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="getReport()">
  GET REPORT
</button>
<button onclick="setReport()">
  SET REPORT
</button>

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

<div class="output" id="output">Report will appear here.<br>Press GET REPORT button to see the report.</div>

CSS

.output {
  width: 80%;
  height: 300px;
  margin-left: auto;
  margin-right: auto;
  padding: 20px;
  background: rgba(242, 242, 242, 1);
  font-family: Menlo, Monaco, "Courier New", Courier, monospace;
  white-space: pre;
  font-size: 16px;
  font-weight: 400;
  overflow-y: scroll;
  margin-top: 20px;
}

JavaScript

let pivot = new Flexmonster({
  container: "#pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  width: "100%",
  height: 300,
  toolbar: true,
  report: {
    "dataSource": {
      "type": "json",
      "filename": "https://cdn.flexmonster.com/data/retail-data.json",
      "mapping": {
        "Price": {
          "type": "number"
        },
        "Order Date": {
          "type": "year/quarter/month/day"
        },
        "Status": {
          "type": "string"
        },
        "Country": {
          "type": "string"
        }

      }
    },
    "slice": {
      "rows": [{
          "uniqueName": "Country",
          "caption": "Exporter" 
          /*Caption is defined in slice*/
        },
        {
          "uniqueName": "Status",
        }
      ],
      "columns": [{
          "uniqueName": "Order Date"
        },
        {
          "uniqueName": "[Measures]"
        }
      ],
      "measures": [{
        "uniqueName": "Price",
        "aggregation": "sum"
      }]
    }
  }
});

let report = null;

function getReport() {
  report = pivot.getReport();
  showOutput(JSON.stringify(report,null,4));
  /*
  Flexmonster changed the report object and moved caption to   mapping.
  */
}

function setReport() {
  if (report == null) {
    alert("getReport wasn't called yet")
    return;
  }
  pivot.setReport(report);
}

function showOutput(content) {
  document.getElementById("output").innerText = content;
}