Flexmonster - Highcharts barstack chart

by Ian Sadovy

HTML

<script src="https://s3.amazonaws.com/flexmonster/2.3/flexmonster.js"></script>
<link rel="stylesheet" href="https://s3.amazonaws.com/flexmonster/2.3/demo.css">
<script src="https://s3.amazonaws.com/flexmonster/2.3/lib/flexmonster.highcharts.js"></script>
<script src="https://code.highcharts.com/4.2.2/highcharts.js"></script>

<div id="pivot-container"></div>
<div id="highcharts-container" style="width: 100%; height: 300px; display: inline-block;"></div>

JavaScript

var pivot = $("#pivot-container").flexmonster({
  report: {
    dataSource: {
      dataSourceType: "json",
      filename: "data/data.json"
    },
    slice: {
      rows: [{
        uniqueName: "Country"
      }],
      columns: [{
        uniqueName: "Business Type"
      }, {
        uniqueName: "[Measures]"
      }],
      measures: [{
        uniqueName: "Quantity"
      }],
    },
    options: {
      viewType: "grid",
      configuratorActive: false,
      grid: {
        type: "compact"
      }
    }
  },
  height: 226,
  toolbar: true,
  componentFolder: "https://s3.amazonaws.com/flexmonster/2.3/",
  reportcomplete: function() {
    pivot.off("reportcomplete");
    createBarstack();
  }
});

function createBarstack() {
  pivot.highcharts.getData({
    type: "bar"
  }, renderChart, renderChart);
}

function renderChart(data) {
  data.plotOptions = {
    series: {
      stacking: 'normal'
    }
  };
  $("#highcharts-container").highcharts(data);
}