Back to Devexpress

XRChart.CustomDrawSeries Event

xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xrchart-48ff2233.md

latest11.8 KB
Original Source

XRChart.CustomDrawSeries Event

Occurs before a series is drawn when the chart’s contents are being drawn.

Namespace : DevExpress.XtraReports.UI

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
public event CustomDrawSeriesEventHandler CustomDrawSeries
vb
Public Event CustomDrawSeries As CustomDrawSeriesEventHandler

Event Data

The CustomDrawSeries event's data class is CustomDrawSeriesEventArgs. The following properties provide information specific to this event:

PropertyDescription
DisposeLegendCheckBoxImageGets or sets the value specifying whether CustomDrawSeriesEventArgs.LegendCheckBoxImage should be disposed when drawing is finished.
DisposeLegendFontGets or sets the value specifying whether the e.DXLegendFont should be disposed when drawing is finished. Inherited from CustomDrawSeriesEventArgsBase.
DisposeLegendMarkerImageGets or sets the value specifying whether e.DXLegendMarkerImage should be disposed when drawing is finished. Inherited from CustomDrawSeriesEventArgsBase.
DXLegendFontGets or sets the text font of the legend item of the series or series point that is currently being painted. Inherited from CustomDrawSeriesEventArgsBase.
DXLegendMarkerImageGets or sets the image of the legend item marker of the series or series point that is currently being painted. Inherited from CustomDrawSeriesEventArgsBase.
LegendCheckBoxDXImageGets or sets the image of the legend item check box of the series or series point that is currently being painted.
LegendCheckBoxImageGets or sets the image of the legend item check box of the series or series point that is currently being painted.
LegendCheckBoxImageSizeModeGets or sets the image size mode of the legend item check box of the series or series point that is currently being painted.
LegendCheckBoxSizeGets or sets the size of the legend item check box of the series or series point that is currently being painted.
LegendCheckBoxVisibleGets or sets the visibility of the legend item check box of the series that is currently being painted.
LegendDrawOptionsReturns the draw settings of the legend item of the series that is currently being drawn. Inherited from CustomDrawSeriesEventArgsBase.
LegendFontGets or sets the text font of the legend item of the series or series point that is currently being painted. Inherited from CustomDrawSeriesEventArgsBase.
LegendMarkerImageGets or sets the image of the legend item marker of the series or series point that is currently being painted. Inherited from CustomDrawSeriesEventArgsBase.
LegendMarkerImageSizeModeGets or sets the image size mode of the legend item marker of the series or series point that is currently being painted. Inherited from CustomDrawSeriesEventArgsBase.
LegendMarkerSizeGets or sets the size of the legend item marker of the series or series point that is currently being painted. Inherited from CustomDrawSeriesEventArgsBase.
LegendMarkerVisibleGets or sets the visibility of the legend item marker of the series or series point that is currently being painted. Inherited from CustomDrawSeriesEventArgsBase.
LegendTextGets or sets the text of the legend item of the series or series point that is currently being painted. Inherited from CustomDrawSeriesEventArgsBase.
LegendTextColorGets or sets the text color of the legend item of the series or series point that is currently being painted. Inherited from CustomDrawSeriesEventArgsBase.
LegendTextVisibleGets or sets the text visibility of the legend item of the series whose points are currently being drawn. Inherited from CustomDrawSeriesEventArgsBase.
SeriesReturns the series that is currently being painted. Inherited from CustomDrawSeriesEventArgsBase.
SeriesDrawOptionsReturns the draw settings of the series that is currently being drawn. Inherited from CustomDrawSeriesEventArgsBase.

Remarks

The CustomDrawSeries event is raised before every series is painted. The event parameter’s Series property provides the series which enables the series view and other specific series options to be determined. And the SeriesDrawOptions property provides the drawing options specific to each series. Note that the return value of this property should be typecast to the corresponding type (e.g., BarDrawOptions).

Example

This example demonstrates how to implement custom drawing in charts when drawing its series. To do this, you should handle the XRChart.CustomDrawSeries event, and then you’re able to change some drawing parameters using its event args.

csharp
using DevExpress.XtraCharts;
// ...

private void xrChart1_CustomDrawSeries(object sender, CustomDrawSeriesEventArgs e) {
   // Find all Bar Series by their view type,
   // and fill them with Aqua color.
   if (e.Series.View is BarSeriesView)
      e.SeriesDrawOptions.Color = Color.Aqua;

   // Find the series by its name, and change its line style to dash-dot-dot.
   // (Here it's assumed that the series view type is LineSeriesView).
   if (e.Series.Name == "Line Series") 
      ((LineDrawOptions)e.SeriesDrawOptions).LineStyle.DashStyle = DashStyle.DashDotDot;

   // Find all Point Series by the type of its DrawOptions, 
   // and change their marker kind to diamond.
   if (e.SeriesDrawOptions.GetType() == typeof(PointDrawOptions)) 
      ((PointDrawOptions)e.SeriesDrawOptions).Marker.Kind = MarkerKind.Diamond;
}
vb
Imports DevExpress.XtraCharts
' ...

Private Sub OnCustomDrawSeries(sender As Object, e As CustomDrawSeriesEventArgs) _ 
Handles XrChart1.CustomDrawSeries
   ' Find all Bar Series by their view type, and fill them with Aqua color.
   If TypeOf e.Series.View Is BarSeriesView Then
      e.SeriesDrawOptions.Color = Color.Aqua
   End If

   ' Find the series by its name, and change its line style to dash-dot-dot.
   ' (Here it's assumed that the series view type is LineSeriesView).
   If e.Series.Name = "Line Series" Then
      CType(e.SeriesDrawOptions, LineDrawOptions).LineStyle.DashStyle = DashStyle.DashDotDot
   End If

   ' Find all Point Series by the type of its DrawOptions, 
   ' and change their marker kind to diamond.
   If e.SeriesDrawOptions.GetType() Is GetType(PointDrawOptions) Then
      CType(e.SeriesDrawOptions, PointDrawOptions).Marker.Kind = MarkerKind.Diamond
   End If
End Sub

See Also

XRChart Class

XRChart Members

DevExpress.XtraReports.UI Namespace