Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chart.js legend alignment left side

CodeSandbox

How to move that legend to the left? I have tried to use options:{legend:{position: 'left'}}.

Goal: enter image description here

position: left shifts the chart to the right what is not good for me:

enter image description here

like image 954
Arthur Avatar asked Mar 26 '19 10:03

Arthur


People also ask

How do I change the legend position in a chart?

Click the chart, and then click the Chart Layout tab. To change the position of the legend, under Labels, click Legend, and then click the legend position that you want. To change the format of the legend, under Labels, click Legend, click Legend Options, and then make the format changes that you want.

How do you wrap a legend text in ChartJS?

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.

What is legend in ChartJS?

The chart legend displays data about the datasets that are appearing on the chart.

How do I change the label color in ChartJS?

With ChartJS 3, you can change the color of the labels by setting the scales. x. ticks. color and scales.


1 Answers

Your code is correct and you will be able to align the legend as following in the future:

legend: {
    position: "top",
    align: "start"
}

But the feature is currently not implemented at the current time (2019-03-30). The feature is already merged and will be released with version 2.9. You either have to wait until version 2.9 will be released or use a development release, which is not recommended as they should only be used for testing purposes.

like image 64
Thomas Dondorf Avatar answered Sep 20 '22 17:09

Thomas Dondorf