0👍
try:
new Chart(canvas, {
type: 'bar',
data: {
labels: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
// chartData.datasets is an array
datasets: chartData.datasets,
},
0👍
Juan’s answer will do what you want. If, for some reason, you only want 0 to 23, you can pass chartData.datasets.slice(0, 24)
instead of chartData.datasets
.
EDIT
let data = [];
chartData.datasets.forEach(a => data = data.concat(a));
And pass data
instead.
This will concatenate every entry in chartData.datasets
- Chartjs-I want to use an object to help create a chart with Chartjs
- Chartjs-How to build dynamic charts with Chart.js
Source:stackexchange.com