简体   繁体   English

highcharts 日期时间点与 xaxis 的错误对齐

[英]Wrong alignment in highcharts datetime points with xaxis

Here's a fiddle with my problem: http://jsfiddle.net/v0bxdqa7/5/这是我的问题的一个摆弄: http : //jsfiddle.net/v0bxdqa7/5/

As you can see, the point is not aligned with the xaxis value.如您所见,该点未与 xaxis 值对齐。

I've come to believe, from the examples shown in highcharts website, that the problem is with my data, but I can't find the exact problem with it.我开始相信,从 highcharts 网站上显示的示例中,问题出在我的数据上,但我找不到它的确切问题。

Any ideas?有任何想法吗?

My options:我的选择:

     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"]

Indeed your (timestamp) data is wrong.确实,您的(时间戳)数据是错误的。

Take the first one for example: 1370787037000 if you convert it you get Sun, 09 Jun 2013 14:10:37 GMT and that is exactly what's drawn on the chart.以第一个为例: 1370787037000如果你转换它,你会得到Sun, 09 Jun 2013 14:10:37 GMT ,这正是图表上绘制的。

If you want this point to be precisely on Sun, 09 Jun 2013 00:00:00 GMT its correct timestamp is 1370736000000 .如果您希望这一点恰好位于Sun, 09 Jun 2013 00:00:00 GMT其正确的时间戳为1370736000000 You have to do this for each date.您必须为每个日期执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM