highcharts - highcharts - 通过自定义 id 添加标签
问题描述
我有一个温度传感器数据的迷你图,它每 1 分钟采样一年的数据
我首先加载一个空白图表,然后进行服务器调用,将结果返回并通过调用显示它
getchart.addSeries({
name: thisGroup,
id: probeItem[0],
data: probeDataArray,
keys: ['x', 'y', 'specialId'],
最多可以有 20 个系列,它们都一个一个地加载到屏幕上 这渲染得非常快,但是我现在需要在温度超过某个值的地方添加一个标签注释(即在其警报状态时添加一个警告符号)
目前我正在遍历每个点并查看它是否超过某个值:
currentSeries.points.forEach(function (point) {
然而,这是非常缓慢的。
我有一组警报,可以将它们引用为
['x', 'y', 'specialId']
但是我看不到如何通过 x、y 或 specialId 添加注释标签。
如果我遍历所有已渲染的点,我似乎只能添加标签
有没有办法使用我的 ID 添加标签?我还需要调整图形和标签的大小以保持在同一个地方
或者,如果这是不可能的,是否在我添加系列时添加标签?:
getchart.addSeries({
name: thisGroup,
id: CurrentGroupID,
dashStyle: 'ShortDot',
data: groupLogArray,
keys: ['x', 'y', 'specialId'],
showInNavigator: true, //this shows the series data in the small bottom navigator
point: {
events: {
click: function () {
//alert("test click");
}
}
}
});
解决方案
x
您可以通过和y
轴值添加注释:
chart.addAnnotation({
labels: [{
text: 'Alarm',
point: {
x: 2,
y: 3,
xAxis: 0,
yAxis: 0
}
}]
});
现场演示:http: //jsfiddle.net/BlackLabel/k6trha3e/
API 参考: https ://api.highcharts.com/class-reference/Highcharts.Chart#addAnnotation
作为替代方案,您还可以使用数据标签:http: //jsfiddle.net/BlackLabel/n4586xzq/
推荐阅读
- python - tf.keras 两个损失,中间层作为其中一个的输入错误:急切执行函数的输入不能是 Keras 符号张量
- unit-testing - 如何模拟这些类型的查询?
- sql - 如何在生产中修改数据库模式
- sql - 在 SQL Server 中将月份名称转换为月份编号
- for-loop - 如何将for循环中的图像名称更改为特定数字
- c++ - 使用容器提升 X3 解析结构
- c - 如何将文件中的信息存储到C中的内存中
- boolean - 大型布尔表达式的替换
- c - 如何使用 malloc 和 realloc 使用 C 分配字符串
- python - 如何为发布配置不同的请求正文并在 django-rest-framework 中对同一端点进行调用