JSFiddle - React, Tailwind, and code Playground

by Flexmonster Pivot Table

HTML

<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

<button onclick="customCaption()">Custom Caption</button> - Set a custom caption for the 'salesperson' hierarchy;
<br>
<button onclick="captionFromValue()">Caption from Value</button> - Set the 'businessarea' hierarchy caption to the value of 'businessarealabel' hierarchy member;
<div id="pivotContainer"></div>

JavaScript

var jsonData = [{
    "salesperson": "Jeremy",
    "businessarea": "Cape Town",
    "businessarealabel": "Cost Centre 1"
  },
  {
    "salesperson": "Adriana",
    "businessarea": "Johannesburg",
    "businessarealabel": "Cost Centre 2"
  },
  {
    "salesperson": "Elon",
    "businessarea": "Pretoria",
    "businessarealabel": "Cost Centre 3"
  }
]

var pivot = new Flexmonster({
  container: "pivotContainer",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  height: 700,
  report: {
    dataSource: {
      data: jsonData,
      mapping: {
        "salesperson": {
          type: "string"
        },
        "businessarea": {
          type: "string"
        },
        "businessarealabel": {
          type: "string"
        }
      },
    },
    "slice": {
      "rows": [{
        "uniqueName": "salesperson"
      }],
      "columns": [{
          "uniqueName": "businessarea"
        },
        {
          "uniqueName": "businessarealabel"
        },
        {
          "uniqueName": "[Measures]"
        }
      ],
      "measures": [{
        "uniqueName": "salesperson",
        "aggregation": "count"
      }],
      "expands": {
        "columns": [{
            "tuple": [
              "businessarea.[cape town]"
            ]
          },
          {
            "tuple": [
              "businessarea.[johannesburg]"
            ]
          },
          {
            "tuple": [
              "businessarea.[pretoria]"
            ]
          }
        ]
      }
    },
    "options": {
      "grid": {
        "showTotals": "off",
        "showGrandTotals": "off"
      },
      "fieldListPosition": "right"
    },

  }
});

function customCaption() {
  let newCaption = prompt("Enter the new caption")
  let newReport = pivot.getReport();
  newReport.dataSource.mapping.salesperson = {
    type: "string",
    caption: newCaption
  };
  pivot.setReport(newReport);
}

function captionFromValue() {
  let newReport = pivot.getReport();
 ...