+ 5
The x-axis labels are intended for different values within one dataset, the legend labels are intended for different datasets. So there's an easy way to do your chart using x-axis labels and there is an easy way to do it using a legend. I found no easy way of using x-axis labels and legend labels for the same thing. You could probably do it by setting up the legend manually. But I'm not sure it is worth the effort since you'll only end up with redundant information. (The third graph in my code is an illustration of how to use x-axis labels and legend labels for different information.) https://code.sololearn.com/WoAn3YUE90Qd/?ref=app
31st May 2022, 8:54 PM
Simon Sauter
Simon Sauter - avatar
0
Why are you treating the values as separate datasets?
31st May 2022, 5:08 PM
Simon Sauter
Simon Sauter - avatar
0
I think your datasets you should be ... data: { labels: [”Italy”, “USA”], datasets: [{ label: “Countries”, data : [20, 30], backgroundColor: [”red”, “blue”] ]} }
31st May 2022, 6:08 PM
Faisal Issaka
Faisal Issaka - avatar
0
data: { labels: ["Italy", "USA"], datasets: [{data: [55, 80], backgroundColor: ["red", "blue"]}] }
31st May 2022, 6:28 PM
Simon Sauter
Simon Sauter - avatar
0
If you really want the legend that's the easy way to do it. Personally I prefer the design with two x-axis labels but no legend.
31st May 2022, 9:12 PM
Simon Sauter
Simon Sauter - avatar