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="updateJSONData()">Update Data</button>
<div id="pivot-container"></div>

JavaScript

var pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  report: {
    dataSource: {
      mapping: {
        "Color": {
          caption: "MyColor"
        },
        "Country": {
          caption: "MyCountry",
        },
        "State": {
          caption: "MyState",
        },
        "City": {
          caption: "MyCity",
        },
        "Price": {
          type: "number",
          caption: "MyPrice"
        },
        "Quantity": {
          type: "number",
          caption: "MyQuantity"
        }
      },
      data: getData()
    },
    slice: {
      rows: [{
        "uniqueName": "City"
      }],
      columns: [{
        "uniqueName": "[Measures]"
      }],
      measures: [{
          "uniqueName": "Price",
          "aggregation": "sum"
        },
        {
          "uniqueName": "Quantity",
          "aggregation": "sum"
        }
      ]
    }
  }
});

function updateJSONData(){
   var jsonData = [{
          "Color": "green",
          "Country": "Canada",
          "State": "Ontario",
          "City": "Toronto",
          "Price": 174,
          "Quantity": 22
        },
        {
          "Color": "red",
          "Country": "USA",
          "State": "California",
          "City": "Los Angeles",
          "Price": 166,
          "Quantity": 19
        },
        {
          "Color": "blue",
          "Country": "USA",
          "State": "California",
          "City": "Los Angeles",
          "Price": 90,
          "Quantity": 10
        },
        {
          "Color": "green",
          "Country": "Canada",
          "State": "Ontario",
          "City": "Toronto",
          "Price": 190,
          "Quantity": 30
        }
      ];
   pivot.updateData({ data: jsonData });
}

function getData(){
   return [{
          "Color": "green",
          "Country": "Canada",
          "State": "Ontario",
          "City": "Toronto",
          "Price": 174,
         ...