using array values in chart.js data and label field

前端 未结 2 733
鱼传尺愫
鱼传尺愫 2021-01-01 02:34

I wish to pass values of an array to the data and label fields of the chart.js dataset.

Here the code from success of ajax call made to fetch json data. I fetch the

2条回答
  •  无人及你
    2021-01-01 02:45

    I think you could try to remove some brackets.

    while(count > 0){
         LabelResult[counter] = Data[counter].TIME; // here removed brackets
          counter++;
          count --;
    }    
    

    and

    data: {
        labels: LabelResult, // here removed brackets
        datasets: [{
            label: '# of Votes',
            data: DataResult, // here removed brackets
            borderWidth: 1
        }]
    },  
    

    I hope that will works.

提交回复
热议问题