Column chart

Integration with Highcharts

by Flexmonster Pivot Table

HTML

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

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>

<div id="pivot-container"></div>
<br/>
<div id="highcharts-container"></div>

JavaScript

var pivot = new Flexmonster({
  container: "#pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  licenseFilePath: "https://cdn.flexmonster.com/jsfiddle.charts.key",
  toolbar: true,
  report: {
    dataSource: {
      dataSourceType: "json",
      data: getData()
    },
    slice: {
      rows: [{
        uniqueName: "Country"
      }, {
        uniqueName: "[Measures]"
      }],
      columns: [{
        uniqueName: "Category"
      }],
      measures: [{
        uniqueName: "Price",
        aggregation: "percentofcolumn",
        format: 'percentage'
      }]
    },
    options: {
      viewType: "charts",
      configuratorActive: false
    },
    formats: [{
      name: 'percentage',
      currencySymbol: "%",
      decimalPlaces: 2
    }]
  },
  height: 400,
  reportcomplete: function() {
    pivot.off("reportcomplete");
    createChart();
  },
  reportchange: function() {
    pivot.off("reportcomplete");
    createChart();
  }
});

function createChart() {
  pivot.highcharts.getData({
      type: "column"
    },
    createAndUpdateChart,
    createAndUpdateChart
  );
}

function createAndUpdateChart(data, rawData) {
  if (data.yAxis == undefined) data.yAxis = [];
  if (data.yAxis[0] == undefined) data.yAxis[0] = {};
  data.yAxis[0].labels = {
    format: pivot.highcharts.getAxisFormat(rawData.meta.formats[0])
  }
  data.tooltip = {
    headerFormat: '{point.key}<br/><b>{series.name}</b><br/>',
    pointFormat: pivot.highcharts.getPointYFormat(rawData.meta.formats[0])
  };
  Highcharts.chart('highcharts-container', data);
}

function getData() {
  return [{
    "Country": "Australia",
    "Category": "Accessories",
    "Price": 445,
    "Quantity": 464
  }, {
    "Country": "Australia",
    "Category": "Bikes",
    "Price": 665,
    "Quantity": 440
  }, {
    "Country": "France",
    "Category": "Clothing",
    "Price": 190,
    "Quantity": 310
  }, {
    "Country": "United States",
    "Category": "Components",
    "Price": 406,
   ...