2015-10-19 72 views
0

我正在使用AmCharts创建折线图。所以我试图从我的mysql数据库分配数据到图表,我使用它。在AmCharts中显示来自mysql的数据

AmCharts.makeChart("chartdiv", { 
    "type": "serial", 
    "dataLoader": { 
     "url": "data.php", 
     "format": "json" 
    }, 
    // we'll skip the rest of the config for now // 
}); 

data.php文件有PHP脚本连接到MySQL服务器,加载数据并以JSON格式输出数据。

但我不能(使用后ID)

+0

请正确格式化代码。缺少引号.. –

+0

AmCharts.makeChart(“chartdiv”,{ “type”:“serial”, “dataLoader”:{ “url”:“data.php”, “format”:“json” }, //我们现在跳过配置的其余部分 // .. }); – sami

回答

0

我会改变我的选择子句中的SQL传递变量(ID)的data.php文件,以查询特定的岗位,做:

WHERE id = 1 

我认为应该这样做。但也有可能是JSON做得太的方式,你也许可以通过一个ID的网址:

AmCharts.makeChart("chartdiv", { 
"type": "serial", 
"dataLoader": { 
"url": "data.php?ID=1", 
    "format": "json" 
}, 
// we'll skip the rest of the config for now 
// .. 
}); 

但是请向PHP或JSON大师。

相关问题