我使用HighCharts HighStock版本在圖表中創建一系列數據。我在柱狀圖頂部有一個燭形圖,位於柱狀圖頂部。燭臺點是可點擊的。我想添加一個標誌到他們剛點擊的蠟燭圖上的點。HighStock HighCharts點擊事件設置標記
下面是一些我試着打代碼:
// create the chart
chart = new Highcharts.StockChart({
chart: {
renderTo: 'container',
alignTicks: false
},
rangeSelector: {
selected: 1
},
title: {
text: 'DJIA Historical'
},
yAxis: [{
title: {
text: 'OHLC'
},
height: 300,
lineWidth: 2
}, {
title: {
text: 'Volume'
},
top: 400,
height: 100,
offset: 0,
lineWidth: 2
}, {
title: {
text: 'MACD'
},
top: 520,
height: 100,
offset: 0,
lineWidth: 1
}],
series: [{
type: 'candlestick',
name: 'DJIA',
data: ohlc,
events: {
click: function(event) {
console.log(chart);
chart.series[6].setData(event.point);
}
},
dataGrouping: {
units: groupingUnits
}
}, {
type: 'column',
name: 'Volume',
data: volume,
yAxis: 1,
dataGrouping: {
units: groupingUnits
}
}, {
type: 'column',
name: 'Histogram',
pointPadding: 0,
groupPadding: 0,
data: histogram,
yAxis: 2,
color: '#666666'
}, {
type: 'line',
name: 'MACD',
pointPadding: 0,
groupPadding: 0,
data: macd,
yAxis: 2,
color: '#0000FF'
}, {
type: 'line',
name: 'Signal',
pointPadding: 0,
groupPadding: 0,
data: signal,
yAxis: 2,
color: '#000000'
}, {
type: 'flags',
name: 'Active Point',
data: [],
onSeries: ohlc,
shape: 'squarepin'
}]
});
})
圖表不拋出任何JavaScript錯誤,但它不是創建標誌。至少,它沒有顯示出來。我希望基本上能夠在他們點擊的燭臺上畫上旗幟。如果他們點擊另一個地點,我想刪除舊標誌並在新點上繪製一個新標誌。我認爲這最好是通過添加和刪除系列中的數據完成的,但沒有多少運氣。
任何幫助,將不勝感激!
您先生,是男士,謝謝! – Dexter 2012-08-03 18:28:54