Highcharts Highstock将x轴网格线与数据点中心对齐

时间:2015-01-02 19:18:33

标签: highcharts highstock gridlines

我使用Highcharts Highstock图表显示每日数据。垂直(x轴)网格线不与数据点对齐(网格线位于数据点的左侧)。有谁知道如何将网格线与数据点对齐?

http://jsfiddle.net/kngz3exf/3/

Highcharts.setOptions({
    global: {
        useUTC: false
    }
});
$(function () {
    $('#container').highcharts('StockChart', {

        rangeSelector: {
            enabled: false
        },

        yAxis: {
            gridLineWidth: 0
        },

        xAxis: {
            gridLineColor: '#000000',
            gridLineWidth: 1,
            lineColor: '#000000',
            tickColor: '#000000',
            minorGridLineColor: '#000000',
            minorGridLineWidth: 1,
            minorTickColor: '#000000',
            ordinal: true,
            tickInterval: 86400000,
            minorTickInterval: 86400000
        },

        series: [{
            data:[
                [1417410000000, -0.4818850000000001],
                [1417496400000, -0.40866199999999997],
                [1417582800000, 0.20889499999999994],
                [1417669200000, -0.623542],
                [1417755600000, -0.060399999999999995],
                [1418014800000, -0.56108],
                [1418101200000, 0.30852700000000005],
                [1418187600000, -0.4492829999999999],
                [1418274000000, -0.275211],
                [1418360400000, 0.013063999999999965],
                [1418619600000, -0.27293900000000004],
                [1418706000000, 0.49981200000000003],
                [1418792400000, 0.2362090000000001],
                [1418878800000, 0.4464490000000003],
                [1418965200000, 1.2100639999999998],
                [1419224400000, -0.792635],
                [1419310800000, 0.14788899999999994],
                [1419397200000, 0.011684],
                [1419570000000, 0.08526699999999998],
                [1419829200000, -0.12494599999999997],
                [1419915600000, -0.06489100000000003],
                [1420002000000, 0.279632]
            ]
        }]
    });
});

2 个答案:

答案 0 :(得分:0)

您需要做的是将useUTC设置为false。现在您的Dec 2数据显示在Dec 2nd轴上。请注意,您的数据不会达到每个主要刻度标记 - 看起来您正在跳过周末,但您的轴不是。

答案 1 :(得分:0)

通过将日期格式从刻度更改为Date.UTC(yyyy,mm,dd),我可以使数据点与垂直网格线对齐。