generate.php将从mysql中以json
格式提取数据。
然后graph.php会通过ajax
请求generate.php获取json
数据。
我如何使用这个json
数据来提供dygraph
数据,
示例 dygraph 代码。
g3 = new Dygraph(
document.getElementById("graphdiv3"),
//"temperatures.csv",
[ //this part i need to change with ajax request data
[1,10,100],
[2,20,80],
[3,50,60],
[4,70,80]
],
//jsonStr,
//data;
{
rollPeriod: 7,
showRoller: true
}
);
最佳答案
您可以使用 updateOptions
的 file
选项来更改图表中的数据,例如:
$.get('/path/to/data', function(data) {
g.updateOptions({file: data});
});
请参阅dynamic update演示以获取灵感。
关于javascript - dygraph从ajax检索数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29602667/