使用Highcharts在图表上绘制小时和日期

时间:2016-09-29 13:37:41

标签: highcharts highcharts-ng

有人能指出我使用高图创建情节图的例子是xAxis包含00:00到23:59的小时数,yAxis包含我无法找到示例的日期列表如何从文档中实现。

基本上驱动图表的数据就是这样的

15/05/2017:09:00,13:00,14:30,17:00,19:15

16/05/2017:09:30,11:20,12:45,15:10,18:00

17/05/2017:08:30,10:15,13:00,14:05,20:30

任何例子或方向都会很棒。

由于

2 个答案:

答案 0 :(得分:0)

要获得与您的要求类似的图表,您可以将日期时间xAxis与分散系列一起使用。 http://api.highcharts.com/highcharts/xAxis.type

您可以使用dateTimeLabelFormats参数将日期时间标签格式更改为HH:MM:SS: http://api.highcharts.com/highcharts/xAxis.dateTimeLabelFormats

xAxis: {
  type: 'datetime',
  dateTimeLabelFormats: {
    millisecond: '%H:%M:%S',
    second: '%H:%M:%S',
    minute: '%H:%M:%S',
    hour: '%H:%M:%S',
    day: '%H:%M:%S',
    week: '%H:%M:%S',
    month: '%H:%M:%S',
    year: '%H:%M:%S'
  }
},

在这里,您可以看到一个示例:http://jsfiddle.net/0quce36h/5/

答案 1 :(得分:-1)

$(function () {  
   var d = new Date("July 21, 1983 01:15:00");
   var n1 = d.getUTCMinutes();
   d = new Date("July 21, 1983 01:16:30");
   n2 = d.getUTCMinutes();
   d = new Date("July 21, 1983 01:19:33");
   n3 = d.getUTCMinutes();

    chart = new Highcharts.Chart({
        chart: {
            type: 'line',
            renderTo: 'container'
        },
        title: {
            text: 'Time'
        },
        xAxis: {
            crosshair: true,
            categories: ['15/05/2017', '16/05/2017', '17/05/2017']
        },
        yAxis: {
            title: {
                text: 'Military Time Hours'
            }
        },
        series: [{
            name: 'Tokyo',
            data: 
           [[n1], 
            [n2], 
            [n3]]
        }]
});
});