Highcharts Marimekko Chart

author(s): Torstein Hønsi

HTML

<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/treemap.js"></script>
<div id="container"></div>

CSS

#container {
    min-width: 300px;
    max-width: 600px;
    margin: 0 auto;
}

JavaScript

$(function() {
    var colors = Highcharts.getOptions().colors;
    Highcharts.seriesTypes.treemap.prototype.bindAxes = function() {
        var treeAxis = {
            min: 0,
            dataMin: 0,
            max: 100,
            dataMax: 0
        };

        Highcharts.Series.prototype.bindAxes.call(this);
        Highcharts.extend(this.yAxis.options, treeAxis);
        Highcharts.extend(this.xAxis.options, treeAxis);

    }
    $('#container').highcharts({
        title: {
            text: 'Highcharts Marimekko Chart',
            margin: 30
        },
        xAxis: {
            labels: {
                format: '{value}%'
            }
        },
        yAxis: {
            title: null,
            labels: {
                format: '{value}%'
            }
        },
        series: [{
            type: 'treemap',
            layoutAlgorithm: 'stripes',
            alternateStartingDirection: true,
            levels: [{
                level: 1,
                borderWidth: 0,
                dataLabels: {
                    enabled: true,
                    align: 'center',
                    crop: false,
                    inside: false,
                    overflow: 'none',
                    y: -24,
                    verticalAlign: 'top',
                    style: {
                        fontWeight: 'bold'
                    }
                }
            }],
            data: [{
                id: 'Seg A',
                sortIndex: 0
            }, {
                name: 'Alpha',
                value: 2,
                parent: 'Seg A',
                color: colors[0],
                sortIndex: 0
            }, {
                name: 'Beta',
                value: 2,
                parent: 'Seg A',
                color: colors[1],
                sortIndex: 1
            }, {
                name: 'Gamma',
                value: 2,
                parent: 'Seg A',
                color: colors[2],
               ...