0👍
Forget what I told you in my first comment (about updating the run()
function). I just hadn’t catched what you were precisely trying to do.
So you have an initial set of data in you PHP vars, that you feed to your chart. You want to update this set of data (which I guess you should do in your AJAX success
callback). This answer and the link it provides should point you in the right direction.
In your success
callback, you can add something like that:
// Update points in the datasets
// index in datasets[] can be 0, 1 or 2 (three datasets for BarChart)
BarChart2.datasets[0].points[0].value = data[0]['cpfsEnviados'];
BarChart2.datasets[1].points[0].value = data[0]['propostasFinalizadas'];
BarChart2.datasets[2].points[0].value = data[0]['propostasAprovadas'];
BarChart2.update();
// index in datasets[] can be 0 or 1 (two datasets for LineChar)
LineChart.datasets[0].points[0].value = data[0]['propostasFinalizadas'];
LineChart.datasets[1].points[0].value = data[0]['propostasAprovadas'];
LineChart.update();
Let me know if it is what you were looking for. Also, simple remark, in many JavaScript coding conventions you would avoid having the first letter of a variable as a capital. Hence maybe you should rename your charts variables to barChart2
and lineChart
.
Source:stackexchange.com