[英]Highstock bottom chart not shown
我正在使用一個官方的高價圖表演示來創建類似於2個圖表堆疊在一起的東西。 問題是底部圖表(音量)沒有顯示jsfiddle
aapl-ohlc.json文件的簡要說明會很有幫助。
...
const data = JSON.parse(document.getElementById('ohlc-data').innerHTML);
// split the data set into ohlc and volume
const ohlc = data.map((a) => [a[0], a[1], a[2], a[3], a[4]])
const volume = data.map((a) => [a[0], a[5]])
// set the allowed units for data grouping
const groupingUnits = [
[
'week', // unit name
[1] // allowed multiples
],
[
'month', [1, 2, 3, 4, 6]
]
]
// create the chart
Highcharts.stockChart('container', {
legend: {
enabled: false
},
credits: {
enabled: false
},
exporting: {
enabled: false
},
scrollbar: {
enabled: false
},
rangeSelector: {
selected: 4,
inputEnabled: false
},
title: {
text: ''
},
yAxis: [{
labels: {
align: 'right',
x: -3
},
title: {
text: ''
},
height: '60%',
lineWidth: 2
}, {
labels: {
align: 'right',
x: -3
},
title: {
text: ''
},
top: '65%',
height: '35%',
offset: 0,
lineWidth: 2
}],
tooltip: {
split: true
},
series: [{
type: 'candlestick',
name: 'AAPL',
data: ohlc,
dataGrouping: {
units: groupingUnits
}
}, {
type: 'column',
name: 'Volume',
data: volume,
yAxis: 1,
dataGrouping: {
units: groupingUnits
}
}],
navigator: {
enabled: false
}
});
這一行:
const volume = data.map((a) => [a[0], a[5]])
指向不存在的元素。 a[5]
未定義(每個子數組只有五個元素,沒有第六個元素),因此數據中沒有y
值,因此不顯示任何數據系列。
我不知道什么數據元素應該代表音量,但作為參考,只是為了表明它確實有效,這里是一個更新的小提琴使用
const volume = data.map((a) => [a[0], a[1]])
編輯:
請注意,在您基於小提琴的演示示例中,他們使用的文件是aapl-ohlcv.json
,而不是aapl-ohlc.json
,實際上每個子數組中都有第6個數據元素。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.