Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.2k views
in Others[杂七杂八] by (100 points)

Use an array as chart values

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.

Welcome To Ask or Share your Answers For Others

Please log in or register to reply this article.

OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...