Chart Events
This article describes the available events for the Telerik Chart for Blazor:
- OnAxisLabelClick
- OnDragEnd
- OnDragStart
- OnDrilldown
- OnLegendItemClick
- OnSeriesClick
- OnZoomEnd
- OnZoomStart
OnAxisLabelClick
The OnAxisLabelClick event fires when the user clicks a label item on any of the Chart axes. The event argument is of type ChartAxisLabelClickEventArgs and exposes the following properties:
| Property | Type | Description |
|---|---|---|
AxisName | string | The value of the Name parameter of the Chart axis. Returns null if Name is not set. |
Index | int | The label index on the clicked axis. |
Text | string | The visible value of the label. It may be formatted. |
Value | object | The underlying non-formatted value of the label. The Value can be:
|
Using the Chart OnAxisLabelClick event
OnLegendItemClick
The OnLegendItemClick event fires when the user clicks on any item in the Chart legend. The event argument is of type ChartLegendItemClickEventArgs and exposes the following properties:
| Property | Type | Description |
|---|---|---|
PointIndex | int? | The data point index in the series Data. Applies to single-series Charts only (Pie and Donut). |
SeriesIndex | int | The series index in the ChartSeriesItems collection. |
Text | string | The label of the clicked legend item. In multi-series Charts, the Text value matches the ChartSeries Name. In single-series Charts (Pie and Donut), the Text value matches the CategoryField value. |
Using the Chart OnLegendItemClick event
OnDragEnd
The Chart OnDragEnd event fires at the end of a drag (pan) gesture. The event argument is of type ChartDragEndEventArgs and exposes the following properties:
| Property | Type | Description |
|---|---|---|
AxisRanges | Dictionary<string, ChartAxisRange> | The visible range of each axis at the end of the drag. The dictionary key is the axis name. Each ChartAxisRange value has Min and Max properties that reflect the new axis range. |
The OnDragEnd event fires after OnDragStart.
OnDragStart
The Chart OnDragStart event fires at the beginning of a drag (pan) gesture. The event argument is of type ChartDragStartEventArgs and exposes the following properties:
| Property | Type | Description |
|---|---|---|
AxisRanges | Dictionary<string, ChartAxisRange> | The visible range of each axis at the start of the drag. The dictionary key is the axis name. Each ChartAxisRange value has Min and Max properties that reflect the current axis range. |
The OnDragStart event fires before OnDragEnd.
OnDrilldown
The OnDrilldown event is triggered when the drill-down functionality executes. The handler of this event accepts a ChartDrilldownEventArgs object as a parameter. You can access the name of the drilled down (clicked) series through the SeriesName property of the event arguments object.
OnSeriesClick
The OnSeriesClick event fires as a response to the user click on a <ChartSeries>.
Below you can find:
- Event Arguments
- Examples:
Event Arguments
The event handler receives a ChartSeriesClickEventArgs object which provides the following data:
-
DataItem- provides the data model of the current series item. You need to cast it to the type from your datasource, which needs to be serializable.- If you are using a Date Axis, the
DataItemwill contain the only the aggregated value in the corresponding y-value field, because it is a collection of more than one items. See theCategorybelow for details.
- If you are using a Date Axis, the
-
Category- provides information on the category the data point is located in. You need to cast it to the type in your data source, for exampleDateTime,string,intor another type. The Category parameter is applicable to Categorical Charts.- When using a Date Axis, you can use it, together with the
BaseUnitvalue of the axis, to filter the data source and obtain the actual data items from the data source in case you want to provide extra information about them.
- When using a Date Axis, you can use it, together with the
-
Percentage- applicable to Donut, Pie and Stacked 100% Charts - the percentage value of the current data point from the whole. -
SeriesIndex- provides the index of the<ChartSeries>the data point belongs to. -
SeriesName- bound to the Name parameter of the<ChartSeries>the data point belongs to. -
SeriesColor- shows the RGB color of the Series the data point belongs to. -
CategoryIndex- shows the index of the data point's x-axis category.
Examples
These examples showcase the different applications of the OnSeriesClick event.
- Basic Click Handler
- Get The Data Model For The Clicked Series
- Load Data On Demand Based On Series Click
Basic Click Handler
Get The Data Model For The Clicked Series
Load Data On Demand Based On Series Click
OnZoomEnd
The Chart OnZoomEnd event fires at the end of a zoom gesture. The event argument is of type ChartZoomEndEventArgs and exposes the following properties:
| Property | Type | Description |
|---|---|---|
AxisRanges | Dictionary<string, ChartAxisRange> | The visible range of each axis at the end of the zoom. The dictionary key is the axis name. Each ChartAxisRange value has Min and Max properties that reflect the new axis range. |
The OnZoomEnd event fires after OnZoomStart.
OnZoomStart
The Chart OnZoomStart event fires at the beginning of a zoom gesture. The event argument is of type ChartZoomStartEventArgs and exposes the following properties:
| Property | Type | Description |
|---|---|---|
AxisRanges | Dictionary<string, ChartAxisRange> | The visible range of each axis at the start of the zoom. The dictionary key is the axis name. Each ChartAxisRange value has Min and Max properties that reflect the current axis range. |
The OnZoomStart event fires before OnZoomEnd.