Chart.js version - 3.8.0 (latest)
Hi all
Losing my mind with this at the moment. I have been able to successfully display the chart once. Since then it is failing to render and I have no idea why.
I have built an object array prior (counts lines in multiple csv files) to declaring the chart options and then passed this array in according to the examples on the chart js website.
I have output to console to ensure that the data is being loaded correctly and everything looks ok. Could someone please cast an eye over the code below and point out anything obvious?
const data = YTDTable;
var ctx1 = document.getElementById('YTD').getContext('2d');
var myChart1 = new Chart(ctx1, {
type: 'bar',
data: {
datasets: [{
data: data,
label: "Tickets to Date"
}]
},
options: {
parsing: {
xAxisKey: 'month',
yAxisKey: 'count'
}
},
});
This is the dataset output of console.log(myChart1.data) which is executed after the above codeblock:
{
"datasets": [
{
"data": [
{
"month": "January",
"count": 1629
},
{
"month": "February",
"count": 1832
},
{
"month": "April",
"count": 1626
},
{
"month": "May",
"count": 2034
},
{
"month": "March",
"count": 1802
},
{
"month": "June",
"count": 1585
}
],
"label": "Test"
}
],
"labels": []
}
I just don't understand why the above code isn't working. Any help is much appreciated
The chart output on screen: chart image - can't embed images yet...
data: [40, 47, 44, 38, 27, 31, 25], or in your casedata: [1629, 1832, 1626...]type: 'bar', data: {datasets: [{ data: [{id: 'Sales', nested: {value: 1500}}, {id: 'Purchases', nested: {value: 500}}] }] }, options: {parsing: {xAxisKey: 'id',yAxisKey: 'nested.value'} }