CustomDrawSeriesPointEventArgs Class
Provides data for a chart control’s ChartControl.CustomDrawSeriesPoint (WebChartControl.CustomDrawSeriesPoint) event.
Namespace: DevExpress.XtraCharts
Assembly: DevExpress.XtraCharts.v24.1.dll
NuGet Package: DevExpress.Charts
Declaration
Remarks
The CustomDrawSeriesPointEventArgs class represents an argument for the ChartControl.CustomDrawSeriesPoint event of a chart control.
An instance of the CustomDrawSeriesPointEventArgs class with appropriate settings is automatically created and passed to the corresponding event’s handler.
Important
Note, that if you change properties of the chart elements that are available only via getters (e.g., CustomDrawSeriesPointEventArgs.SeriesPoint), these changes will not be effected. To make changes that should be effected, use the CustomDrawSeriesEventArgsBase.SeriesDrawOptions property.
Example
This example demonstrates how to implement custom drawing in charts when drawing the series points of charts. To do this you should handle the ChartControl.CustomDrawSeriesPoint event, and then you can change some of the drawing parameters using its event args.
using DevExpress.XtraCharts;
// ...
private void chartControl1_CustomDrawSeriesPoint(object sender,
CustomDrawSeriesPointEventArgs e) {
// These changes will be applied to Bar Series only.
BarDrawOptions drawOptions = e.SeriesDrawOptions as BarDrawOptions;
if (drawOptions == null)
return;
// Get the fill options for the series point.
drawOptions.FillStyle.FillMode = FillMode.Gradient;
RectangleGradientFillOptions options =
drawOptions.FillStyle.Options as RectangleGradientFillOptions;
if (options == null)
return;
// Get the value at the current series point.
double val = e.SeriesPoint[0];
// If the value is less than 2.5, then fill the bar with green colors.
if (val < 2.5) {
options.Color2 = Color.FromArgb(154, 196, 84);
drawOptions.Color = Color.FromArgb(81, 137, 3);
drawOptions.Border.Color = Color.FromArgb(100, 39, 91, 1);
}
// ... if the value is less than 5.5, then fill the bar with yellow colors.
else if (val < 5.5) {
options.Color2 = Color.FromArgb(254, 233, 124);
drawOptions.Color = Color.FromArgb(249, 170, 15);
drawOptions.Border.Color = Color.FromArgb(60, 165, 73, 5);
}
// ... if the value is greater, then fill the bar with red colors.
else {
options.Color2 = Color.FromArgb(242, 143, 112);
drawOptions.Color = Color.FromArgb(199, 57 ,12);
drawOptions.Border.Color = Color.FromArgb(100, 155, 26, 0);
}
}