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 class="text">
  Click on a value cell to see the cell's details.<br /><br />
  In the output below, you can see the column, measure, and row details of the clicked cell in the "columns", "measure", and "rows" sections of the <a href="https://www.flexmonster.com/api/cell-object/" target="_blank" rel="noopener noreferrer">Cell Data Object</a>.
</h3>
<div id="pivot-container"></div>

<div class="output" id="output">Output will appear here</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;
}

.text {
  padding: 10px;
}

JavaScript

new Flexmonster({
  container: "#pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  width: "100%",
  height: 550,
  toolbar: true,
  report: {
    "dataSource": {
      "type": "api",
      "url": "https://olap.flexmonster.com:9500",
      "index": "fm-product-sales"
    },
    "slice": {
      "rows": [{
        "uniqueName": "Category"
      }],
      "columns": [{
          "uniqueName": "Color"
        },
        {
          "uniqueName": "[Measures]"
        }
      ],
      "measures": [{
        "uniqueName": "Price",
        "aggregation": "sum"
      }]
    }
  }
});

flexmonster.on("cellclick", onCellClick);

function onCellClick(cell) {
  showOutput(JSON.stringify(cell, null, 4));
}

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