react-chartjs-2
react-chartjs-2 copied to clipboard
each labels contains only 1 bar of data
may i know how to generate a bar chart with each labels contains its own bar of data
eg :
data = {
labels: ["apple", "orange", "pear"],
datasets: **this is the part where i stucked**
}
i want to have 3 bars displaying : apples -> a bar (10 apples), orange -> a bar (6 oranges), pear -> a bar (4 pears)
@jacky-ew if you want to show labels without hover, you can use this lib https://www.npmjs.com/package/chartjs-plugin-datalabels
Hi @jacky-ew 👋
If I understand your problem correctly, you can just set up datasets like so:
datasets: [
{
label: 'Fruit data',
data: [10, 6, 4],
backgroundColor: 'rgba(255, 99, 132, 0.5)',
...
},
],
to achieve desired result.