您的位置:首页 > 其它

关于jqplot同一个div重用,导致数据重复问题

2014-12-22 15:57 267 查看
这是我的jsp:

<div id="chart1b" class="plot" style="width:400px;height:260px;"></div>
<script type="text/javascript">
function show(){
plot2 = $.jqplot('chart1b', [s1, s2], {
series: [
{label: '总计'},
{label: '已完成'}
],
seriesDefaults:{

rendererOptions:{barPadding:10, barMargin:10},
pointLabels: {show: true, formatString: '%d'}
},
legend: {show:true, location: 'nw'},
axes:{xaxis:{renderer:$.jqplot.CategoryAxisRenderer, ticks:ticks,rendererOptions:{sortMergedLabels:true}},
yaxis:{min:0, max:20, numberTicks:6}
}
});
}
</script>


这个s1和s2分别代表总共的和已完成的,因为我有根据年,月,周查询,为了代码简介,我显示结果都是使用一个id为chart1b的div来实现,那么结果会是多次查询结果的xy轴,还有

pointLabels显示的数值重复叠加,造成显示结果错误,

解决方法我是每次调用show()方法的时候,都先调用一次$('#chart1b').html(" ");输入一次空,然后再一次绘图.

不过感觉方法不够好,大家有什么好的方法吗?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐