Clustered column chart

Click on the legend items to show/hide series. A special method `arrangeColumns` is added to this demo which nicely aniamtes columns so that they would always be centered within the cell.

by Kearnan Kelly

HTML

<script src="https://www.amcharts.com/lib/4/core.js"></script>
<script src="https://www.amcharts.com/lib/4/charts.js"></script>
<script src="https://www.amcharts.com/lib/4/themes/animated.js"></script>
<div id="chartdiv"></div>

CSS

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

#chartdiv {
  width: 100%;
  height: 500px;
}

JavaScript

/**
 * ---------------------------------------
 * This demo was created using amCharts 4.
 * 
 * For more information visit:
 * https://www.amcharts.com/
 * 
 * Documentation is available at:
 * https://www.amcharts.com/docs/v4/
 * ---------------------------------------
 */

// Themes begin
am4core.useTheme(am4themes_animated);
// Themes end




var chart = am4core.create('chartdiv', am4charts.XYChart)
chart.colors.step = 2;

chart.legend = new am4charts.Legend()
chart.legend.position = 'top'
chart.legend.paddingBottom = 20
chart.legend.labels.template.maxWidth = 95

var xAxis = chart.xAxes.push(new am4charts.CategoryAxis())
xAxis.dataFields.category = 'category'
xAxis.renderer.cellStartLocation = 0.1
xAxis.renderer.cellEndLocation = 0.9
xAxis.renderer.grid.template.location = 0;

var yAxis = chart.yAxes.push(new am4charts.ValueAxis());
yAxis.min = 0;

function createSeries(value, name) {
    var series = chart.series.push(new am4charts.ColumnSeries())
    series.dataFields.valueY = value
    series.dataFields.categoryX = 'category'
    series.name = name

/*     series.events.on("hidden", arrangeColumns);
    series.events.on("shown", arrangeColumns);
    
    var bullet = series.bullets.push(new am4charts.LabelBullet())
    bullet.interactionsEnabled = false
    bullet.dy = 30;
    bullet.label.text = '{valueY}'
    bullet.label.fill = am4core.color('#0000ff') */

    return series;
}

chart.data = [
    {
        category: 'Place #1',
        first: 40,
        second: 55,
        third: 60
    },
    {
        category: 'Place #2',
        first: 30,
        second: 78,
        third: 69
    },
    {
        category: 'Place #3',
        first: 27,
        second: 40,
        third: 45
    },
    {
        category: 'Place #4',
        first: 50,
        second: 33,
        third: 22
    }
]


createSeries('first', 'The Thirst');
createSeries('second', 'The Second');
createSeries('third', 'The Third');

function arrangeColumns() {

    var series =...