angular - 如何在 HighChart 中为 ColumnRange 图表的 xAixs 添加时间?
问题描述
我目前正在使用角度来显示 highcharts。我需要显示一个关于时间和用户名的 columnRange 图表。但我无法这样做。
所以我通过 API 获得的时间是字符串格式('07:34:25'),我不能直接在 columnRange 图表中显示字符串。为此,我尝试将其转换为日期。这是不可能的。我也尝试使用 moment.js 但它也只返回字符串。
同样经过一番搜索,我得到了一种在 yAxis 中添加“日期时间”类型的解决方案。
yAxis: {
type: 'datetime',
min: 0,
title: {
text: charSeries.title,
},
}
但它正在抛出错误。
src/app/features/adminControl/modules/analyticsReport/components/averageDailyActionsReport/averageDailyActionsReport.component.ts(157,66):错误TS2345:类型参数'{图表:{类型:字符串;倒置:布尔值;动画:布尔值;}; 标题:{文本:字符串;风格:{颜色:字符串;字体:字符串;}; 位置:{对齐:字符串;}; }; 副标题:{文本:字符串;样式:{浮动:布尔值;对齐:字符串;字体:字符串;}; }; ... 5 更多 ...; 学分:{ ...; }; }' 不可分配给“选项”类型的参数。
解决方案
您可以使用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]
]
}]
推荐阅读
- python - 我在销毁按钮时收到错误 _tkinter.TclError: bad window path name ".!button"
- sql - SQL Server - Sakila DB
- angular - 上传文件时如何通过 ng2-file-upload 发送其他参数
- ios - 如何从@propertywrapper 中公开闭包?
- javascript - 使用 for 循环 (JS) 在变量名末尾分配索引 (i) 值
- json - Circe asJson 不编码抽象基类的属性
- reactjs - React Material UI 扩展面板禁用光标指针
- swift - 有没有办法在 SwiftUI 中向 Lottie 动画开关添加动作
- python - 如何更改 Django 管理员用户更改页面选项卡的标题?
- html - 如何在所有屏幕尺寸上保持 SVG 的波形