我如何在HighChart中为ColumnRange图表的xAix添加时间?

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

我目前正在使用角度显示高图。我需要显示有关时间和用户名的columnRange图表。但我无法这样做。

所以我通过API的时间是字符串格式(''07:34:25')并且我无法直接在columnRange图表中显示字符串。为此,我尝试将其转换为日期。这是不可能的。我也尝试使用moment.js,但它也只返回字符串。

[也经过一些搜索,我得到了一个解决方案,在yAxis中添加'datetime'类型。

yAxis: {
    type: 'datetime',
    min: 0,
    title: {
      text: charSeries.title,
    },
  }

但是它抛出错误。

src / app / features / adminControl / modules / analyticsReport / components / averageDailyActionsReport / averageDailyActionsReport.component.ts(157,66):错误TS2345:类型为'{的参数:图表:{类型:字符串;反转:布尔值;动画:布尔值; };标题:{文字:字符串;样式:{颜色:字串;字型:字串; };位置:{align:string; }; };字幕:{text:string;样式:{float:boolean; align:字符串;字型:字串; }; }; ...另外5个...;学分:{...; }; }”不可分配给“选项”类型的参数。

angular highcharts
1个回答
0
投票

您可以使用category轴类型:

xAxis: {
    type: 'category'
},

series: [{
    data: [
        ['07:34:25', -9.9, 10.3],
        ['07:35:25', -8.6, 8.5],
        ['07:36:25', -10.2, 11.8],
        ['07:37:25', -1.7, 12.2],
        ['07:38:25', -0.6, 23.1]
    ]
}]

实时演示: https://jsfiddle.net/BlackLabel/7o8f9ez5/

API参考: https://api.highcharts.com/highcharts/xAxis.type

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