默认的高图表高度= 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