Fixed placement columns

author(s): Torstein Hønsi

by Sascha

HTML

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>

<figure class="highcharts-figure">
    <div id="container"></div>
    <p class="highcharts-description">
        Chart showing overlapping placement of columns, using different data
        series. The chart is also using multiple y-axes, allowing data in
        different ranges to be visualized on the same chart.
    </p>
</figure>

CSS

.highcharts-figure, .highcharts-data-table table {
    min-width: 310px; 
    max-width: 800px;
    margin: 1em auto;
}

#container {
    height: 400px;
}

.highcharts-data-table table {
	font-family: Verdana, sans-serif;
	border-collapse: collapse;
	border: 1px solid #EBEBEB;
	margin: 10px auto;
	text-align: center;
	width: 100%;
	max-width: 500px;
}
.highcharts-data-table caption {
    padding: 1em 0;
    font-size: 1.2em;
    color: #555;
}
.highcharts-data-table th {
	font-weight: 600;
    padding: 0.5em;
}
.highcharts-data-table td, .highcharts-data-table th, .highcharts-data-table caption {
    padding: 0.5em;
}
.highcharts-data-table thead tr, .highcharts-data-table tr:nth-child(even) {
    background: #f8f8f8;
}
.highcharts-data-table tr:hover {
    background: #f1f7ff;
}

JavaScript

Highcharts.chart('container', {
  chart: {
    type: 'column'
  },
  title: {
    text: 'Efficiency Optimization by Branch'
  },
  xAxis: {
    categories: [
      'Seattle HQ',
      'San Francisco',
      'Tokyo'
    ]
  },
  yAxis: [{
    min: 0,
    title: {
      text: 'Employees'
    }
  }, {
    title: {
      text: 'Profit (millions)'
    },
    opposite: true
  }],
  legend: {
    shadow: false
  },
  tooltip: {
    shared: true
  },
  plotOptions: {
    column: {
      grouping: false,
      shadow: false,
      borderWidth: 0
    }
  },
  series: [{
    name: 'Employees',
    color: 'rgba(165,170,217,1)',
    data: [150, 73, 20],
    pointPadding: 0.3,
    pointPlacement: -0.2
  }, {
    name: 'Employees Optimized',
    color: 'rgba(126,86,134,.9)',
    data: [140, 90, 40],
    pointPadding: 0.4,
  }, {
    name: 'Profit',
    color: 'rgba(248,161,63,1)',
    data: [183.6, 178.8, 198.5],
    tooltip: {
      valuePrefix: '$',
      valueSuffix: ' M'
    },
    pointPadding: 0.3,
    pointPlacement: 0.2,
    yAxis: 1
  }, {
    name: 'Profit Optimized',
    color: 'rgba(186,60,61,.9)',
    data: [203.6, 198.8, 208.5],
    tooltip: {
      valuePrefix: '$',
      valueSuffix: ' M'
    },
    pointPadding: 0.4,
    pointPlacement: 0.2,
    yAxis: 1
  }]
});