Chart.js legend position error

7.8k views Asked by At

I try to move the legend of a pie chart(created with Chart.js 2.0) to left or right, but I always get an error. The bottom and top option works.

var myChart = new Chart(ctx, {
        type: 'pie',
        data: {
            labels: optionLabels,
            datasets: [{
                label: '# of Resources',
                data: optionData,
                backgroundColor: optionColor,
                borderColor: "white",
                borderWidth: 1,

            }]
        },
        options: {
            legend: {
                position: 'left'
            }
        }
    });

enter image description here

Is there a library bug or something similar?

1

There are 1 answers

0
ɢʀᴜɴᴛ On BEST ANSWER

Seems like you are using an old version of ChartJS (which might have this bug).

Make sure you use the latest version of ChartJS, which is 2.7.0 at-the-moment.

see a working example.