Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

180
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda