Skip to main content
A newer version of this page is available. .

ChartControl.CustomDrawSeries Event

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

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v20.2.UI.dll

NuGet Package: DevExpress.Win.Charts

Declaration

public event CustomDrawSeriesEventHandler CustomDrawSeries

Event Data

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

Property Description
DisposeLegendCheckBoxImage Gets or sets the value specifying whether CustomDrawSeriesEventArgs.LegendCheckBoxImage should be disposed when drawing is finished.
DisposeLegendFont Gets or sets the value specifying whether the CustomDrawSeriesEventArgsBase.LegendFont should be disposed when drawing is finished. Inherited from CustomDrawSeriesEventArgsBase.
DisposeLegendMarkerImage Gets or sets the value specifying whether CustomDrawSeriesEventArgsBase.LegendMarkerImage should be disposed when drawing is finished. Inherited from CustomDrawSeriesEventArgsBase.
LegendCheckBoxImage Gets or sets the image of the legend item check box of the series or series point that is currently being painted.
LegendCheckBoxImageSizeMode Gets or sets the image size mode of the legend item check box of the series or series point that is currently being painted.
LegendCheckBoxSize Gets or sets the size of the legend item check box of the series or series point that is currently being painted.
LegendCheckBoxVisible Gets or sets the visibility of the legend item check box of the series that is currently being painted.
LegendDrawOptions Returns the draw settings of the legend item of the series that is currently being drawn. Inherited from CustomDrawSeriesEventArgsBase.
LegendFont Gets or sets the text font of the legend item of the series or series point that is currently being painted. Inherited from CustomDrawSeriesEventArgsBase.
LegendMarkerImage Gets or sets the image of the legend item marker of the series or series point that is currently being painted. Inherited from CustomDrawSeriesEventArgsBase.
LegendMarkerImageSizeMode Gets 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.
LegendMarkerSize Gets or sets the size of the legend item marker of the series or series point that is currently being painted. Inherited from CustomDrawSeriesEventArgsBase.
LegendMarkerVisible Gets or sets the visibility of the legend item marker of the series or series point that is currently being painted. Inherited from CustomDrawSeriesEventArgsBase.
LegendText Gets or sets the text of the legend item of the series or series point that is currently being painted. Inherited from CustomDrawSeriesEventArgsBase.
LegendTextColor Gets or sets the text color of the legend item of the series or series point that is currently being painted. Inherited from CustomDrawSeriesEventArgsBase.
LegendTextVisible Gets or sets the text visibility of the legend item of the series whose points are currently being drawn. Inherited from CustomDrawSeriesEventArgsBase.
Series Returns the series that is currently being painted. Inherited from CustomDrawSeriesEventArgsBase.
SeriesDrawOptions Returns 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 CustomDrawSeriesEventArgsBase.Series property provides the series which enables the series view and other specific series options to be determined. And the CustomDrawSeriesEventArgsBase.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).

The CustomDrawSeries and ChartControl.CustomDrawSeriesPoint events are always raised in the following order.

  • The CustomDrawSeries event for the first series in the chart’s ChartControl.Series collection. The first series in the series collection is a Series which the SeriesCollection.IndexOf method returns 0 for.
  • The CustomDrawSeriesPoint event for all the series points of the first series.
  • The CustomDrawSeries event for the second series in the chart’s ChartControl.Series collection.
  • The CustomDrawSeriesPoint event for all the series points of the second series.
  • …and so on for all the other series and their points.

Example

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

Note

For the WebChartControl you should handle its WebChartControl.CustomDrawSeries event to implement this task.

using DevExpress.XtraCharts;
// ...

private void chartControl1_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;
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the CustomDrawSeries event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also