在我的下面的代码中,数据已更新,但图表未重新绘制在同一位置。我的代码有什么问题?
(如果你愿意,可以在firebug中获取更多信息 - 当更改las下拉列表时更新json - 只有类别设计者才有数据)
<script type="text/javascript">
dojo.query(".estatistica").onchange(function() {
dojo.xhrPost({
url: "drop2.php",
handleAs: "json",
postData: "data=" + $(this).val(),
preventCache: true,
load: function(json) {
$msgs = [];
for (var i = 1; i < 10; i++) {
$msgs.push(parseFloat(json[i]["valor" + i]));
}
var chart1 = new dojox.charting.Chart2D('chart1');
chart1.addPlot("default", {
type: "StackedAreas",
markers: true,
tension: "S",
lines: true,
areas: true,
labelOffset: 0,
});
chart1.addAxis('x');
chart1.addAxis('y', {
vertical: true,
max: 80000
});
chart1.addSeries('January Visits', $msgs, {
stroke: 'red',
fill: 'pink'
});
chart1.updateSeries("January Visits", $msgs);
chart1.render();
var stackedAreaLegend = new dojox.charting.widget.SelectableLegend({
chart: chart1
}, "legend1");
stackedAreaLegend.refresh();
}
});
});
</script>
感谢
答案 0 :(得分:0)
首先,渲染图表,然后进行任何更新。只需切换这两行,如图所示:
chart1.render();
chart1.updateSeries("January Visits", $msgs);