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>

<h3>
  1. Try changing the initial configuration (e.g., move the "Color" field to columns). <br>
  2. Click "Update Data" button. You will see that the configuration is not changed, only the data is updated. <br>
  3. Click "Set Report" button. You will see that the configuration is reset to the default slice and the data is updated.
</h3>

<button onclick="updateData()">
  Update Data
</button>

<button onclick="setReport()">
  Set Report
</button>

<div id="pivotContainer"></div>

JavaScript

var pivot = new Flexmonster({
  container: "pivotContainer",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  report: {
    dataSource: {
      data: getInitialData()
    },
    options: {
      grid: {
        type: 'classic'
      },
      datePattern: 'dd/MM/yyyy HH:mm:ss'
    }
  }
});

function updateData() {
  flexmonster.updateData({
    data: getDataForUpdate()
  });
}

function setReport() {
  flexmonster.setReport({
    dataSource: {
      data: getNewData()
    },
    options: {
      grid: {
        type: 'classic'
      },
      datePattern: 'dd/MM/yyyy HH:mm:ss'
    }
  });
}

function getInitialData() {
  return [{
      "Color": "white",
      "Month": "March",
      "Week Day": "Wed",
      "Price": 7941
    },
    {
      "Color": "red",
      "Month": "August",
      "Week Day": "Wed",
      "Price": 6829
    },
    {
      "Color": "green",
      "Month": "January",
      "Week Day": "Wed",
      "Price": 2995
    },
    {
      "Color": "white",
      "Month": "February",
      "Week Day": "Mon",
      "Price": 2471
    }
  ]
}

function getDataForUpdate() {
  return [{
      "Color": "white",
      "Month": "March",
      "Week Day": "Wed",
      "Price": 6578
    },
    {
      "Color": "red",
      "Month": "August",
      "Week Day": "Wed",
      "Price": 1254
    },
    {
      "Color": "green",
      "Month": "January",
      "Week Day": "Wed",
      "Price": 3467
    },
    {
      "Color": "white",
      "Month": "February",
      "Week Day": "Mon",
      "Price": 9546
    }
  ]
}

function getNewData() {
  return [{
      "Country": "USA",
      "State": "California",
      "City": "Los Angeles",
      "Quantity": 73
    },
    {
      "Country": "Canada",
      "State": "Ontario",
      "City": "Toronto",
      "Quantity": 19
    },
    {
      "Country": "Canada",
      "State": "Quebec",
      "City": "Montreal",
      "Quantity": 98
    },
    {
      "Country": "USA",
      "State": "California",
     ...