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>
<button onclick="highlight()">Highlight</button>
<button onclick="removeHighlight()">Remove Highlight</button>
<div id="pivot-container"></div>

CSS

.highlight {
  background: #c9f364 !important;
}

JavaScript

var pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  customizeCell: customizeCellFunction,
  report: {
    dataSource: {
      data: getData()
    },
    slice: {
      rows: [{
        uniqueName: "Time"
      }],
      columns: [{
          uniqueName: "Event"
        },
        {
          uniqueName: "[Measures]"
        }
      ],
      measures: [{
        uniqueName: "Price",
        aggregation: "sum"
      }]
    }
  }
});

function customizeCellFunction(cell, data) {
  console.log(data);
  if (data.hierarchy && data.hierarchy.uniqueName == "Time") {
    cell.addClass("highlight");
  }
}

function highlight() {
  pivot.customizeCell(customizeCellFunction);
}

function removeHighlight() {
  pivot.customizeCell(null);
}

function getData() {
  return [{
      "Event": "Event 1",
      "Time": "00:00:00",
      "Price": 20
    },
    {
      "Event": "Event 2",
      "Time": "00:20:00",
      "Price": 25
    },
    {
      "Event": "Event 2",
      "Time": "04:20:00",
      "Price": 40
    }
  ];
}