我正在使用 jQuery 的 ajax 调用从 Dojo 工具包中创建一个图表,基于他们对下拉菜单的选择。问题是它没有替换图表,而是将其向下推并显示其上方的下一个图表。如果我用文本切换图表,它将正确替换文本。
$('#listID').on('change',function()
{
var input = $(this).attr("value");
$.post("helper.php", { input: input, username: username }, function(data){
$('#chart').html(data.chart);
}, "json");
});
<div id="chart"></div>
<div id="chartOne" style="width: 400px; height: 240px; "></div>
正在插入的图表:
<script>
require(["dojox/charting/Chart", "dojox/charting/axis2d/Default", "dojox/charting/plot2d/StackedAreas", "dojox/charting/themes/Wetland" , "dojo/ready"],
function(Chart, Default, StackedAreas, Wetland, ready){
ready(function(){
var c = new Chart("chartOne");
c.addPlot("default", {type: StackedAreas, tension:3})
.addAxis("x", {fixLower: "major", fixUpper: "major"})
.addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", min: 0})
.setTheme(Wetland)
.addSeries("Series A", [1, 2, 0.5, 1.5, 1, 2.8, 0.4])
.addSeries("Series B", [2.6, 1.8, 2, 1, 1.4, 0.7, 2])
.addSeries("Series C", [6.3, 1.8, 3, 0.5, 4.4, 2.7, 2])
.render();
});
});
</script>