chartjs / Chart.js

Simple HTML5 Charts using the <canvas> tag
https://www.chartjs.org/
MIT License
63.92k stars 11.89k forks source link

Bar chart with indexAxis: 'y' requires data.labels whereas 'x' doesn't. #11688

Closed ItsRkaj closed 2 months ago

ItsRkaj commented 4 months ago

As reported in #11684, indexAxis y requires data.labels whereas indexAxis x does not. According to the same issue y should be treated as x in this case. Where this PR solves that problem.

This is done by checking if data.labels.lenght is 0 and indexAxis set to y then we transform the data.dataset.data to set the required data.labels and data.dataset.data in order to work as expected.

Closes #11684

LeeLenaleee commented 4 months ago

Hi I appreciate the PR with a fix for the problem. I have made a alternative PR to fix the issue since I don't think putting the data in the labels array is the correct fix.

The underlying issue is in my eyes that the data array was always build staticly instead of dynamically.

LeeLenaleee commented 2 months ago

Fixed in #11690