Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

109
Views
Show and plot zero values on ChartJS line graph when no data

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!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Just pass 0 as the value. We cannot help with your back-end, without more information.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!