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

250
Views
how to draw Line chart using chart.js and datalabels should be shown

In the above image I will not able to show the datalabels on my dots where tooltips are shown. Instead of tooltips I want only values shown there and my code is in this. I will not get any idea for how to show datalabels on my line chart dots.

This is my script by which I make the line chart accordingly to the database values.

    $('canvas.LineChart').each(function(cnvindx, cnvobj) {
        var proc_id = $(cnvobj).data('proc_id');
        var dcharry         = [];
        var labelChartArr   = [];
        var ctxs = cnvobj;
        var dataChart = {
            datasets: [],
            labels: []
        };

        var optionsChart = {
            title: {
                display: true,
                text: "Offered Call's Hourly",
                position: 'top'
            },
            legend: {
                display: true,
                position: 'top',
                align: 'start',
            },
            tooltips: {
                enabled: false
            },
            plugins: {
                datalabels: {
                    anchor: 'end',
                    align: 'end',
                    labels: {
                        value: {
                            color: 'blue'
                        }
                    }
                }
            }
        };

        var myLineChart = new Chart(ctxs, {
            type: 'line',
            data: dataChart,
            options: optionsChart
        });

        myLineChart.data.datasets[0]    = { };
        myLineChart.data.labels     = [];
        myLineChart.update();

        if(msg.myLineChart != undefined) {
            myLineChart.data.datasets[0].data = [];

            myLineChart.data.datasets[0].label = ["Offered Call's"];
            myLineChart.data.datasets[0].fill = [false];
            myLineChart.data.datasets[0].borderColor = [Offered_Call_COLOR];

            myLineChart.data.datasets[0].backgroundColor = [];

            $.each(msg.multiplebarchart, function(indx, hourData) {
                //setting line data 
                myLineChart.data.datasets[0].data.push(
                    hourData['Offered_Call']);

                //setting X axis label
                myLineChart.data.labels.push(hourData['HOUR1']);

                //setting background color      
                myLineChart.data.datasets[0].backgroundColor.push(
                    Offered_Call_COLOR);
            });

            myLineChart.update();
    
            myLineChart.render({
                duration: 500,
                lazy: false,
            });
        }
    });
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Since your config aint working I assume you are using chart.js V3 in which case you put the options in the wrong spot, you are placing them in the V2 spots.

If you put it like this it will work:

options: {
  plugins: {
    tooltip: {
      enabled: false
    }
  }
}

For all changes between V2 and V3 you can read the migration guide

about 4 years ago · Santiago Trujillo 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!