使用xaxis在highcharts datetime中错误对齐

时间:2014-10-06 15:34:38

标签: javascript highcharts highstock

以下是我的问题:http://jsfiddle.net/v0bxdqa7/5/

如您所见,该点与xaxis值不对齐。

我从highcharts网站上显示的示例中得出结论,问题出在我的数据上,但我无法找到它的确切问题。

有什么想法吗?

我的选择:

     rangeSelector: {
        inputEnabled: false,
        selected: 1,
        buttons: [{
            type: 'day',
            count: 7,
            text: '7'
        }, {
            type: 'day',
            count: 30,
            text: '30'
        }, {
            type: 'year',
            count: 1,
            text: '365'
        }, {
            type: 'ytd',
            text: 'year'
        }]
    },
    tooltip: {
        headerFormat: '<small style="color: #666680">{point.key}</small><br>',
        pointFormat: '<span style="color: #acacbf">{series.name}: </span>' +
        '<span style="color: #666680"><b>{point.y}</b></span>'
    },
    xAxis: {
        lineColor: '#ebebeb',
        type: 'datetime',
        labels: {
            style: {
                color: '#acacbf'
            },
            align: "center",
            maxStaggerLines: 1,
            overflow: false
        }
    },
    yAxis: {
        allowDecimals: false,
        gridLineWidth: 0,
        labels: {
            enabled: false,
            style: {
                color: '#acacbf'
            }
        },
        min: 0,
        floor: 0,
        minRange:1
    },
    navigator: {enabled: false},
    chart: {
        className: "line-chart",
        backgroundColor: "#f7f7f7",
        margin:[10,5,22,5]
    },
    plotOptions: {
        series: {
            marker: {
                enabled: true,
                states: {
                    hover: {
                        radius: 5
                    },
                    select: {
                        enabled: true,
                        radius: 5,
                        fillColor: '#ffffff',
                        lineColor: '#ad49a5'
                    }
                }
            }
        }
    },
    scrollbar: {
        enabled: false
    },
    colors: ["#ad49a5"]

1 个答案:

答案 0 :(得分:0)

确认您的(时间戳)数据错误。

以第一个为例:1370787037000如果您将其转换为Sun, 09 Jun 2013 14:10:37 GMT,那么这就是图表上绘制的内容。

如果您希望此点恰好位于Sun, 09 Jun 2013 00:00:00 GMT,则正确的时间戳为1370736000000。您必须为每个日期执行此操作。