Flexmonster - Integration with Google Charts

Demos

by jesperra

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.googlecharts.js"></script>
<script src="https://www.gstatic.com/charts/loader.js"></script>

<div id="pivot-container" style="margin-bottom:50px;"></div>
<h2 style="text-align:center; margin-bottom:0px;">
  Income, Expenses, and Profit
</h2>
<div id="googlechart-container-1" style="height:350px; margin-bottom:50px;"></div>

<h2 style="text-align:center; margin-bottom:0px;">
  Top 5 Countries by Sales
</h2>

<div id="googlechart-container-2" style="height:350px;"></div>

CSS

@import url('https://fonts.googleapis.com/css?family=Poppins');

JavaScript

var pivot = new Flexmonster({
  container: "#pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  width: "100%",
  height: 350,
  toolbar: true,
  report: {
    "dataSource": {
      "type": "json",
      "data": getData()
    },
    "slice": {
      "rows": [{
        "uniqueName": "Date.Month"        
      },
      {
      	"uniqueName": "Date.Day"
      }],
      "columns": [{
        "uniqueName": "[Measures]"
      }],
      "measures": [{
          "uniqueName": "Income",
          "formula": "sum(\"Sales\") * sum(\"Unit Price\")",
          "individual": true,
          "caption": "Income",
          "format": "currency"
        },
        {
          "uniqueName": "Sales",
          "active": false,
          "format": "currency"
        },
        {
          "uniqueName": "Expenses",
          "format": "currency"
        },
        {
          "uniqueName": "Profit",
          "formula": "sum(\"Income\") - sum(\"Expenses\")",
          "individual": true,
          "caption": "Profit",
          "format": "currency"
        }
      ]
    },
    "formats": [{
        "name": "",
        "maxDecimalPlaces": 2
      },
      {
        "name": "currency",
        "decimalPlaces": 1,
        "currencySymbol": "$"
      }
    ],
    "options": {
      "grid": {
        "showHeaders": false
      },
      "showAggregationLabels": false
    }
  },

  reportcomplete: function() {
    pivot.off("reportcomplete");
    pivotTableReportComplete = true;
    createGoogleChart();
    createPieChart();

  }
});
var pivotTableReportComplete = false;
var googleChartsLoaded = false;

google.charts.load('current', {
  'packages': ['corechart', 'bar']
});
google.charts.setOnLoadCallback(onGoogleChartsLoaded);

function onGoogleChartsLoaded() {
  googleChartsLoaded = true;
  if (pivotTableReportComplete) {
    createGoogleChart();
    createPieChart();
  }
}

function createGoogleChart() {
  if (googleChartsLoaded) {
    pivot.googlecharts.getData({
      ...