0

编辑 HighStock 示例 2 窗格图表,在轴上设置极值会导致成交量图表消失。这是一个例子

http://jsfiddle.net/gbcLC/1/

我使用的是双窗格图表,但是当我调用 setExtremes (因为我想设置导航器的起始值)时,大多数情况下第一个图表很好,但是体积图表(这是我的第二个 x 轴)每次都会跳到不同的高度(导致它脱离 x 轴),有时它会完全消失(尽管 y 轴本身看起来还不错)。

$(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
        ])
    }

    // 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', {
                chart: {
                    events: {
                        load: function() {
                            this.xAxis[0].setExtremes(Date.UTC(2008,1,1),Date.UTC(2008,8,1),true,true);
                        }
                    }
                },          
        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
            }
        }]
    });
});

});

4

1 回答 1

0

该问题与动画有关,但已在最新的 master 分支中修复:

http://jsfiddle.net/gbcLC/4/

<script src="https://raw.github.com/highslide-software/highcharts.com/master/js/highstock.src.js"></script>
于 2013-03-29T10:55:09.913 回答