Open SaraNaifar opened 6 years ago
@SaraNaifar I apologize for the delay.
Why are you using setState
to update the dataProvider
and then afterwards pushing into the dataProvider
? You should make all your changes first and then call setState
.
Similarly, you're calling this.setState({ dataProvider: this.generateData() });
and then afterwards calling this.generateData();
again. You only need to call it once.
Also, I do not understand what this code is doing:
for (var i = 0; i < 100; ++i) {
var firstDate = new Date();
var date = new Date(firstDate.getTime());
date.setDate(i);
//console.log(this.state.dataProvider)
this.state.dataProvider.push({
date: this.state.dataProvider.date,
value: this.state.dataProvider.count
});
}
this.state.dataProvider
is an array, so it doesn't have a date
or count
property.
I am trying to make an API request (GET) then the received data should be appended on the graph as a statistatics , this is my code when i run it i got nothing on the graph.