您好我正在使用两个窗格图http://www.highcharts.com/stock/demo/candlestick-and-volume 然后我把一个plodBands放到那个图表上,发生的事情是Band对yAxis的影响就像在这里http://jsfiddle.net/6sqEd/我注意到的是这个图表只有一个xAxis。
我怎样才能使这个PlotBands成为唯一的第一个yAxis不是两个?
这是代码:
$(function() {
$.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl- ohlcv.json&callback=?', function(data) {
// split the data set into ohlc and volume
var ohlc = [],
volume = [],
dataLength = data.length;
for (i = 0; i < dataLength; i++) {
ohlc.push([
data[i][0], // the date
data[i][1], // open
data[i][2], // high
data[i][3], // low
data[i][4] // close
]);
volume.push([
data[i][0], // the date
data[i][5] // the volume
])
}
// create the chart
chart = new Highcharts.StockChart({
chart: {
renderTo: 'container',
alignTicks: false
},
rangeSelector: {
selected: 5
},
title: {
text: 'AAPL Historical'
},
xAxis:[{
plotBands : [{
from : 1115856000000,
to : 1128384000000,
color : 'rgba(68, 170, 213, 0.2)',
label : {
text : 'Last quarter\'s value range'
}
}]
}],
yAxis: [{
title: {
text: 'OHLC'
},
height: 200,
lineWidth: 2
}, {
title: {
text: 'Volume'
},
top: 300,
height: 100,
offset: 0,
lineWidth: 2
}],
series: [{
type: 'candlestick',
name: 'AAPL',
data: ohlc,
}, {
type: 'column',
name: 'Volume',
data: volume,
yAxis: 1,
}]
});
});
});
答案 0 :(得分:3)
当您向yAxis添加plotBand时,您可以设置更高和更低的点
如果将plotBand放在xAxis上,它将显示在所有yAxis上
因此,如果您想在第一个轴上进行绘图,可能需要使用相同的plotBand样式创建一个新系列。添加它。
首先:您需要创建从开始日期到结束日期的区域系列,所有值都与窗格的最大值相同。在我的例子中它是800.
秒:确保最大值高于您的系列的最高值。我没有在我的例子中这样做,所以你必须在你的代码上这样做
第三:从图例中删除系列,并从工具提示中将enableMouseTracking和showInLegend设置为false。
<强> Example 强>