New to Kendo UI for jQuery? Start a free 30-day trial

Legend.labels

configuration

Configures the legend labels.

<div id="stock-chart"></div>
<script>
$("#stock-chart").kendoStockChart({
    legend: {
        labels: {
            color: "red",
            font: "16px Arial"
        }
    },
    series: [{
        type: "line",
        data: [
            { date: new Date(2023, 0, 1), value: 10 },
            { date: new Date(2023, 0, 2), value: 25 },
            { date: new Date(2023, 0, 3), value: 15 }             
        ],
    }]
});
</script>

The color of the labels. Any valid CSS color string will work here, including hex and rgb.

Default: "black"

<div id="stock-chart"></div>
<script>
$("#stock-chart").kendoStockChart({
    legend: {
        labels: {
            color: "blue"
        }
    },
    series: [{
        type: "line",
        data: [
            { date: new Date(2023, 0, 1), value: 10 },
            { date: new Date(2023, 0, 2), value: 25 },
            { date: new Date(2023, 0, 3), value: 15 }             
        ],
    }]
});
</script>

The font style of the labels.

Default: "12px Arial,Helvetica,sans-serif"

<div id="stock-chart"></div>
<script>
$("#stock-chart").kendoStockChart({
    legend: {
        labels: {
            font: "14px Verdana"
        }
    },
    series: [{
        type: "line",
        data: [
            { date: new Date(2023, 0, 1), value: 10 },
            { date: new Date(2023, 0, 2), value: 25 },
            { date: new Date(2023, 0, 3), value: 15 }             
        ],
    }]
});
</script>

The template which renders the labels.

The fields which can be used in the template are:

  • text - the text the legend item.
  • series - the data series.
  • value - the point value. (only for donut and pie charts)
  • percentage - the point value represented as a percentage value. Available only for 100% stacked charts.
  • dataItem - the original data item used to construct the point.
<div id="stock-chart"></div>
<script>
$("#stock-chart").kendoStockChart({
    legend: {
        labels: {
            template: (data) => `Series: ${data.text}`
        }
    },
    series: [{
        name: "Sales",
        type: "line",
        data: [
            { date: new Date(2023, 0, 1), value: 10 },
            { date: new Date(2023, 0, 2), value: 25 },
            { date: new Date(2023, 0, 3), value: 15 }             
        ],
    }]
});
</script>