我是 DOJO 的新手,第一次在这里发帖。我在同一个图表上创建多条线时遇到问题。
我做了一个简单的测试来模拟数据并且它有效
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 放到 dojo AddSeries。将有几个来源,不同的文件数据来源。
我不知道将我的 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();
我的 data_chart.php 是一个测试:<?php echo"[1, 2, 2, 3, 4, 5, 5, 7]"; ?>
我迷路了,我不知道如何解决这个问题。