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
@@ -82,21 +82,23 @@ The Blazor Chart uses client-side rendering and the label templates are JavaScri
82
82
The JavaScript function for each label template will receive an argument that exposes different properties, depending on the template type. The mechanism is similar to the `context` of Blazor `RenderFragment`s. The sections below list the available method argument properties:
*[How to add new lines to label templates](#new-line-in-the-label-template)
89
-
*[Example for all types of label templates](#label-template-example)
90
+
*[Example for categorical Charts](#label-template-in-categorical-charts)
91
+
*[Example for numerical Charts](#label-template-in-numerical-charts)
90
92
91
93
### Series Label Template
92
94
93
95
The `Template` function of `ChartSeriesLabels` exposes the following fields in the template context:
94
96
95
97
*`category` - the category name. Available for Area, Bar, Column, Donut, Line, and Pie series.
96
-
*`dataItem` - the original data item used to construct the point. Will be `null` if binding to array. Sample syntax: `context.dataItem.MyModelPropertyName`.
98
+
*`dataItem` - the original data item used to construct the point. Will be `null` if binding to array. Sample syntax: `context.dataItem.MyPropertyName`.
97
99
*`percentage` - the point value represented as a percentage value. Available only for Donut, Pie and 100% stacked charts.
98
100
*`stackValue` - the cumulative point value on the stack. Available only for stackable series.
99
-
*`value` - the point value. Can be a number or object containing each bound field.
101
+
*`value` - the point value. Can be a number for categorical series or an object with `x` and `y` properties for numerical series.
100
102
101
103
<!--* `series` - the data series-->
102
104
<!--* runningTotal - the sum of point values since the last "runningTotal" summary point. Available for waterfall series.
@@ -106,23 +108,40 @@ The `Template` function of `ChartSeriesLabels` exposes the following fields in t
106
108
107
109
The `Template` function of `CategoryAxisLabels` exposes the following fields in the template context:
108
110
109
-
*`value` - the category value
110
-
*`format` - the default format of the label
111
+
*`count` - the number of labels on the axis
112
+
*`format` - the numeric or date format of the label
113
+
*`index` - the order index of the label
114
+
*`text` - the label string if no template is used
115
+
*`value` - the category value as a string, number or JavaScript `Date` object
116
+
117
+
### X Axis Label Template
118
+
119
+
The `Template` function of `XAxisLabels` exposes the following fields in the template context:
120
+
121
+
*`count` - the number of labels on the axis
122
+
*`format` - the numeric or date format of the label
123
+
*`index` - the order index of the label
124
+
*`text` - the label string if no template is used
125
+
*`value` - the label as a number or JavaScript `Date` object
111
126
112
127
<!--* `dataItem` - the data item, in case a field has been specified. If the category does not have a corresponding item in the data then an empty object will be passed.-->
113
128
<!--* culture - the default culture (if set) on the label-->
114
129
115
-
### Value Axis Label Template
130
+
### Value and Y Axis Label Template
116
131
117
-
The `Template` function of `ValueAxisLabels` exposes the following fields in the template context:
132
+
The `Template` function of `ValueAxisLabels`and `YAxisLabels`exposes the following fields in the template context:
118
133
119
-
*`value` - the label value
134
+
*`count` - the number of labels on the axis
135
+
*`format` - the default or specified format of the label
136
+
*`index` - the order index of the label
137
+
*`text` - the label string if no template is used
138
+
*`value` - the numeric representation of the label
120
139
121
140
### Legend Item Label Template
122
141
123
142
The `Template` function of `ChartLegendLabels` exposes the following fields in the template context:
124
143
125
-
*`text` - the text the legend item
144
+
*`text` - the text of the legend item
126
145
*`series` - the data series object
127
146
*`value` - the data point value. Available only for Donut and Pie charts.
128
147
*`percentage` - the data point value as a number between 0 and 1. Available only for Donut, Pie and 100% stacked charts.
@@ -139,9 +158,9 @@ function chartLabelFunction(context) {
139
158
}
140
159
````
141
160
142
-
### Label Template Example
161
+
### Label Template in Categorical Charts
143
162
144
-
>caption Using Chart label templates for series, axes and legend
163
+
>caption Using categorical Chart label templates for series, axes and legend
145
164
146
165
````CSHTML
147
166
<TelerikChart>
@@ -288,6 +307,97 @@ function chartLabelFunction(context) {
288
307
}
289
308
````
290
309
310
+
### Label Template in Numerical Charts
311
+
312
+
>caption Using numerical Chart label templates for series, axes and legend
313
+
314
+
````CSHTML
315
+
<TelerikChart>
316
+
<ChartTitle Text="Signal Level vs. Errors per Minute"></ChartTitle>
new ChartModel() { Signal = -88, Errors = 18, ExtraData = "foo 2" },
389
+
new ChartModel() { Signal = -78, Errors = 12, ExtraData = "bar 2" },
390
+
};
391
+
392
+
public class ChartModel
393
+
{
394
+
public decimal Signal { get; set; }
395
+
public int Errors { get; set; }
396
+
public string ExtraData { get; set; } = string.Empty;
397
+
}
398
+
}
399
+
````
400
+
291
401
### Hide Label Conditionally
292
402
293
403
In some cases, you want the series to have labels, but certain data points must not have a label. For example, in a [stacked series]({%slug components/chart/stack%}) where a certain value is `0`.
0 commit comments