默認的高圖表高度= 400px。自動圖表高度
如何根據圖表軸及其尺寸設置自動尺寸的高度圖?
請參閱下面的示例,導航欄位於卷面板上方。
我知道我可以設置高度的股利,但我有一個插入/刪除動態軸/系列在圖表中和將是很好的自動高度圖表的解決方案。
該示例與Highchart站點的燭臺/音量演示相同,但div容器中沒有高度屬性。
// 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
])
}
// set the allowed units for data grouping
var groupingUnits = [[
'week', // unit name
[1] // allowed multiples
], [
'month',
[1, 2, 3, 4, 6]
]];
// create the chart
$('#container').highcharts('StockChart', {
rangeSelector: {
selected: 1
},
title: {
text: 'AAPL Historical'
},
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,
dataGrouping: {
units: groupingUnits
}
}, {
type: 'column',
name: 'Volume',
data: volume,
yAxis: 1,
dataGrouping: {
units: groupingUnits
}
}]
});
});
});
問候。
您應該能夠使用您的yAxes中的百分比而不是固定值:http:// jsfiddle。net/BYNsJ/13 /如果它不能幫助你解決這個問題,你可以使用chart.setSize()來設置圖表的正確高度; – 2016-07-25 05:57:52
[Highcharts可能重複 - 如何使用動態高度的圖表](https://stackoverflow.com/questions/8809852/highcharts-how-to-have-a-chart-with-dynamic-height) – trushkevich 2017-12-07 06:40:29