0

在这个演示jsFiddle中,它展示了如何制作带有 2 个窗格的图表。但是,窗格的位置值是硬编码的,可以用于 500 像素的图表。此外,如果您删除导航器和滚动条(此 jsFiddle),图表不再看起来不错。

我想根据总 yAxis 高度的百分比来定义窗格高度,如下所示:

yAxis: [{
    title: {
        text: 'OHLC'
    },
    height: yAxisHeight * 0.5,
    lineWidth: 2
}, {
    title: {
        text: 'Volume'
    },
    top: yAxisHeight * 0.75,
    height: yAxisHeight * 0.25,
    offset: 0,
    lineWidth: 2
}],

但是,我只能在创建图表后获取 yAxis 的高度,然后必须重新绘制图表,这似乎效率很低。

var options = createMyOptions();
var chart = new Highcharts.StockChart(options);
var yAxisHeight = chart.yAxis[0].height;
options.yAxis[0].height = yAxisHeight * 0.5;
options.yAxis[1].top = chart.yAxis[0].top + yAxisHeight * 0.75
options.yAxis[1].height = yAxisHeight * 0.25;
chart.yAxis[0].update(options, true);
chart.yAxis[1].update(options, true);

有任何想法吗?

4

0 回答 0