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

Categories

0 votes
2.1k 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 answer this question.

Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...