Chartjs-ChartJS – Returning labels and data from server on different calls

0👍

The problem with your drawSpeedChart method is that the properties which you are using with this does not exist on your class. I’ve made them local variables. And you don’t need the third then because you already have all the information to call createChart method.

drawSpeedChart() {
    let avgData;
    this.getAvgData()
        .then((avgDataResponse) => {
            console.log(avgDataResponse);                
            avgData = avgDataResponse;
            return this.getCarNames();
        }).then((carNames) => {
            console.log(carNames)
            this.createChart(carNames, avgData)
        }).catch((err) => {
            console.log('Error', err);
        })
}

Checkout this fiddle to see working example

Leave a comment