我是flot的新手,但成功地快速设置了我的时间图。以下是我的基于时间的绘图:
$.plot("#placeholder", [d],
{
xaxis: {
mode: "time",
minTickSize: [1, "month"],
min: (new Date(2008, 05, 20)).getTime(),
max: (new Date(2014, 05, 27)).getTime()
}
});
当用户点击按钮时,我希望更改图表以仅显示[d]的一部分 - 例如,如果[d]包含2013年和2014年的数据,则只想显示2013年。在flot示例中有这样的例子(http://www.flotcharts.org/flot/examples/axes-time/index.html)。因此,在我的按钮单击中,我基本上按照示例所示做了一些事情,类似于这样:
$("#myBtn").click(function () {
$.plot("#placeholder", [d], {
xaxis: {
mode: "time",
min: (new Date(2013, 06, 30)).getTime(),
max: (new Date(2013, 12, 30)).getTime()
}
});
});
除了2013年的最小值和最大值之外,Y轴刻度没有根据其重新生成,否则一切正常。我查找了解决方案并尝试了这段代码:
$("#myBtn").click(function () {
plot.getOptions().yaxes[0].min = minVal;
plot.getOptions().yaxes[0].max = maxVal;
plot.setupGrid(); //only necessary if your new data will change the axes or grid
plot.draw();
});
但是当我运行这个程序时,Y轴没有发生变化。 有人能帮助我弄清楚我错在哪里吗?