Chartjs-Chart.js and Firebase Ionic App Angular 4

0👍

May be you are trying to assign labels before you actually get it from firebase ?

I was using dynamic labels for chart js and was simply passing data as function argument and there shouldn’t be problem for you as well

Below is glimpse of my code

function bar_graph_instance(element, answers, answers_count){
  Chart.defaults.global.elements.responsive = false;
  var ctx = document.getElementById(element);
  ctx.height = 400;
  return new Chart(ctx, {
        type: 'horizontalBar',
        data: {
          labels: answers,
          datasets: [
            {
              label: "Total Answers",
              backgroundColor: "rgba(64,202,100, 0.6)",
              data: answers_count
            }
          ]
        },

Leave a comment