Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I need an array with chart values, I obtained one but after exiting from the function it became blank, here's what happens: 

    function AddvotoTec(votor) {
      class Avg {
        constructor() {}
        static average(votor) {
          var total = 0;
          var count = 0;
          jQuery.each(votor, function(index, value) {
                total += value;
                count++;
          });
          return total / count;
        }
      }
      var mvoti = Avg.average(votor);
      var mvoti = Math.round((mvoti + Number.EPSILON) * 10) / 10;
      const myJSON = JSON.stringify(mvoti);
      voti(myJSON);
    }
    
    var allvoti = [];
    function voti(Voti) {
      allvoti.push(Voti);
    }
    
  const data = {
    labels: labels,
    datasets: [{
      label: 'My First dataset',
      backgroundColor: [
        'rgb(255, 132, 0)'
      ],
      borderColor: 'rgb(255, 99, 132)',
      data: allvoti,
    }]
  };

The chart that I used is Chart.js.

thumb_up_alt 0 like thumb_down_alt 0 dislike
1.9k views
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...