You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: components/chart/events.md
+204-1Lines changed: 204 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,213 @@ position: 32
10
10
11
11
# Chart Events
12
12
13
-
This article explains the available events for the Telerik Chart for Blazor:
13
+
This article describes the available events for the Telerik Chart for Blazor:
14
14
15
+
*[OnAxisLabelClick](#onaxislabelclick)
16
+
*[OnLegendItemClick](#onlegenditemclick)
15
17
*[OnSeriesClick](#onseriesclick)
16
18
19
+
## OnAxisLabelClick
20
+
21
+
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:
|`AxisName`|`string`| The value of the `Name` parameter of the Chart axis. Returns `null` if `Name` is not set. |
28
+
|`Index`|`int`| The label index on the clicked axis. |
29
+
|`Text`|`string`| The visible value of the label. It may be formatted. |
30
+
|`Value`|`object`| The underlying non-formatted value of the label. The `Value` can be: <ul><li>The same as the <code>Text</code> value when clicking on a category axis label.</li><li>A numeric value when clicking on a value axis label.</li><li>An ISO-8601 DateTime string when clicking on a date axis.</li></ul> |
Console.WriteLine($"Clicked axis label {args.Text} with index {args.Index} and value {args.Value} from axis {args.AxisName}.");
60
+
}
61
+
62
+
protected override void OnInitialized()
63
+
{
64
+
var rnd = new Random();
65
+
var now = DateTime.Today;
66
+
var monthsBack = 12;
67
+
68
+
for (int i = 1; i <= monthsBack; i++)
69
+
{
70
+
var dateTimeValue = now.AddMonths(-monthsBack + i);
71
+
72
+
Series1Data.Add(new SalesData()
73
+
{
74
+
Id = i,
75
+
Product = "Smartphones",
76
+
Revenue = rnd.Next(500, 900),
77
+
TimePeriod = dateTimeValue
78
+
});
79
+
}
80
+
81
+
base.OnInitialized();
82
+
}
83
+
84
+
public class SalesData
85
+
{
86
+
public int Id { get; set; }
87
+
public string Product { get; set; }
88
+
public DateTime TimePeriod { get; set; }
89
+
public decimal Revenue { get; set; }
90
+
}
91
+
}
92
+
````
93
+
94
+
## OnLegendItemClick
95
+
96
+
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:
97
+
98
+
| Property | Type | Description |
99
+
| --- | --- | --- |
100
+
|`PointIndex`|`int?`| The data point index in the series `Data`. Applies to single-series Charts only (Pie and Donut). |
101
+
|`SeriesIndex`|`int`| The series index in the `ChartSeriesItems` collection. |
102
+
|`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. |
0 commit comments