Back to Devexpress

XRChart.CustomDrawSeriesPoint Event

xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xrchart-1198763e.md

latest14.5 KB
Original Source

XRChart.CustomDrawSeriesPoint Event

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

Namespace : DevExpress.XtraReports.UI

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
public event CustomDrawSeriesPointEventHandler CustomDrawSeriesPoint
vb
Public Event CustomDrawSeriesPoint As CustomDrawSeriesPointEventHandler

Event Data

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

PropertyDescription
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.
LabelTextGets or sets the text of a label for the point 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.
PercentValueReturns the portion of the series point’s value within the total value of a series group to which the series point belongs.
SecondLabelTextGets or sets the text of a second label for the point currently being painted for specific series views.
SelectionStateSpecifies the selection state mode for the series whose points are currently being painted.
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.
SeriesPointGets the series point currently being painted.
TotalLabelTextObsolete. Gets or sets the text of a series group’s total label.
TotalValueReturns the total value of a series group to which the series point belongs.

Remarks

The CustomDrawSeriesPoint event is raised before every series point is painted. The event parameter’s Series property provides the series which enables the series view and other specific series options to be determined. The SeriesPoint property provides the series point which enables to all the data that corresponds to the series point being painted.

And the SeriesDrawOptions property provides 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 the series points of charts. To do this, you should handle the XRChart.CustomDrawSeriesPoint event, and then you can change some of the drawing parameters using its event args.

csharp
using DevExpress.XtraCharts;
// ...

private void xrChart1_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);
   }
}
vb
Imports DevExpress.XtraCharts
' ...

Private Sub OnCustomDrawSeriesPoint(ByVal sender As Object, _ 
ByVal e As CustomDrawSeriesPointEventArgs) Handles XrChart1.CustomDrawSeriesPoint

   ' These changes will be applied to Bar Series only.
   Dim drawOptions = CType(e.SeriesDrawOptions, BarDrawOptions)
   If drawOptions Is Nothing Then
      Return
   End If

   ' Get the fill options for the series point.
   drawOptions.FillStyle.FillMode = FillMode.Gradient
   Dim options = CType(drawOptions.FillStyle.Options, RectangleGradientFillOptions)
   If options Is Nothing Then
      Return
   End If

   ' Get the value at the current series point.
   Dim val As Double = e.SeriesPoint(0)

   ' If the value is less than 2.5, then fill the bar with green colors.
   If val < 2.5 Then
      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 Then
         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)
      End If
   End If
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomDrawSeriesPoint 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.

bi-dashboard-non-visual-custom-export/CS/DashboardExporterApp/ExportControlProviders/FunnelItemExportControlProvider.cs#L17

csharp
chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
chart.CustomDrawSeriesPoint += CustomDrawSeriesPoint;
DashboardFlatDataSource flatData = customItemData.GetFlatData(new DashboardFlatDataSourceOptions() {

bi-dashboard-non-visual-custom-export/VB/DashboardExporterApp/ExportControlProviders/FunnelItemExportControlProvider.vb#L19

vb
chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True
AddHandler chart.CustomDrawSeriesPoint, AddressOf CustomDrawSeriesPoint
Dim flatData As DashboardFlatDataSource = customItemData.GetFlatData(New DashboardFlatDataSourceOptions() With {.AddColoringColumns = True})

See Also

XRChart Class

XRChart Members

DevExpress.XtraReports.UI Namespace