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="pivotContainer"></div>

JavaScript

const pivot = new Flexmonster({
  container: "pivotContainer",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  height: 530,
  global: {
    localization: "https://cdn.flexmonster.com/loc/pt.json"
  },
  customizeCell: customizeCell,
  report: {
    dataSource: {
      type: "api",
      url: "https://olap.flexmonster.com:9500",
      index: "fm-product-sales",
      concurrentRequests: true,
      mapping: {
        "Category": {
          type: "string",
          hierarchy: "Item"
        },
        "Size": {
          type: "string",
          hierarchy: "Item",
          parent: "Category",
        },
        "Color": {
          type: "string",
          hierarchy: "Item",
          parent: "Size"
        }
      }
    },
    localization: {
      "fieldsList": {
        "values": "Medidas"
      }
    },
    slice: {
      rows: [{
        uniqueName: "Country"
      }],
      columns: [{
        uniqueName: "Item",
        levelName: "Color"
      }, {
        uniqueName: "[Measures]"
      }],
      measures: [{
        uniqueName: "Price",
        aggregation: "sum"
      }]
    }
  }
});

function customizeCell(cell, data) {
  /*
  Check if only one measure is present and the cell is a non-empty column measure label
  */
  if (data.columns.length > 0 && data.hierarchy.levels && !data.measure && data.type === "header" && data.label !== "") {
    let hierarchySplitter = /\.\[|\]\.\[|\]/;
    let captions = data.member.parentMember.split(hierarchySplitter).reduce(
      (accumulator, currentValue) => accumulator + currentValue + " ",
      ""
    );
    captions = captions.slice(1)
    cell.text += "( " + captions + ")"

  }
}