2
如何在縮放操作後重新設置刻度的formatString?jqplot:如何在縮放後更改軸刻度formatString
我在012xx的「xaxis」上使用了$.jqplot.DateAxisRenderer
插件,但是當我縮放時,我想根據新的最小值和最大值將其更改爲%d.%m %H:%M:%S
。
如何在縮放操作後重新設置刻度的formatString?jqplot:如何在縮放後更改軸刻度formatString
我在012xx的「xaxis」上使用了$.jqplot.DateAxisRenderer
插件,但是當我縮放時,我想根據新的最小值和最大值將其更改爲%d.%m %H:%M:%S
。
我想我有些東西給你。 Please see the sample for code details.
整個問題歸結爲覆蓋DateTickFormatter
與此代碼:
$.jqplot.DateTickFormatter = function(format, val) {
if (plot) {
var noDays = days_between(new Date(plot.axes.xaxis.max), new Date(plot.axes.xaxis.min));
console.log("days_between = " + noDays);
if (noDays < 28) format = "%d";
else if (noDays < 120) format = '%m/%d';
else format = '%Y/%m/%d';
}
return $.jsDate.strftime(val, format);
};
這將取決於可見的天數返回不同的格式。使用代碼進行遊戲,看看縮放時會發生什麼。
太棒了!謝謝 – sdespont