Php 同一图表中的混合图表数据源
我是DOJO的新手,第一次在这里发帖。 我在同一张图表上创建多条直线时遇到问题 我做了一个简单的测试来模拟数据,它是有效的Php 同一图表中的混合图表数据源,php,javascript,charts,dojo,dojox.charting,Php,Javascript,Charts,Dojo,Dojox.charting,我是DOJO的新手,第一次在这里发帖。 我在同一张图表上创建多条直线时遇到问题 我做了一个简单的测试来模拟数据,它是有效的 dojo.require("dojox.charting.Chart2D"); makeCharts = function(){ //crée un nouvel objet graphique var chart1 = new dojox.charting.Chart2D("simplechart"); chart1.addPlot("l
dojo.require("dojox.charting.Chart2D");
makeCharts = function(){
//crée un nouvel objet graphique
var chart1 = new dojox.charting.Chart2D("simplechart");
chart1.addPlot("line", {type: "Lines"});
chart1.addPlot("space", {type: "Areas", hAxis: "space x", vAxis: "space y"});
chart1.addPlot("histo", {type: "Bars", gap: 6, hAxis: "histo x", vAxis: "histo y"});
chart1.addAxis("histo x", {
labels: [{value: 1, text: "Jan"}, {value: 2, text: "Feb"},
{value: 3, text: "Mar"}, {value: 4, text: "Apr"},
{value: 5, text: "May"}, {value: 6, text: "Jun"},
{value: 7, text: "Jul"}, {value: 8, text: "Aug"},
{value: 9, text: "Sep"}, {value: 10, text: "Oct"},
{value: 11, text: "Nov"}, {value: 12, text: "Dec"}]
});
chart1.addAxis("histo y", {vertical: true,
max: 10,
stroke: "green",
fontColor: "black",
majorTick: {color: "red", length: 6},
minorTick: {stroke: "black", length: 3}});
chart1.addSeries("Series 1", [1, 2, 2, 3, 4, 5, 5, 7],
{plot:"line", stroke: {color:"red"}});
chart1.addSeries("Series 2", [1, 2, 4, 2, 1, 6, 4, 5],
{plot: "space", stroke: {color:"blue"}, fill: "lightblue"});
chart1.addSeries("Series 3", [1, 2, 2, 3, 4, 5, 5, 7],
{plot: "histo", stroke: {color:"green"}, fill: "lightgreen"});
chart1.render();
我创建了另一个php文件,将数据从Mysql转换为JSON。
现在我想把我的源代码的URL放到DojoAddSeries。
将有多个数据源,不同的文件和数据源
我不知道在代码中把我的URL放在哪里
谢谢你的帮助
谢谢你的回复 我尝试过这个,但“系列1”不起作用:
dojo.require("dojox.charting.Chart2D");
dojo.require("dojo.data.ItemFileWriteStore");
makeCharts = function(){
test_store = new dojo.data.ItemFileWriteStore({url: 'data_chart.php'});
var chart1 = new dojox.charting.Chart2D("simplechart");
chart1.addPlot("line", {type: "Lines"});
chart1.addPlot("space", {type: "Areas", hAxis: "space x", vAxis: "space y"});
chart1.addPlot("histo", {type: "Bars", gap: 6, hAxis: "histo x", vAxis: "histo"});
chart1.addAxis("histo x", {
labels: [{value: 1, text: "Jan"}, {value: 2, text: "Feb"},
{value: 3, text: "Mar"}, {value: 4, text: "Apr"},
{value: 5, text: "May"}, {value: 6, text: "Jun"},
{value: 7, text: "Jul"}, {value: 8, text: "Aug"},
{value: 9, text: "Sep"}, {value: 10, text: "Oct"},
{value: 11, text: "Nov"}, {value: 12, text: "Dec"}]});
chart1.addAxis("histo y", {vertical: true, max: 10, stroke: "green", fontColor:"black", majorTick: {color: "red", length: 6}, minorTick: {stroke: "black", length: 3}});
chart1.addSeries("Series 1", {data :test_store,plot:"line", stroke: {color:"red"}});
{color:"black"}});
chart1.addSeries("Series 2", [1, 2, 4, 2, 1, 6, 4, 5],
{plot: "space", stroke: {color:"blue"}, fill: "lightblue"});
chart1.addSeries("Series 3", [1, 2, 2, 3, 4, 5, 5, 7],
{plot: "histo", stroke: {color:"green"}, fill: "lightgreen"});
chart1.render();
My data_chart.php是一个测试:
我迷路了,我不知道如何解决这个问题。我会使用。
您必须使用数据存储来传递数据。
见和
首先使用一个。如果这样做很好,可以使用复合数据存储,它包装其他数据存储以从多个源获取数据(您可能需要自己创建该类)
--编辑--
使用带有itemfilereadstore的datachart的示例:
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js.uncompressed.js"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
dojo.require("dojox.charting.DataChart");
dojo.require("dojo.data.ItemFileWriteStore");
dojo.addOnLoad(function() {
var store = new dojo.data.ItemFileWriteStore({
url: "stock.json"
});
chart = new dojox.charting.DataChart("chartDiv" ,{});
chart.setStore(store, {symbol:"*"}, "historicPrice"); // <-- single value property
});
//]]>
</script>
</head>
<body>
<div id="chartDiv" style="width: 600px; height: 400px;"></div>
</body>
</html>
要使用多个存储,您需要创建一个对多个存储进行分组的compositeStore。不幸的是,它似乎不存在,所以您必须自己实现该类。数据系列应该可以解决您的问题。注意,DataSeries是在Dojo1.5.0中添加的
dojo.require("dojox.charting.DataSeries");
chart1.addSeries("Series 1", new dojox.charting.DataSeries(
test_store, {query: {symbol: "*"}}, "price"));
PS我认为您应该将后续问题作为评论而不是回答。谢谢davyM,我将把所有数组数据推送到同一个json url上!它就像一个符咒
dojo.require("dojox.charting.DataSeries");
chart1.addSeries("Series 1", new dojox.charting.DataSeries(
test_store, {query: {symbol: "*"}}, "price"));