Highchart 显示 UTC 时间而不是本地时间 - 同时配置为显示本地时间

问题描述 投票:0回答:1

我有高图表设置:(我确实复制粘贴了最终对象)

{
    "responsive": {
        "rules": [
            {
                "condition": {
                    "maxWidth": 500
                },
                "_id": "highcharts-j9kyewe-155"
            }
        ]
    },
    "chart": {
        "type": "area",
        "style": {
            "cursor": "pointer"
        },
        "zooming": {
            "type": "x"
        }
    },
    "time": {
        "useUTC": false
    },
    "title": {
        "text": "",
        "align": "left"
    },
    "subtitle": {
        "text": "",
        "align": "left"
    },
    "credits": {
        "enabled": false
    },
    "xAxis": {
        "lineWidth": 1,
        "lineColor": "#d2d8db",
        "labels": {
            "style": {
                "fontFamily": "Open Sans",
                "fontWeight": "400",
                "fontSize": "0.75rem",
                "color": "#3f5c69"
            }
        },
        "type": "datetime"
    },
    "yAxis": {
        "labels": {
            "style": {
                "fontFamily": "Open Sans",
                "fontWeight": "400",
                "fontSize": "0.75rem",
                "color": "#3f5c69"
            }
        },
        "title": {
            "text": ""
        }
    },
    "legend": {
        "enabled": false
    },
    "plotOptions": {
        "area": {
            "marker": {
                "radius": 2
            },
            "lineWidth": 1,
            "color": {
                "linearGradient": {
                    "x1": 0,
                    "y1": 0,
                    "x2": 0,
                    "y2": 1
                },
                "stops": [
                    [
                        0.5,
                        "#95AAB8"
                    ],
                    [
                        1,
                        "#F3F6F7"
                    ]
                ]
            },
            "states": {
                "hover": {
                    "lineWidth": 1
                }
            },
            "threshold": null
        }
    },
    "series": [
        {
            "data": [
                [
                    1704067200000,
                    50.75
                ],
                [
                    1704070800000,
                    57.79999923706055
                ],
                [
                    1704074400000,
                    41.55555725097656
                ],
                [
                    1704078000000,
                    44.14285659790039
                ],
                [
                    1704081600000,
                    59.55555725097656
                ],
                [
                    1704085200000,
                    46.92856979370117
                ],
                [
                    1704088800000,
                    60
                ],
                [
                    1704092400000,
                    70.55555725097656
                ],
                [
                    1704096000000,
                    58.3636360168457
                ],
                [
                    1704099600000,
                    52.42856979370117
                ],
                [
                    1704103200000,
                    61
                ],
                [
                    1704106800000,
                    78.9000015258789
                ],
                [
                    1704110400000,
                    71.0999984741211
                ],
                [
                    1704114000000,
                    38.099998474121094
                ],
                [
                    1704117600000,
                    61.70000076293945
                ],
                [
                    1704121200000,
                    50.5
                ],
                [
                    1704124800000,
                    52.83333206176758
                ],
                [
                    1704128400000,
                    44.46154022216797
                ],
                [
                    1704132000000,
                    52.09090805053711
                ],
                [
                    1704135600000,
                    52.83333206176758
                ],
                [
                    1704139200000,
                    34.66666793823242
                ],
                [
                    1704142800000,
                    60.75
                ],
                [
                    1704146400000,
                    64.80000305175781
                ],
                [
                    1704150000000,
                    46.20000076293945
                ]
            ],
            "lineColor": "#7E97A8",
            "name": "",
            "type": "area"
        }
    ],
    "exporting": {
        "enabled": false,
        "buttons": {
            "contextButton": {
                "enabled": false
            }`your text`
        }
    },
    "tooltip": {
        "resolution": "Hour"
    }
}

**我想看到当地时间的所有日期,但我在 UTC 上看到为什么?** 我尝试根据文档将其添加到设置中:

时间:{ 使用UTC:假 },


but I still saw UTC time

我尝试使用: 时间: { useUTC: false } 它不起作用 我做错了什么?让我知道如何解决它谢谢

highcharts
1个回答
0
投票

timezone.useUTC
选项目前已弃用,建议使用
time.timezone
设置。您可以将此属性设置为
undefined
,它应该回退到本地浏览器时区。

time: {
    timezone: undefined
}

演示:https://jsfiddle.net/BlackLabel/9kdb8er4/

API: https://api.highcharts.com/highcharts/time.timezone

© www.soinside.com 2019 - 2024. All rights reserved.