最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Highcharts graph X-axis label for different date ranges - Stack Overflow

programmeradmin2浏览0评论

I have written a below code which generates a area graph for selected dates (to and from dates).

$(document).ready(function() {
    var options = {
        "series": [{
            "showInLegend": false,
            "color": "#D0D0D0",
            "name": "Revenue",
            "data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}],
        "credits": {
            "enabled": false
        },
        "chart": {
            "renderTo": "highchart_id",
            "defaultSeriesType": "area",
            "shadow": true
        },
        "title": {
            "text": null,
            "align": "center",
            "x": 0,
            "y": 20
        },
        "xAxis": {
            "type": "datetime",
            "dateTimeLabelFormats": {
                "month": "%e. %b",
                "year": "%b"
            },
            "labels": {
                "enabled": "false"
            }
        },
        "legend": {
            "enabled": true
        },
        "yAxis": {
            "title": {
                "text": ""
            },
            "labels": {
                "enabled": true
            }
        },
        "plotOptions": {
            "area": {
                "stacking": "normal",
                "lineColor": "#3E3E3E",
                "lineWidth": 3,
                "marker": {
                    "lineWidth": "1",
                    "lineColor": "#3E3E3E",
                    "states": {
                        "hover": {
                            "enabled": true,
                            "radius": 1
                        }
                    }
                }
            },
            "series": {
                "pointStart": 1335823200000,
                "pointInterval": 86400000
            }
        }
    };
    var chart = new Highcharts.Chart(options);
});​

The interval of dates on x-axis is coming one day less. here the series value 2 is for 10 may whereas it is showing for 9 may in graph.

I am new to this highchart, can anybody advice the solution please and let me known if you need any more clarification on the problem.

I have written a below code which generates a area graph for selected dates (to and from dates).

$(document).ready(function() {
    var options = {
        "series": [{
            "showInLegend": false,
            "color": "#D0D0D0",
            "name": "Revenue",
            "data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}],
        "credits": {
            "enabled": false
        },
        "chart": {
            "renderTo": "highchart_id",
            "defaultSeriesType": "area",
            "shadow": true
        },
        "title": {
            "text": null,
            "align": "center",
            "x": 0,
            "y": 20
        },
        "xAxis": {
            "type": "datetime",
            "dateTimeLabelFormats": {
                "month": "%e. %b",
                "year": "%b"
            },
            "labels": {
                "enabled": "false"
            }
        },
        "legend": {
            "enabled": true
        },
        "yAxis": {
            "title": {
                "text": ""
            },
            "labels": {
                "enabled": true
            }
        },
        "plotOptions": {
            "area": {
                "stacking": "normal",
                "lineColor": "#3E3E3E",
                "lineWidth": 3,
                "marker": {
                    "lineWidth": "1",
                    "lineColor": "#3E3E3E",
                    "states": {
                        "hover": {
                            "enabled": true,
                            "radius": 1
                        }
                    }
                }
            },
            "series": {
                "pointStart": 1335823200000,
                "pointInterval": 86400000
            }
        }
    };
    var chart = new Highcharts.Chart(options);
});​

The interval of dates on x-axis is coming one day less. here the series value 2 is for 10 may whereas it is showing for 9 may in graph.

I am new to this highchart, can anybody advice the solution please and let me known if you need any more clarification on the problem.

Share Improve this question edited Mar 5, 2017 at 12:22 Cœur 38.7k26 gold badges202 silver badges277 bronze badges asked Jun 12, 2012 at 9:55 Jeet SinghJeet Singh 4021 gold badge5 silver badges12 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 23

Try adding this code before declaring the chart

Highcharts.setOptions({      
  time: {
    useUTC: false
  }
});

By default highchart used UTC times. By adding the code above it will use the time zone of the browser.

发布评论

评论列表(0)

  1. 暂无评论