Show only time labels on xAxis. Highcharts

雨燕双飞 提交于 2019-12-22 04:33:16

问题


I need to display only time labels on xAxis. I'm using Highcharts and don't fully understand how to do it. On xAxis there should be time labels in format like 21:00. I do not need dates, only time is needed. In addition, the difference between two labels should be 00:30 (half an hour) or 01:30 and it should be zoomable. My PHP script writes some value in database every half an hour and I need to display it on a graph. Sorry for my poor English, I'm Russian. Any help would be appreciated :)


回答1:


In xAxis of your chart you need to provide tickinterval and dateTimeLabelFormats. Following code gives the tick interval of 1.5 hours. You can change that to any number of hours you want by replacing 1.5 in tickInterval: 1.5 * 3600 * 1000,

xAxis: {
    type: 'datetime',
    //Sets tickInterval to 24 * 3600 * 1000 if display is by day
    tickInterval: 1.5 * 3600 * 1000,
    dateTimeLabelFormats : {
        day: '%H:%M'
    }
}


来源:https://stackoverflow.com/questions/11328567/show-only-time-labels-on-xaxis-highcharts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!