Highcharts (Highstock) — 为什么图表上没有绘制 plotLine?
Hichcharts (Highstock) — Why isn't the plotLine being drawn on the chart?
为什么图表上没有绘制 plotLine?我已经尝试解决这个问题至少 2 个小时了。
目标是在任何给定索引(示例中为 100)处添加与烛台一致的 plotLine。因此,ohlc
数组中索引 100 处的蜡烛将在图表中突出显示。为此,我将 plotLine 的 value
设置为 100
。我做错了吗?
非常感谢您的帮助。
// ASSUME WE HAVE 300 BARS
const symbol = 'APPL';
const volume = [ ... ];
const ohlc = [ ... ];
Highcharts.stockChart('chart', {
cropThreshold: 500,
xAxis: {
plotLines: [{
color: 'red',
dashStyle: 'longdashdot',
value: 100,
width: 1,
zIndex: 5
}],
},
series: [{
type: 'candlestick',
id: `${symbol}-ohlc`,
name: `${symbol} OHLC`,
data: ohlc,
}, {
type: 'column',
id: `${symbol}-volume`,
name: `${symbol} Volume`,
data: volume,
yAxis: 1,
}]
});
您需要记住您的 xAxis type is set as datetime
,因此 100 值是 1970 年 1 月 1 日之后的几秒钟。要使其正常工作,您需要设置适合图表范围的日期值。
为什么图表上没有绘制 plotLine?我已经尝试解决这个问题至少 2 个小时了。
目标是在任何给定索引(示例中为 100)处添加与烛台一致的 plotLine。因此,ohlc
数组中索引 100 处的蜡烛将在图表中突出显示。为此,我将 plotLine 的 value
设置为 100
。我做错了吗?
非常感谢您的帮助。
// ASSUME WE HAVE 300 BARS
const symbol = 'APPL';
const volume = [ ... ];
const ohlc = [ ... ];
Highcharts.stockChart('chart', {
cropThreshold: 500,
xAxis: {
plotLines: [{
color: 'red',
dashStyle: 'longdashdot',
value: 100,
width: 1,
zIndex: 5
}],
},
series: [{
type: 'candlestick',
id: `${symbol}-ohlc`,
name: `${symbol} OHLC`,
data: ohlc,
}, {
type: 'column',
id: `${symbol}-volume`,
name: `${symbol} Volume`,
data: volume,
yAxis: 1,
}]
});
您需要记住您的 xAxis type is set as datetime
,因此 100 值是 1970 年 1 月 1 日之后的几秒钟。要使其正常工作,您需要设置适合图表范围的日期值。