const labels = ['s', 'a', 'd']
const data = {
labels: labels,
datasets: [{
label: 'Weekly Sales',
data: [
{products: { sales: [0, 5], id: 1 } },
{products: { sales: [5, 10], id: 2 } },
{products: { sales: [10, 15], id: 3 } },
],
backgroundColor: [
'rgba(255, 26, 104, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
],
borderColor: [
'rgba(255, 26, 104, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
],
borderWidth: 1
}]
};
// config
const config = {
type: 'bar',
data,
options: {
parsing: {
yAxisKey: 'products.sales',
},
indexAxis: 'y',
scales: {
y: {
beginAtZero: true
}
}
}
};
I'm trying to create a horizontal barchart using Chartjs I'm kind of in trouble putting data to the chart. enter image description here The output should be like this one in the image.