I'd like to customize a legend for line data so that the legend graphic is a line (styled like the actually data line) rather than a box.
As far as I can tell from the source, the graphic can be a point or a box, and the height of the box is fixed to the font size. The 'generateLabels' option does not seem to allow for extending around these contraints.
Version 2.2.1.
Thanks for any help.
Most charts use some kind of a legend to help readers understand the charted data. Whenever you create a chart in Excel, a legend for the chart is automatically generated at the same time. A chart can be missing a legend if it has been manually removed from the chart, but you can retrieve the missing legend.
To make this behave the same as standard Chart. js charts, the function onLegendClicked is invoked when a mouse click occurs on a legend label. This function toggles the hidden state of individual datasets and changes label text style between normal and strike-through.
Plugins are the most efficient way to customize or change the default behavior of a chart. They have been introduced at version 2.1. 0 (global plugins only) and extended at version 2.5. 0 (per chart plugins and options).
Legends are a small visual representation of the chart's data series to understand each without confusion. Legends are directly linked to the chart data range and change accordingly. In simple terms, if the data includes many colored visuals, legends show what each visual label means.
You can make line legend by changing width of legend box (for example 2px), it will be vertical line but it's looks nice too
plugins: {
legend: {
display: true,
labels: {
boxWidth: 2
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With