New to Telerik UI for Blazor? Download free 30-day trial

How to Style the Series Labels for a Chart


Product Chart for Blazor


The UI for Blazor Chart is rendered using the HTML Canvas API or Scalable Vector Graphic and that means manipulating the styling and appearance is not possible without an existing API from the chart component.


In this case, use the ChartSeriesLabelsBase API properties to alter the style and appearance as desired. The properties accept typical CSS styling convention. For example, to bold the Font use a common CSS font-family designation as shown below in the code snippet.

You can also explore the child tags of the labels for more options on controlling borders, margins and paddings. The third series showcases that.

For more detailed control over the text shown in the labels, see the Label Template and Format article.

        <ChartSeries Type="ChartSeriesType.Column" Name="Product 3" Data="@series1Data">
            <ChartSeriesStack Enabled="true" />
            <ChartSeriesLabels Position="ChartSeriesLabelsPosition.OutsideEnd"
                               Font="16px 'Times New Roman'"
        <ChartSeries Type="ChartSeriesType.Column" Name="Product 2" Data="@series2Data">
            <ChartSeriesStack Enabled="true" />
            <ChartSeriesLabels Position="ChartSeriesLabelsPosition.Top"
                               Font="bold 14px 'Comic Sans MS'"
                               Background="transparent" />
        <ChartSeries Type="ChartSeriesType.Column" Name="Product 1" Data="@series3Data">
            <ChartSeriesStack Enabled="true" />
            <ChartSeriesLabels Position="ChartSeriesLabelsPosition.Above"
                               Font="bold 22px Times New Roman"
                               Background="rgba(0, 128, 0, 0.2)">
                <ChartSeriesLabelsBorder Color="red" Width="5" DashType="@DashType.LongDashDotDot" />
                <ChartSeriesLabelsMargin Left="50" />
                <ChartSeriesLabelsPadding Top="50" />

        <ChartCategoryAxis Categories="@xAxisItems"></ChartCategoryAxis>

    <ChartTitle Text="Quarterly revenue per product"></ChartTitle>

    <ChartLegend Position="ChartLegendPosition.Right">

@code {
    public List<object> series1Data = new List<object>() { 10, 2, 5, 6 };
    public List<object> series2Data = new List<object>() { 5, 8, 2, 7 };
    public List<object> series3Data = new List<object>() { 15, 3, 8, 8 };
    public string[] xAxisItems = new string[] { "Q1", "Q2", "Q3", "Q4" };

See Also

In this article