Marcelo Juventino
Marcelo Juventino

Reputation: 335

Is it possible create a Highstock chart using TWO PANES and MULTIPLE SERIES in a pane

Does anybody know if it's possible to create a chart using TWO PANES and, inside of a pane, MULTIPLE SERIES?

I did a screenshot of what I need:

Example of TWO PANES chart with MULTIPLE SERIES in a pane

Does anybody have a example in JFiddler?

I already tried to create one but I didn't have success...

Regards,

Marcelo

Upvotes: 0

Views: 1509

Answers (1)

Marcelo Juventino
Marcelo Juventino

Reputation: 335

Yes, I did it!

Bellow follow the source code that I've created:

HTML

<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>
<div id="container" style="height: 500px; min-width: 310px"></div>

Javascript Code

$(function() {
    $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-ohlcv.json&callback=?', function(data) {
        var ohlc = [],
            ohlc2 = [],
            volume = [],
            dataLength = data.length,
            groupingUnits = [
                ['week', [1]],
                ['month', [1, 2, 3, 4, 6]]
            ],
            i = 0;

        for (i; i < dataLength; i += 1) {
            ohlc.push([
                data[i][0], // the date
                data[i][1], // open
                data[i][2], // high
                data[i][3], // low
                data[i][4]  // close
            ]);

            ohlc2.push([
                data[i][0],       // the date
                data[i][1] - (Math.ceil(Math.random()*100)+100), // open
                data[i][2] - (Math.ceil(Math.random()*100)+100), // high
                data[i][3] - (Math.ceil(Math.random()*100)+100), // low
                data[i][4] - (Math.ceil(Math.random()*100)+100)  // close
            ]);

            volume.push([
                data[i][0], // the date
                data[i][5]  // the volume
            ]);
        }

        // create the chart
        $('#container').highcharts('StockChart', {

            rangeSelector: {
                inputEnabled: $('#container').width() > 480,
                selected: 1
            },

            title: {
                text: 'Two Panes & Multiple Series'
            },

            yAxis: [{
                labels: {
                    align: 'right',
                    x: -3
                },
                title: {
                    text: 'OHLC'
                },
                height: '60%',
                lineWidth: 2
            }, {
                labels: {
                    align: 'right',
                    x: -3
                },
                title: {
                    text: 'Volume'
                },
                top: '65%',
                height: '35%',
                offset: 0,
                lineWidth: 2
            }],

            series: [{
                name: 'AAPL',
                data: ohlc,
                dataGrouping: {
                    units: groupingUnits
                }
            }, {
                name: 'AAPL2',
                data: ohlc2,
                dataGrouping: {
                    units: groupingUnits
                }
            }, {
                name: 'Volume',
                data: volume,
                yAxis: 1,
                dataGrouping: {
                    units: groupingUnits
                }
            }]
        });
    });
});

And the link in JSFiddler: http://jsfiddle.net/marcelojuventino/tc1a78ma/1/

Thanks to everybody!

Upvotes: 1

Related Questions