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>

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

JavaScript

var jsonData = [{
    "Fruit": {
      "type": "string"
    },
    "Shop": {
      "type": "string"
    },
    "Quantity": {
      "type": "number"
    }
  },
  {
    "Fruit": "apple",
    "Shop": "shop 1",
    "Quantity": 124
  },
  {
    "Fruit": "banana",
    "Shop": "shop 2",
    "Quantity": 435
  },
  {
    "Fruit": "mango",
    "Shop": "shop 3",
    "Quantity": 190
  },
  {
    "Fruit": "carambole",
    "Shop": "shop 1",
    "Quantity": 12
  }
];

var pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  customizeCell: customizeCellFunction,
  report: {
    dataSource: {
      data: jsonData
    },
    slice: {
      rows: [{
          uniqueName: "Color"
        },
        {
          uniqueName: "Fruit"
        }
      ],
      columns: [{
        uniqueName: "[Measures]"
      }],
      measures: [{
        uniqueName: "Quantity"
      }]
    },
  }
});

function customizeCellFunction(cell, data) {
  if (data && data.type == "value" &&
    data.measure && data.measure.uniqueName == "Quantity" &&
    data.rows && data.rows[0]) {
    cell.text = data.rows[0].caption + " (" + cell.text + ")";
  }
}