How can the font size used in Chart Labels and Legends be set? I don't see any configuration for that, and overriding the CSS has no effect on the SVG generated for the charts.
1 Answer, 1 is accepted
0
Tsvetomir
Telerik team
answered on 29 May 2024, 10:10 AM
Hi Ted,
To change the font size of the Chart series and Chart legend labels, use the Fontparameter. The only specific to this parameter is that the expected value is a valid CSS font string (e.g., "20px Sans-serif").
To assist you further, I crafted an example that demonstrates the desired outcome:
<TelerikChart><ChartSeriesItems><ChartSeriesType="ChartSeriesType.Column"Name="Product 1"Data="@series1Data"><ChartSeriesLegendItem><ChartSeriesLegendItemMarkersBackground="blue"></ChartSeriesLegendItemMarkers></ChartSeriesLegendItem><ChartSeriesLabelsVisible="true"Font="15px Sans-serif" /></ChartSeries><ChartSeriesType="ChartSeriesType.Column"Name="Product 2"Data="@series2Data"><ChartSeriesLegendItemType="@ChartLegendItemType.Area"><ChartSeriesLegendItemMarkersBackground="#00ff00"></ChartSeriesLegendItemMarkers></ChartSeriesLegendItem><ChartSeriesLabelsVisible="true"Font="30px Sans-serif" /></ChartSeries></ChartSeriesItems><ChartCategoryAxes><ChartCategoryAxisCategories="@xAxisItems"></ChartCategoryAxis></ChartCategoryAxes><ChartTitleText="Quarterly revenue"></ChartTitle><ChartLegendPosition="ChartLegendPosition.Right"Visible="true"><ChartLegendTitleText="Revenue per product"Background="lightblue"Color="black"Font="15px Sans-serif"></ChartLegendTitle><ChartLegendItem><ChartLegendItemMarkersType="@ChartSeriesMarkersType.Cross"Background="#00ff00"></ChartLegendItemMarkers></ChartLegendItem><ChartLegendLabelsFont="15px Sans-serif"></ChartLegendLabels></ChartLegend></TelerikChart>
@code {
public List<object> series1Data = new List<object>() { 10, 2, 5, 6 };
public List<object> series2Data = new List<object>() { 5, 8, 2, 7 };
public string[] xAxisItems = new string[] { "Q1", "Q2", "Q3", "Q4" };
}