我有一个每周图表来显示3周的数据,
图表中有2个XAxis,一个显示周数,另一个显示年份,
Screen Capture of the chart
两个轴都具有相同的数据长度,但不同的刻度长度,
年份XAxis标签仅显示在周数等于1的刻度线上
(我已经设置了年轴的偏移量,所以它没有在周数1下面准确显示)
现在我想在周数等于1的情况下显示Year Axis Tick
所以我将“tickPositions”添加到数组[0,53,105]
((3年的周数位置)到年轴,
但图表变成:
Screen Capture after adding "tickPositions"
由于我只根据数组添加3个刻度,为什么图表上有这么多刻度呢?
我该如何解决?非常感谢你! :)
感谢Sebastian,在我将插件添加到页面后,它显示如下错误:
你以前见过吗?谢谢!
另一个问题,我也有相同的图表显示每日数据,我该如何分组日期时间表?谢谢!
屏幕截图错误_http://postimg.org/image/iqgfspxqt/
我的年份xAxis代码:
{
labels: {
align: 'left',
x: 25,
formatter: function () {
var ex = this.axis.getExtremes();
if ((ex.max - ex.min) > 30) {
if (xCategoriesWeekNum[this.value] == 1)
return xCategoriesYear[this.value];
}
else if (((ex.max - ex.min) > 10)) {
if ((xCategoriesWeekNum[this.value] == 1) || ((xCategoriesWeekNum[this.value] % 10) == 0))
return xCategoriesYear[this.value];
}
else {
if ((xCategoriesWeekNum[this.value] == 1) || ((xCategoriesWeekNum[this.value] % 5) == 0))
return xCategoriesYear[this.value];
}
}
},
//offset: 0,
lineWidth: 0,
tickLength: 12,
tickPosition: 'inside',
tickInterval: 1,
tickPositions: [0, 53, 105],
tickPlacement: 'on',
//tickPositioner: function () {
// var ex = this.chart.xAxis[0].getExtremes();
// alert(getTickPosition(ex.min, ex.max));
// return getTickPosition(ex.min, ex.max);
//},
title: {
text: 'Week Number',
},
startOnTick: false,
endOnTick: false,
minPadding: 0,
maxPadding: 0,
}],
我的周xAxis代码:
[{
labels: {
formatter: function () {
var ex = this.axis.getExtremes();
if ((ex.max - ex.min) > 30) {
if ((xCategoriesWeekNum[this.value] == 1) || (xCategoriesWeekNum[this.value] == 7) || (xCategoriesWeekNum[this.value] == 13) || (xCategoriesWeekNum[this.value] == 19) || (xCategoriesWeekNum[this.value] == 25) || (xCategoriesWeekNum[this.value] == 31) || (xCategoriesWeekNum[this.value] == 37) || (xCategoriesWeekNum[this.value] == 43) || (xCategoriesWeekNum[this.value] == 49)) {
return xCategoriesWeekNum[this.value];
//if (xCategoriesWeekNum[this.value] == 1)
// return xCategoriesWeekNum[this.value] + '<br>' + xCategoriesYear[this.value];
//else
}
}
else {
return xCategoriesWeekNum[this.value];
}
}
},
tickPixelInterval: $('#' + container).width() / dataLength,
tickInterval: 1,
showLastLabel: true,
startOnTick: false,
endOnTick: false,
minPadding: 0,
maxPadding: 0,
}