legend converting rectangle box to square - boxWidth not working
With react-chartjs-2, creating Bar Graph as below. I am trying to make the legends in square shape rather than default rectangle.
I applied boxWidth: 10 as below but it doesn't work, Is there any other possible alternatives to generate a square legend
const sample_data = {
labels: ['Item1', 'Item2'],
datasets: [
{
data: [10, 10, 50],
borderWidth: 1,
backgroundColor: 'yellow',
},
{ data: [20, 20, 20],
borderWidth: 1,
backgroundColor: 'green'
},
],
};
const sample_options = {
responsive: true,
legend: {
boxWidth: 10, // Also 0 doesn't make any change
},
...
};
<Bar data={sample_data} options={sample_options} />;
Source: https://www.chartjs.org/docs/latest/configuration/legend.html#legend-label-configuration boxWidth - Width of coloured box.
as stated in the documentation it falls under the labels key in the legend object
example: https://jsfiddle.net/Leelenaleee/yoh5su6t/
as stated in the documentation it falls under the
labelskey in thelegendobjectexample: https://jsfiddle.net/Leelenaleee/yoh5su6t/
Thanks @LeeLenaleee for noticing the gap.