TcxGridChartDiagramLegendItemCustomDrawEvent Type
The procedural type for legend item draw events.
Declaration
TcxGridChartDiagramLegendItemCustomDrawEvent = procedure(Sender: TcxGridChartDiagram; ACanvas: TcxCanvas; AViewInfo: TcxGridChartLegendItemViewInfo; var ADone: Boolean) of object;
Parameters
Name | Type | Description |
---|---|---|
Sender | TcxGridChartDiagram | The grid Chart diagram that raised the legend item draw event. |
ACanvas | TcxCanvas | Provides access to the target legend item’s canvas. You can call draw methods accessible through the |
AViewInfo | TcxGridChartLegendItemViewInfo | Returns information required to identify and draw the processed legend item. Use the |
ADone | Boolean | Specifies if the custom draw event handler overrides or complements built-in draw routines for the target legend item:
|
Remarks
A legend item custom draw event occurs every time the grid Chart diagram is about to draw a legend item. You can handle this event to change the appearance of individual legend items depending on specific conditions in your application.
Code Example: Highlight Legend Items
The following code example fills background with two colors for legend items with different names:
uses
cxGrid, // Declares the TcxGrid control
cxGridDBChartView, // Declares the TcxGridDBChartView class
StrUtils; // Declares the ContainsText function
// ...
procedure TMyForm.cxGrid1ChartViewDiagramStackedColumnCustomDrawLegendItem(
Sender: TcxGridChartDiagram; ACanvas: TcxCanvas;
AViewInfo: TcxGridChartLegendItemViewInfo; var ADone: Boolean);
begin
if ContainsText((AViewInfo.Series as TcxGridDBChartSeries).DataBinding.FieldName, 'Female') then
ACanvas.FillRect(AViewInfo.Bounds, clWebLightGreen)
else
ACanvas.FillRect(AViewInfo.Bounds, clWebLightCoral);
end;
Direct TcxGridChartDiagramLegendItemCustomDrawEvent Type Reference
The TcxGridChartDiagram.OnCustomDrawLegendItem event references the TcxGridChartDiagramLegendItemCustomDrawEvent
procedural type.