javascript highchart dateTimeLabelFormats 不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18767736/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 13:09:29  来源:igfitidea点击:

highchart dateTimeLabelFormats don't work

javascripthighcharts

提问by Michael Scofield

var chart = new Highcharts.Chart({
chart: {
    renderTo: container
},

plotOptions: {
    series: {
        pointStart: Date.UTC(2010, 0, 1),
        pointInterval: 24 * 3600 * 1000 * 1 // one day
    }
},
xAxis: {
            type: 'datetime',
            dateTimeLabelFormats: { // don't display the dummy year 
                 day: '%b %e',  
            },
        },
series: [{
    data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}, {
    data: [144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2]
}]

the code upper work good, However when i change pointInterval to 24 * 3600 * 1000 * 7 (1 week), the highchart dateTimeLabelFormat don't work, any help

代码上部工作良好,但是当我将 pointInterval 更改为 24 * 3600 * 1000 * 7(1 周)时,highchart dateTimeLabelFormat 不起作用,有什么帮助

回答by Pawe? Fus

It doesn't work because you are setting label format for one day interval, while used is week format, see fixed example: http://jsfiddle.net/F2uMR/1/

它不起作用,因为您正在为一天间隔设置标签格式,而使用的是周格式,请参阅固定示例:http: //jsfiddle.net/F2uMR/1/

$('#container').highcharts({
    xAxis: {
        type: 'datetime',
        dateTimeLabelFormats: {
            day: '%b %e',
            week: '%b %e'
        }
    },

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
        pointStart: Date.UTC(2010, 0, 1),
        pointInterval: 24 * 3600 * 1000 * 7// one week
    }]
});