hightcharts圖表默認的英文日期改爲中文顯示

hightcharts中,圖表默認時間顯示樣式爲英文,需改爲中文。

在這裏插入圖片描述

解決:增加tooltip樣式控制

var tooltipConfig = {
  formatter: function () {
        return '<b>' + this.series.name + '</b><br/>' + this.point.y + '<br/>' +
            getLocalTime(this.point.x);
    },
    dateTimeLabelFormats: {
        millisecond: '%H:%M:%S.%L',
        second: '%H:%M:%S',
        minute: '%H:%M',
        hour: '%H:%M',
        day: '%Y-%m-%d',
        week: '%m-%d',
        month: '%Y-%m',
        year: '%Y'
    }
};
function getLocalTime(nS) {
    var date = new Date(nS);
    return date.getFullYear() + "/" + fomat(date.getMonth() + 1) + "/" + fomat(date.getDate()) + " " + fomat(date.getHours()) + ":" + fomat(date.getMinutes()) + ":" + fomat(date.getSeconds());
}
function fomat(data)
{
    return (data > 9 ? data : "0" + data);
}

在chart初始化中,增加

tooltip: tooltipConfig,

在這裏插入圖片描述

即可解決

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章