I have a script that uses ChartJS for plotting the performance of a QR code in term of scans and unique users. The chart only plots interactions with the QR, skipping those days when there is no interaction with it.
I would like to include those days plotting 0 as value for that day in case no interaction happens. Any suggestion on how to achieve this?
this is the code:
/* Display chart */
new Chart(pageviews_chart, {
type: 'line',
data: {
labels: <?= $data->pageviews_chart['labels'] ?>,
datasets: [
{
label: <?= json_encode(l('link_statistics.pageviews')) ?>,
data: <?= $data->pageviews_chart['pageviews'] ?? '[]' ?>,
backgroundColor: pageviews_gradient,
borderColor: pageviews_color,
fill: true
},
{
label: <?= json_encode(l('link_statistics.visitors')) ?>,
data: <?= $data->pageviews_chart['visitors'] ?? '[]' ?>,
backgroundColor: visitors_gradient,
borderColor: visitors_color,
fill: true
}
]
},
options: chart_options
});
thank you!
Just pass 0 as the value. We cannot help with your back-end, without more information.