Stacked and Clustered Column Chart
As you see from the chart above, you can have stacked and clustered columns/bars on one series. All you need to do is set <code>newStack</code> property of a graph which should begin new stack to <code>true</code>. You can have any number of stacks on one series.
by Kearnan Kelly
July 03, 2020
HTML
<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/plugins/export/export.min.js"></script>
<link rel="stylesheet" href="https://www.amcharts.com/lib/3/plugins/export/export.css" type="text/css" media="all" />
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
<div id="chartdiv"></div>
CSS
#chartdiv {
width: 100%;
height: 500px;
}
JavaScript
var chart = AmCharts.makeChart( "chartdiv", {
"type": "serial",
"theme": "light",
"depth3D": 0,
"angle": 0,
"legend": {
"horizontalGap": 10,
"markerSize": 10,
"data": [{
"title": "Total_Balance",
"value": "120", //not officially documented - use at your own risk
// "backgroundColor":"#0D52D1", not valid
"color": "#00ff00"
}, {
"title": "Total_Paid",
"value":"150", //not officially documented - use at your own risk
// "backgroundColor":"#04D215", not valid
"color": "#ff0000"
}]
},
"dataProvider": [ {
"year": 2003,
"europe": 200,
"namerica": 215
}, {
"year": 2004,
"europe": 244,
"namerica": 180
}, {
"year": 2005,
"europe": 280,
"namerica": 295
} ],
"valueAxes": [ {
"stackType": "none",
"axisAlpha": 0,
"gridAlpha": 0
} ],
"graphs": [ {
"balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>",
"fillAlphas": 0.8,
"labelText": "[[value]]",
"lineAlpha": 0.3,
"title": "Europe",
"type": "column",
"color": "#000000",
"valueField": "europe"
}, {
"balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>",
"fillAlphas": 0.8,
"labelText": "[[value]]",
"lineAlpha": 0.3,
"title": "North America",
"type": "column",
"color": "#000000",
"valueField": "namerica"
}],
"categoryField": "year",
"categoryAxis": {
"gridPosition": "start",
"axisAlpha": 0,
"gridAlpha": 0,
"position": "left"
},
"export": {
"enabled": true
}
} );