Mekko chart

A demo of amCharts 3, an older version, no longer developed. For a new project, start from the amCharts 5 demos.

Mekko or Marimekko chart is a variation of stacked column chart with a varied column width.

Open in:

Code

JavaScript

var chart = AmCharts.makeChart("chartdiv", {
    "theme":"light",
    "type": "serial",
    "dataProvider": [{
        "continent": "North America",
        "trucks": 40000,
        "SUVs": 180000,
        "cars": 90000,
        "total": 310000
    }, {
        "continent": "Asia",
        "trucks": 90000,
        "SUVs": 40000,
        "cars": 110000,
        "total": 240000
    }, {
        "continent": "Europe",
        "trucks": 30000,
        "SUVs": 50000,
        "cars": 110000,
        "total": 190000
    }],


    "categoryField": "continent",

    "categoryAxis": {
        "gridAlpha": 0.1,
        "axisAlpha": 0,
        "widthField": "total",
        "gridPosition": "start"
    },

    "valueAxes": [{
        "stackType": "100% stacked",
        "gridAlpha": 0.1,
        "unit": "%",
        "axisAlpha": 0
    }],

    "graphs": [
        {
            "title": "Trucks",
            "labelText": "[[value]]",
            "valueField": "trucks",
            "type": "column",
            "fillAlphas": 1
        }, {
            "title": "SUVs",
            "labelText": "[[value]]",
            "valueField": "SUVs",
            "type": "column",
            "fillAlphas": 1
        },

        {
            "title": "Cars",
            "labelText": "[[value]]",
            "valueField": "cars",
            "type": "column",
            "fillAlphas": 1
        }
    ],

    "legend": {},
    "export":
     {
     "enabled":true
     }
});

HTML

<div id="chartdiv"></div>

CSS

#chartdiv {
	width		: 100%;
	height		: 500px;
	font-size	: 11px;
}

Resources

https://www.amcharts.com/lib/3/amcharts.js
https://www.amcharts.com/lib/3/serial.js
https://www.amcharts.com/lib/3/themes/light.js
https://www.amcharts.com/lib/3/plugins/export/export.min.js
https://www.amcharts.com/lib/3/plugins/export/export.css

All in one page

<!-- Resources -->
<script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="https://www.amcharts.com/lib/3/serial.js"></script>
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
<script src="https://www.amcharts.com/lib/3/plugins/export/export.min.js"></script>
<link rel="stylesheet" href="https://www.amcharts.com/lib/3/plugins/export/export.css">

<!-- Chart code -->
<script>
var chart = AmCharts.makeChart("chartdiv", {
    "theme":"light",
    "type": "serial",
    "dataProvider": [{
        "continent": "North America",
        "trucks": 40000,
        "SUVs": 180000,
        "cars": 90000,
        "total": 310000
    }, {
        "continent": "Asia",
        "trucks": 90000,
        "SUVs": 40000,
        "cars": 110000,
        "total": 240000
    }, {
        "continent": "Europe",
        "trucks": 30000,
        "SUVs": 50000,
        "cars": 110000,
        "total": 190000
    }],


    "categoryField": "continent",

    "categoryAxis": {
        "gridAlpha": 0.1,
        "axisAlpha": 0,
        "widthField": "total",
        "gridPosition": "start"
    },

    "valueAxes": [{
        "stackType": "100% stacked",
        "gridAlpha": 0.1,
        "unit": "%",
        "axisAlpha": 0
    }],

    "graphs": [
        {
            "title": "Trucks",
            "labelText": "[[value]]",
            "valueField": "trucks",
            "type": "column",
            "fillAlphas": 1
        }, {
            "title": "SUVs",
            "labelText": "[[value]]",
            "valueField": "SUVs",
            "type": "column",
            "fillAlphas": 1
        },

        {
            "title": "Cars",
            "labelText": "[[value]]",
            "valueField": "cars",
            "type": "column",
            "fillAlphas": 1
        }
    ],

    "legend": {},
    "export":
     {
     "enabled":true
     }
});
</script>

<!-- HTML -->
<div id="chartdiv"></div>