如果有人遇到这个问题,请告诉我:
我使用jqPlot在页面图上显示
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$.jqplot.config.enablePlugins = true;
var chLines = [[['09/30/2010 00:00:00',24.13],['12/31/2010 00:00:00',28.26],['03/31/2011 00:00:00',24.00],['06/30/2011 00:00:00',25.35],['09/30/2011 00:00:00',26.26],['12/31/2011 00:00:00',29.71]]];
var chSeries = [{ color: '#436277', label: 'label' }];
var mnth;
var quarter;
$.jqplot.DateTickFormatter = function(format, val) {
if (!format) {
format = '%Y/%m/%d';
}
if(format == '%Q') {
mnth = $.jsDate.strftime(val, '%#m');
quarter = parseInt((mnth-1) / 3) + 1;
return $.jsDate.strftime(val, '%Y') + 'Q' + quarter;
}
return $.jsDate.strftime(val, format);
};
//$.jqplot.DateAxisRenderer.tickInterval = 86400000*32*3;
var plot = $.jqplot('content-chart', chLines,
{
//animate: !$.jqplot.use_excanvas, // Only animate if we're not using excanvas (not in IE 7 or IE 8)..
axes: {
xaxis: {
tickInterval: 86400000*32*3,
renderer: $.jqplot.DateAxisRenderer,
borderColor: 'black',
borderWidth: 0.5,
tickOptions: {
showGridline: false,
//formatString: '%b %Y',
formatString: '%Q',
textColor: 'black',
fontSize: '11px',
}
},
yaxis: {
min: 0,
tickOptions: {
formatString: '%.2f',
textColor: 'black',
fontSize: '11px'
}
}
},
highlighter: {
show: true,
sizeAdjust: 7.5
},
seriesDefaults: {
lineWidth: 3
},
series: chSeries,
legend: {
show: true,
location: 'sw',//compass direction, nw, n, ne, e, se, s, sw, w.
xoffset: 5,
yoffset: 5
//placement: 'outside'
},
grid:{
background: 'white',
borderColor: 'white',
shadow: false,
gridLineColor: '#999999'
}
});
$(window).bind('resize', function(event, ui) {
plot.replot( { resetAxes: true } );
});
});
</script>我看到在X轴上的标签是重复的

但是,当this.tickInterval对象在jqplot.dateAxisRenderer.js in 中调整大小时,函数变为null。此外,我还试图更改函数createTicks中的代码,如下所示
this.tickInterval = 86400000 * 32 * 3;
var tickInterval = this.tickInterval;但不幸的是,当窗口调整大小时,滴答标签开始相互碰撞。
发布于 2012-04-19 17:02:38
要解决问题,首先必须为日期轴(即轴X)设置'min‘和'max’日期。显然,只有当'min‘和'max’值被设置时,渲染器才会使用'tickInterval‘的值。这类问题实际上已经在堆栈上解决了--请看这个答案。
因此,使用此建议,您需要设置以下参数:
tickInterval: "3 months",
min: chLines[0][0][0],
max: chLines[0][0][chLines[0].length-1]对于调整大小的位,您需要使用以下内容:
$(window).bind('resize', function(event, ui) {
if (plot) {
plot.replot();
}
});下面是为您的代码制作的工作代码示例。
编辑:在修改了示例一段时间之后,我发现仍然存在一些问题,认为是不可见的,因为格式正在覆盖它。从表面上看,min、max和tickInterval的设置是不够的,因为每个滴答显示出第30天,而且有时应该是31,所以这个值仍然不是每3个月一次。
在本例中,我想出了唯一的解决办法就是自己决定。不再需要min、max和tickInterval。
发布于 2013-05-01 11:33:02
对于我来说,更新jqplot解决了滴答标签相互碰撞的问题,为了解决刻度间隔不起作用的问题,请参阅这里接受的答案:
https://stackoverflow.com/questions/10191122
复制相似问题