在高图表中x轴终点数据点未正确显示

时间:2015-06-05 10:11:23

标签: highcharts

我的例子:enter code here http://jsfiddle.net/8wkyu9hh/

end-Data point应该是2020年12月。但它显示的是1月-2021.当设置endOnTick:true时,sep 2020当endOnTick:false时。 如何解决它。

1 个答案:

答案 0 :(得分:0)

它不会显示2020年12月,因为您每隔三个月就会在xAxis上显示(Jan - > Apr - > July - > Oct - > Jun)。我会升级你的tickPositioner。另外,我会更改minmax以使用Date.UTC(),但这只是个人观点。

        tickPositioner: function (min, max) {
            var axis = this,
                options = axis.options,
                // get normalized tick interval
                normalizedTickInterval = axis.normalizeTimeTickInterval(
                axis.tickInterval,
                options.units),
                // get default ticks
                ticks = this.getTimeTicks(
                normalizedTickInterval,
                min,
                max,
                options.startOfWeek,
                axis.ordinalPositions,
                axis.closestPointRange,
                true);

            // register information for label formatter
            ticks.info = {
                higherRanks: normalizedTickInterval.higherRanks,
                unitName: normalizedTickInterval.unitName
            };

            // replace first label with 2004 year. When label overlap, remove for example first two elements (1 change to 2):
            //ticks.splice(0, 2, min);
            ticks.splice(0, 1);
            ticks.push(max);
            ticks.sort(function (a, b) {
                return a - b;
            });
            return ticks;
        }

演示:http://jsfiddle.net/8wkyu9hh/2/