Jugal | Stacked charts | Highchart & Highstock

http://stackoverflow.com/questions/12121297/multiple-different-chart-types-stacked-column-type-with-y-value-as-color Jugal Thakkar http://jugal.me/

by tungwaiyip

HTML

<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>

<div id="container" style="min-width: 400px; height: 500px; margin: 0 auto"></div>

JavaScript

// usage: createSeries([0, 3, 4, 6], 1)
// Creates 4 series and assigns them all to yAxis 1
// you can extend this to take colors etc too, as per requirement
function createSeries(data, yAxisIndex) {
    var i;
    var series = [];
    for (i = 0; i < data.length - 1; i++) { // Node lenghth-1
        var start = data[i];
        var end = data[i + 1];
        series.push({
            yAxis: yAxisIndex,
            animation: false,
            stack: 0,
            data: [[start, 0], [end, 0]],
            lineWidth: 50,
            marker: {
                enabled: false
            },
            tooltip: {
                pointFormat: function() {
                    return "";
                }
            },
            events: {
                mouseOver: function() {
                    alert(this.data[1].x - this.data[0].x);
                }
            },
            showInLegend: false

        });
    }
    return series;
}


var options = {
    chart: {
        renderTo: 'container',
        animation: false
    },
    xAxis: {
                gridLineWidth: 1,
    },

    yAxis: [
    {
        height: 200,
        lineWidth: 2,
        offset: 0,
        tooltip: {
            enabled: true,
            formatter: function() {
                return this.value + 50;
            }
        }
    },
    {
        top: 300,
        //lineWidth: 0,
        min: 0,
        max: 5,
        gridLineWidth: 0,
        offset: 0,
        height: 100,
        labels: {
            enabled: false
        },
        title: {
            text: 'my title',
            align: 'low'
        }
    },
    ],
    plotOptions: {
        series: {
            borderWidth: 0,
//            pointPadding: 0,
//            groupPadding: 0,
            shadow: false
        },
        column: {
//            stacking: 'normal',
//            pointPadding: "5px;",
//            groupPadding: "2px",
            animation: false,
        },
        line: {
           ...