highcharts - 是否可以在特定点之间更改时间线图的线条颜色?
问题描述
在上图中,我想在时间线高图中将索引 2 到 3 的点设为红色。请帮我。
这是代码示例:
Highcharts.wrap(Highcharts.Tooltip.prototype, 'hide', function(proceed) {});
Highcharts.wrap(Highcharts.Tooltip.prototype, 'refresh', function(proceed, point, event, click) {
if (click) {
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
}
});
Highcharts.chart('container', {
chart: {
zoomType: 'x',
type: 'timeline',
events: {
load: function(e) {
this.series[0].points[2].select();
}
}
},
xAxis: {
type: 'datetime',
visible: false
},
yAxis: {
gridLineWidth: 1,
title: null,
labels: {
enabled: false
}
},
legend: {
enabled: false
},
title: {
text: ''
},
subtitle: {
text: ''
},
tooltip: {
style: {
width: 300
}
},
series: [{
dataLabels: {
allowOverlap: false,
enabled: false,
format: ''
},
marker: {
symbol: 'circle',
fillColor: '#1B7A92'
},
data: [{
x: Date.UTC(1951, 5, 22),
name: 'First dogs in space',
label: 'First dogs in space',
description: "Dezik and Tsygan were the first dogs to make a sub-orbital flight on 22 July 1951. Both dogs were recovered unharmed after travelling to a maximum altitude of 110 km."
}, {
x: Date.UTC(1957, 9, 4),
name: 'First artificial satellite',
label: 'First artificial satellite',
description: "Sputnik 1 was the first artificial Earth satellite. The Soviet Union launched it into an elliptical low Earth orbit on 4 October 1957, orbiting for three weeks before its batteries died, then silently for two more months before falling back into the atmosphere."
}, {
x: Date.UTC(1959, 0, 4),
name: 'First artificial satellite to reach the Moon',
label: 'First artificial satellite to reach the Moon',
description: "Luna 1 was the first artificial satellite to reach the Moon vicinity and first artificial satellite in heliocentric orbit."
}, {
x: Date.UTC(1961, 3, 12),
name: 'First human spaceflight',
label: 'First human spaceflight',
description: "Yuri Gagarin was a Soviet pilot and cosmonaut. He became the first human to journey into outer space when his Vostok spacecraft completed one orbit of the Earth on 12 April 1961."
}],
point: {
events: {
click: function(e) {
this.series.chart.tooltip.refresh(this, e, true);
}
}
}
}]
});
我尝试添加区域,但对于时间线图,我发现没有区域选项。有什么方法可以添加像 zone.d 那样的线条颜色。
我们如何制作像我提供的图像一样的时间线图。
提前致谢
解决方案
您可以使用zones
:
series: [{
zones: [{
value: Date.UTC(1959, 0, 4),
color: 'blue'
}, {
color: 'red'
}],
zoneAxis: 'x',
...
}]
现场演示: https ://jsfiddle.net/BlackLabel/uj20zh7a/
API 参考: https ://api.highcharts.com/highcharts/series.line.zones
推荐阅读
- python-3.x - 为什么 yield + iter() 不产生输出?
- javascript - 出口未定义 ia tsc'ed (js) 文件
- python - 根据固定的关键字/短语列表从文档中提取关键字
- c# - 长寿命连接多路复用器日志记录
- ios - 向集合视图单元添加集合视图会导致内存增长
- javascript - 使用来自 Node 原生 C++ 插件的 protobuf 并返回 V8
- nginx - 我无法提供来自 nginx 的 gunicorn 请求
- mysql - 带有特殊字符的全文,用于在 json 中替换。怎么了?
- node.js - 为 NodeJs 议程作业处理器编写单元测试
- angular - 使用 MVC dotNet Core 2.2 和 Angular 7 在 Visual Studio 2017 中运行 e2e 测试时出错