这是我的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(" ");输入一次空,然后再一次绘图.
不过感觉方法不够好,大家有什么好的方法吗?