Skip to content

Commit cd8251c

Browse files
authored
Updates to the Chart Tooltip Docs (#80)
* chore(chart): updates to the chart tooltip docs * chore(chart): added new template file; small wording updates * chore(chart): updated chart tooltip docs
1 parent 90dbd39 commit cd8251c

File tree

5 files changed

+54
-51
lines changed

5 files changed

+54
-51
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#context-parameter-information
2+
* `FormattedValue` - maps to the default rendering of the tooltip, formatted as a string.
3+
* Use this when the chart's data is bound by [Independent Series Binding]({%slug components/chart/databind%}#independent-series-binding). You can parse this to a numerical value (`int`, `double`, etc.) in order to apply formatting. Otherwise, use the `DataItem` to get the value of the point.
4+
5+
* `DataItem` - provides the data model of the current series item. You may need to cast it to its type.
6+
7+
* `Percentage` - applicable to [Donut]({%slug components/chart/types/donut%}), [Pie]({%slug components/chart/types/pie%}) and [Stacked 100%]({%slug components/chart/stack%}#stack-100) Charts - the percentage value of the current data point from the whole.
8+
9+
* `SeriesIndex` - provides the index of the `<ChartSeries>` the data point belongs to.
10+
11+
* `SeriesName` - bound to the `Name` parameter of the `<ChartSeries>` the data point belongs to.
12+
13+
* `SeriesColor` - shows the RGB color of the Series the data point belongs to.
14+
15+
* `CategoryIndex` - shows the index of the data point's x-axis category.
16+
#end
17+
18+
19+
#shared-tooltip-parameter-settings
20+
* `Background` - control the background color by applying a CSS color string, including HEX and RGB. By default the it will match the color for the category.
21+
22+
* `Color` - control the text color by applying a CSS color string, including HEX and RGB.
23+
24+
* `Opacity` - control the opacity of the tooltip.
25+
26+
* `Border` - control the `Color` and the `Width` of the tooltip by using the `<ChartSeriesTooltipBorder />` nested inside the `<ChartSeriesTooltip>` tag.
27+
28+
* `Padding` - control the `Left`, `Right`, `Top` and `Bottom` padding of the tooltip by using the `<ChartSeriesTooltipPadding />` nested inside the `<ChartSeriesTooltip>` tag.
29+
#end

_contentTemplates/chart/link-to-basics.md

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -185,31 +185,3 @@ This approach is not limited only to the Labels - it can be used with to all tag
185185

186186
#end
187187

188-
#context-parameter-information
189-
* `Value` - maps to the value of the data point that is being hovered.
190-
191-
* `DataItem` - provides the data model of the current series item. You may need to cast it to its type.
192-
193-
* `Percentage` - applicable to [Donut]({%slug components/chart/types/donut%}), [Pie]({%slug components/chart/types/pie%}) and [Stacked 100%]({%slug components/chart/stack%}#stack-100) Charts - the percentage value of the current data point from the whole.
194-
195-
* `SeriesIndex` - provides the index of the `<ChartSeries>` the data point belongs to.
196-
197-
* `SeriesName` - bound to the `Name` parameter of the `<ChartSeries>` the data point belongs to.
198-
199-
* `SeriesColor` - shows the RGB color of the Series the data point belongs to.
200-
201-
* `CategoryIndex` - shows the index of the data point's x-axis category.
202-
#end
203-
204-
205-
#shared-tooltip-parameter-settings
206-
* `Background` - control the background color by applying a CSS color string, including HEX and RGB. By default the it will match the color for the category.
207-
208-
* `Color` - control the text color by applying a CSS color string, including HEX and RGB.
209-
210-
* `Opacity` - control the opacity of the tooltip.
211-
212-
* `Border` - control the `Color` and the `Width` of the tooltip by using the `<ChartSeriesTooltipBorder />` nested inside the `<ChartSeriesTooltip>` tag.
213-
214-
* `Padding` - control the `Left`, `Right`, `Top` and `Bottom` padding of the tooltip by using the `<ChartSeriesTooltipPadding />` nested inside the `<ChartSeriesTooltip>` tag.
215-
#end
2.01 KB
Loading

components/chart/tooltip/overview.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ To enable tooltips for the data points of each individual series:
4040
<ChartSeriesItems>
4141
<ChartSeries Type="ChartSeriesType.Column" Name="Series 1" Data="@data1">
4242
</ChartSeries>
43-
43+
4444
<ChartSeries Type="ChartSeriesType.Column" Name="Series 2" Data="@data2">
4545
<ChartSeriesTooltip Visible="true"></ChartSeriesTooltip>
4646
</ChartSeries>
47-
47+
4848
</ChartSeriesItems>
4949
5050
<ChartCategoryAxes>
@@ -84,7 +84,7 @@ To enable the same tooltip for all series:
8484
8585
<ChartTooltip Visible="true">
8686
</ChartTooltip>
87-
87+
8888
<ChartSeriesItems>
8989
<ChartSeries Type="ChartSeriesType.Bar" Name="Product 1" Data="@series1Data">
9090
</ChartSeries>
@@ -201,7 +201,7 @@ You can customize the appearance of the individual series tooltip by using:
201201

202202
In a similar fashion, you can declare these settings in the common tooltip section. Their tag names are slightly different, however:
203203

204-
@[template](/_contentTemplates/chart/link-to-basics.md#shared-tooltip-parameter-settings)
204+
@[template](/_contentTemplates/chart/chart-tooltip-context-templates.md#shared-tooltip-parameter-settings)
205205

206206
* Use the [Template](#template) to take control over what is rendered in the tooltip - the tag name and data it provides is the same as for the specific tooltip, but it affects all series at once.
207207

@@ -218,10 +218,10 @@ In the template you can:
218218

219219
The available series data point information in the `context` is:
220220

221-
@[template](/_contentTemplates/chart/link-to-basics.md#context-parameter-information)
221+
@[template](/_contentTemplates/chart/chart-tooltip-context-templates.md#context-parameter-information)
222222

223223

224-
>caption Use the Tooltip Template to add an Icon and additional information to the series tooltip
224+
>caption Use the Tooltip Template and use the DataItem to get the value of the point and add additional information
225225
226226
````CSHTML
227227
@* This example shows how to use the Template to provide an Icon and additional information from the model *@
@@ -235,7 +235,7 @@ The available series data point information in the `context` is:
235235
<ChartSeriesTooltip Visible="true">
236236
<Template>
237237
<TelerikIcon Icon="@IconName.Information" />
238-
@context.Value for @((context.DataItem as MyDataModel).ExtraData)
238+
@((context.DataItem as MyDataModel).SecondSeriesValue) for @((context.DataItem as MyDataModel).ExtraData)
239239
</Template>
240240
</ChartSeriesTooltip>
241241
</ChartSeries>
@@ -264,7 +264,7 @@ The available series data point information in the `context` is:
264264
}
265265
266266
public List<MyDataModel> modelData = new List<MyDataModel>()
267-
{
267+
{
268268
new MyDataModel() { SecondSeriesValue = 1, ExtraData = "first" },
269269
new MyDataModel() { SecondSeriesValue = 5, ExtraData = "second" },
270270
new MyDataModel() { SecondSeriesValue = 3, ExtraData = "third" },

components/chart/tooltip/shared.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ There are two types of customizations you can do for the tooltips:
7373
### Parameter Settings
7474
You can customize the rendering of the `Shared` tooltip by using:
7575

76-
@[template](/_contentTemplates/chart/link-to-basics.md#shared-tooltip-parameter-settings)
76+
@[template](/_contentTemplates/chart/chart-tooltip-context-templates.md#shared-tooltip-parameter-settings)
7777

7878

7979
### Shared Template
@@ -95,29 +95,31 @@ The `context` contains the following information:
9595

9696
Each `Point` contains the following data:
9797

98-
@[template](/_contentTemplates/chart/link-to-basics.md#context-parameter-information)
98+
@[template](/_contentTemplates/chart/chart-tooltip-context-templates.md#context-parameter-information)
9999

100100

101101
>caption Usage of the SharedTemplate
102102
103103
````CSHTML
104-
@* This example shows how to use the SharedTemplate and extract information on the data points value and category from the context *@
104+
@* This example shows how to use the SharedTemplate and extract information on the data points value, parse them to int and get the category from the context *@
105105
106106
<TelerikChart>
107107
<ChartTooltip Visible="true" Shared="true">
108108
<SharedTemplate>
109-
@{
110-
var points = context.Points;
111-
112-
foreach (var point in points)
113-
{
114-
<div>
115-
<TelerikIcon Icon="@IconName.Information" />
116-
Point value: @point.Value
117-
Category: @context.Category
118-
</div>
119-
}
120-
}
109+
@{
110+
var points = context.Points;
111+
112+
foreach (var point in points)
113+
{
114+
<div>
115+
<TelerikIcon Icon="@IconName.Information" />
116+
@*this example shows how to parse the FormattedValue to a int,*@
117+
@*but you can also parse it to any other type your data uses / has*@
118+
Point value: @(int.Parse(point.FormattedValue).ToString("C"))
119+
Category: @context.Category
120+
</div>
121+
}
122+
}
121123
</SharedTemplate>
122124
</ChartTooltip>
123125
<ChartSeriesItems>

0 commit comments

Comments
 (0)