Skip to content

Commit 7557a1f

Browse files
svdimitrdimodi
andauthored
Chart Legends docs (#1888)
* docs(chart-legend): docs article * Update components/chart/legend.md Co-authored-by: Dimo Dimov <[email protected]> * Update components/chart/legend.md Co-authored-by: Dimo Dimov <[email protected]> * Update components/chart/legend.md Co-authored-by: Dimo Dimov <[email protected]> * Update components/chart/legend.md Co-authored-by: Dimo Dimov <[email protected]> --------- Co-authored-by: Dimo Dimov <[email protected]>
1 parent 2631eb6 commit 7557a1f

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

components/chart/legend.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
title: Legend
3+
page_title: Chart Legend
4+
description: Discover the capabilities of the Chart Legend in Telerik UI for Blazor. Learn how to show it, and explore the customization options.
5+
slug: chart-legend
6+
tags: telerik,blazor,chart,legend,customizations
7+
published: True
8+
position: 100
9+
---
10+
11+
# Telerik Chart Legend
12+
13+
The Telerik Chart for Blazor can show a visual guide with details about the series or elements in the Chart. This article explores how to add a Chart legend, identify its building blocks, and customize the legend appearance.
14+
15+
## Adding a Legend
16+
17+
1. Add the `<ChartLegend>` child tag and set the `Visible` parameter to `true`
18+
1. Add the `Name` parameter to all Chart series that must be visible in the legend.
19+
20+
## Chart Legend Customization
21+
22+
You can customize the Chart legend by adding nested (child) tags to the `<ChartLegend>` and use their parameters for fine tuning.
23+
24+
The structure of the nested tags is `<ChartLegend*Specifics*>`, where the specifics can be:
25+
26+
* `Title`
27+
* `Item`
28+
* `Border`
29+
30+
>note Use the IntelliSense to explore the nested tags.
31+
32+
## Legend Settings in the Chart Series
33+
34+
You can customize individual items in the legend for a specific Chart series by adding the `<ChartSeriesLegendItem>` (child tag of `<ChartSeries>`) and its nested tag settings and parameters.
35+
36+
The structure of the nested tags is `<ChartSeriesLegend*Specifics*>`, where the specifics can be:
37+
38+
* `Markers`
39+
* `Highlight`
40+
* and others
41+
42+
>note Use the IntelliSense to explore the nested tags.
43+
44+
## Example
45+
46+
Customize the legend items by using nested tag settings.
47+
48+
````CSHTML
49+
<TelerikChart>
50+
<ChartSeriesItems>
51+
<ChartSeries Type="ChartSeriesType.Column" Name="Product 1" Data="@series1Data">
52+
<ChartSeriesLegendItem>
53+
<ChartSeriesLegendItemMarkers Background="blue">
54+
</ChartSeriesLegendItemMarkers>
55+
</ChartSeriesLegendItem>
56+
</ChartSeries>
57+
<ChartSeries Type="ChartSeriesType.Column" Name="Product 2" Data="@series2Data">
58+
<ChartSeriesLegendItem Type="@ChartLegendItemType.Area">
59+
<ChartSeriesLegendItemMarkers Background="#00ff00">
60+
</ChartSeriesLegendItemMarkers>
61+
</ChartSeriesLegendItem>
62+
</ChartSeries>
63+
</ChartSeriesItems>
64+
65+
<ChartCategoryAxes>
66+
<ChartCategoryAxis Categories="@xAxisItems"></ChartCategoryAxis>
67+
</ChartCategoryAxes>
68+
69+
<ChartTitle Text="Quarterly revenue"></ChartTitle>
70+
71+
<ChartLegend Position="ChartLegendPosition.Right" Visible="true">
72+
<ChartLegendTitle Text="Revenue per product"
73+
Background="lightblue"
74+
Color="black">
75+
</ChartLegendTitle>
76+
<ChartLegendItem>
77+
<ChartLegendItemMarkers Type="@ChartSeriesMarkersType.Cross"
78+
Background="#00ff00">
79+
</ChartLegendItemMarkers>
80+
</ChartLegendItem>
81+
</ChartLegend>
82+
</TelerikChart>
83+
84+
@code {
85+
public List<object> series1Data = new List<object>() { 10, 2, 5, 6 };
86+
public List<object> series2Data = new List<object>() { 5, 8, 2, 7 };
87+
public string[] xAxisItems = new string[] { "Q1", "Q2", "Q3", "Q4" };
88+
}
89+
````
90+
91+
## See Also
92+
93+
[Live Chart Legend Customization Demo](https://demos.telerik.com/blazor-ui/chart/legend-customization)

0 commit comments

Comments
 (0)