Highcharts Demo

author(s): Torstein Hønsi

by anikettiwari

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-3d.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>

<div id="container" style="height: 400px"></div>

CSS

#container {
  height: 400px;
  min-width: 310px;
  max-width: 800px;
  margin: 0 auto;
}

JavaScript

Highcharts.chart('container', {
  chart: {
    type: 'bar',
    events: {
      load: function() {

        var chart = this,
          minColHeightVal = 100;

        chart.series.forEach(function(s) {
          s.points.forEach(function(p) {
						console.log(p.y)
            if (p.y < minColHeightVal) {
              p.update({
                y: minColHeightVal,
                realValue: p.y
              }, false);
            }
          });
        });

        chart.redraw();

      }
    },
   /*  options3d: {
      enabled: true,
      alpha: 15,
      beta: 15,
      viewDistance: 25,
      depth: 40
    } */
  },

  title: {
    text: 'Total fruit consumption, grouped by gender'
  },

  xAxis: {
    categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas'],
    labels: {
      skew3d: true,
      style: {
        fontSize: '16px'
      }
    }
  },

  yAxis: {
    allowDecimals: false,
    min: 0,
    title: {
      text: 'Number of fruits',
      skew3d: true
    }
  },

  tooltip: {
    headerFormat: '<b>{point.key}</b><br>',
    //pointFormat: '<span style="color:{series.color}">\u25CF</span> {series.name}: {point.y} / {point.stackTotal}'

    pointFormatter: function() {
      var stackSum = 0,
        point = this,
        chart = point.series.chart;

      chart.series.forEach(function(s) {
        s.points.forEach(function(p) {
          if (p.x === point.x) {
            stackSum += p.realValue ? p.realValue : p.y
          }
        });
      });

      return '<span style="color:' + this.color + '">\u25CF</span> ' + this.series.name + ': ' + (point.realValue ? point.realValue : point.y) + ' / ' + stackSum;

    }
  },

  plotOptions: {
    column: {
      stacking: 'normal',
      depth: 40
    }
  },

  series: [{
      name: 'John',
      data: [500, 3, 4, 7, 2], //If change 500 to 5, all blocks will be shown
      stack: 'male'
    }, {
      name: 'Joe',
      data: [300, 4, 4, 2, 5], //change 300 to 3
      stack: 'male'
    },

...