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

278
Views
how to pass data and labels in $scope variable in angular-chart.js?

I'm using angular-chart.js to show charts. I want to show tooltip in stacked bar charts with labels with each bar.

Here I'm passing data in chart-option but it's not working.

Is there anyway I can pass data with $scope variable to html markup values?

$scope.optionsData = {
            type: "HorizontalBar",
            responsive: true, // set to false to remove responsiveness. Default responsive value is true.
            maintainAspectRatio: false,
            legend: { display: false },

            data: {
                datasets: [{
                   data: [2000, 4000, 6000, 8000, 10000, 12000, 14000],
                   labels: ["Label 11", "Label 2", "Label 3", "Label 4", "Label 5", "Label 6", "Label 7"],
                   backgroundColor: ["#73BFB8", "#73BFB8", "#73BFB8", "#73BFB8", "#73BFB8", "#73BFB8", "#73BFB8"], 
                }, {
                  data: [2200, 400, 600, 800, 1000, 1200, 1400],
                  labels: ["Label 21", "Label 22", "Label 3", "Label 4", "Label 5", "Label 6", "Label 7"],
                  backgroundColor: ["#47cf73", "#47cf73", "#47cf73", "#47cf73", "#47cf73", "#47cf73", "#47cf73"]
                }]
             },
            tooltips:{
                callbacks: {
                    label: function(tooltipItem, data) {
                        console.log(data);
                        var datasetData = data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
                        var datasetLabel = data.datasets[tooltipItem.datasetIndex].labels[tooltipItem.index];
                        return datasetLabel +':'+ datasetData;
                    },
                },
            },
            scales: {
                xAxes:  [{ 
                    id: 'x-axis-1',
                    display: true,
                    scaleOverride: true,
                    scaleStartValue: 0,
                    staked:true,
                    //To FIX y-axis label getting truncated
                    ticks:{
                        userCallback: function(value, index, values) {
                            return  formatNumber(value);
                        },
                        fontSize: 12
                    }  
                    
                 } ],
                yAxes: [{
                    id: 'y-axis-1',
                    display: true,
                    scaleOverride: true,
                    stacked: true,
                    position: 'left'
                }]
            }
        }
<canvas id="mixed-chart" 
  class="chart chart-horizontal-bar"
  chart-data="top25skuData" 
  chart-colors="colours"
  chart-labels="top25skuLabels"
  chart-options="optionsData"
 ></canvas>

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!