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

176
Views
Chart JS annotation issues

I am trying to load annotation the dynamic chart that I create after receiving data from the database and I have tried all possible options but somehow the chart loads but no the annotations.

chart.js version = v2.9.4 chart-plugin-annotation.min.js version = 0.5.7

Function in JS that runs when data is receiving from db:

function DrawChart(timeLabelList, unitsProducedList, goalList){
    if(draw_the_chart != null) draw_the_chart.destroy();

    Chart.defaults.global.defaultFontColor = 'white';
    var ctx = document.getElementById('draw_the_chart').getContext("2d");

    draw_the_chart = new Chart(ctx, {
        type: 'line',
        //plugins: [ChartAnnotation],
        data: {
            labels: timeLabelList,
            datasets: [
                {
                    label: 'Goal',
                    yAxisID: 'A',
                    data: goalList,
                    //backgroundColor: chartColumnColorBlueSolid,
                    borderColor: chartColumnColorGreenSolid,
                    borderWidth: 2,
                    pointStyle: 'star'
                }]
        },
        options: {
            annotation: {
                annotations: [
                  {
                    id: "a-line-1",
                    type: "line",
                    mode: "vertical",
                    scaleID: "y-axis-0",
                    value: "1",
                    borderColor: "red",
                    borderWidth: 2
                  }
                ]
            },
            legend: {
                position: 'bottom',
                display: true,
            },
            elements: {
                line: {
                    tension: 0
                }
            },
            scales: {
                xAxes: [{
                    stacked: true,
                    type: 'time',
                    time: {
                        unit: 'hour'
                    },
                }],
                yAxes: [{
                    stacked: false,
                    id: 'A',
                    type: 'linear',
                    position: 'right',
                }]
            },
        }
    });
}

I tried all possible ways to register and also different ways to used the plugin but had no luck plotting it. I even used latest CDN versions but had no luck.

Can anyone help with it.

Thanks!

about 4 years ago · Juan Pablo Isaza
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!