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: blazor/chart/legend.md
+95Lines changed: 95 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -678,6 +678,101 @@ The series [Name](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Charts
678
678
679
679

680
680
681
+
## Legend Template
682
+
683
+
Legend templates allow you to replace default legend icons and text with custom HTML or Blazor markup for each series. This enables branded styles, richer content (icons, multi-line text, badges), improved readability, and localization.
684
+
685
+
To use, add a `LegendItemTemplate` inside any [ChartSeries](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Charts.ChartSeries.html) you want to customize. The rendered content becomes the legend item and can be styled with CSS. Legend interactions (click to toggle series) remain unless [ToggleVisibility](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Charts.ChartLegendSettings.html#Syncfusion_Blazor_Charts_ChartLegendSettings_ToggleVisibility) is set to false. Templates work with all legend positions, alignments, and paging.
686
+
687
+
```
688
+
@using Syncfusion.Blazor.Charts
689
+
690
+
@* Initialize the chart and configure essential features *@
new ChartData{ Country= "USA", Gold=50, Silver=70, Bronze=45 },
760
+
new ChartData{ Country= "China", Gold=40, Silver=60, Bronze=55 },
761
+
new ChartData{ Country= "Japan", Gold=70, Silver=60, Bronze=50 },
762
+
new ChartData{ Country= "Australia",Gold=60, Silver=56, Bronze=40 },
763
+
new ChartData{ Country= "France", Gold=50, Silver=45, Bronze=35 },
764
+
new ChartData{ Country= "Germany", Gold=40, Silver=30, Bronze=22 },
765
+
new ChartData{ Country= "Italy", Gold=40, Silver=35, Bronze=37 },
766
+
new ChartData{ Country= "Sweden", Gold=30, Silver=25, Bronze=27 }
767
+
};
768
+
769
+
public int GoldTotal => (int)MedalDetails.Sum(m => m.Gold);
770
+
public int SilverTotal => (int)MedalDetails.Sum(m => m.Silver);
771
+
public int BronzeTotal => (int)MedalDetails.Sum(m => m.Bronze);
772
+
}
773
+
```
774
+

775
+
681
776
N> Refer to our [Blazor Charts](https://www.syncfusion.com/blazor-components/blazor-charts) feature tour page for its groundbreaking feature representations and also explore our [Blazor Chart Example](https://blazor.syncfusion.com/demos/chart/line?theme=bootstrap5) to know various chart types and how to represent time-dependent data, showing trends at equal intervals.
0 commit comments