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'
}
}
});
Is there a library bug or something similar?
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'
}
}
});
Is there a library bug or something similar?
Share Improve this question asked Sep 11, 2017 at 7:01 ChrisChris 6,3216 gold badges40 silver badges57 bronze badges 4-
are you sure the error is occurring due to
position: 'left'
? coz it doesn't seem like.. – ɢʀᴜɴᴛ Commented Sep 11, 2017 at 8:44 - @ɢʀᴜɴᴛ I suspect that it occurs on position:left and right also because it does not occur on position: 'top' and position: 'bottom'. The last two works as expected. – Chris Commented Sep 11, 2017 at 8:50
- @ɢʀᴜɴᴛ The version was 2.2.0, I updated it to 2.7.0 and it works, you can submit your answer. Thanks! – Chris Commented Sep 11, 2017 at 9:06
- @Chris How to update version 2.2.0 to 2.7.0? – Raj G Commented Aug 23, 2023 at 10:06
1 Answer
Reset to default 5Seems 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.