JSFiddle - React, Tailwind, and code Playground

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>
<button onclick="setMapping()">
  Set mapping
</button>
<div id="pivot-container"></div>

JavaScript

var pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  height: 430,
  report: {
    dataSource: {
      data: getData(),
    },
    "slice": {
      "rows": [{
        "uniqueName": "Color"
      }],
      "columns": [{
        "uniqueName": "Date.Year"
      }],
      "measures": [{
        "uniqueName": "Price",
        "aggregation": "sum"
      }]
    }
  }
});

function setMapping() {
  report = flexmonster.getReport();
  report.dataSource.mapping = {
    "Color": {
      "type": "string"
    },
    "Price": {
      "type": "number"
    },
    "Date": {
      "type": "year/quarter/month/day",
    }
  }
  report.slice.columns = [{
    "uniqueName": "Date",
    "levelName": "Date.Quarter"
  }]
  flexmonster.setReport(report)
}

function getData() {
  return [{
      "Color": "green",
      "Price": 174,
      "Date": "2016-01-20T14:48:00"
    },
    {
      "Color": "red",
      "Price": 1664,
      "Date": "2016-08-20T14:48:00"
    },
    {
      "Color": "red",
      "Price": 1190,
      "Date": "2016-04-20T14:48:00"
    },
    {
      "Color": "green",
      "Price": 1222,
      "Date": "2016-12-20T14:48:00"
    },
    {
      "Color": "white",
      "Price": 7941,
      "Date": "2016-02-20T14:48:00"
    },
    {
      "Color": "red",
      "Price": 6829,
      "Date": "2016-01-20T14:48:00"
    },
    {
      "Color": "green",
      "Price": 2995,
      "Date": "2016-09-20T14:48:00"
    },
    {
      "Color": "white",
      "Price": 2471,
      "Date": "2016-07-20T14:48:00"
    },
    {
      "Color": "yellow",
      "Price": 6650,
      "Date": "2016-03-20T14:48:00"
    },
    {
      "Color": "blue",
      "Price": 865,
      "Date": "2016-07-20T14:48:00"
    },
    {
      "Color": "purple",
      "Price": 511,
      "Date": "2016-01-20T14:48:00"
    },
    {
      "Color": "blue",
      "Price": 981,
      "Date": "2016-11-20T14:48:00"
    },
  ];
}