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">The component 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;
}

JavaScript

let pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  customizeCell: customizeCellFunction,
  report: {
    dataSource: {
      data: getData()
    },
    slice: {
      rows: [{
        uniqueName: "actionType",
      }],
      columns: [{
        uniqueName: "[Measures]"
      }],
      measures: [{
          "uniqueName": "Price"
        },
        {
          uniqueName: "Calculated",
          formula: "if(max('actionType') = 1, count('actionType') * 25, 0) or (if(max('actionType') = 2, count('actionType') * 40, 0) or (if(max('actionType') = 3, count('actionType') * 72, 0)"
        }
      ]
    }
  }
});


function customizeCellFunction(cell, data) {
  if (data && data.hierarchy && data.hierarchy.uniqueName === "actionType") {
    if (data.label === "1") {
      cell.text = "X"
    } else if (data.label === "2") {
      cell.text = "Y"
    } else if (data.label === "3") {
      cell.text = "Z"
    }
  }
}

function getData() {
  return [{
    actionType: 1,
    Price: 25
  }, {
    actionType: 1,
    Price: 25
  }, {
    actionType: 1,
    Price: 25
  }, {
    actionType: 1,
    Price: 25
  }, {
    actionType: 1,
    Price: 25
  }, {
    actionType: 1,
    Price: 25
  }, {
    actionType: 1,
    Price: 25
  }, {
    actionType: 2,
    Price: 40
  }, {
    actionType: 2,
    Price: 40
  }, {
    actionType: 2,
    Price: 40
  }, {
    actionType: 2,
    Price: 40
  }, {
    actionType: 2,
    Price: 40
  }, {
    actionType: 2,
    Price: 40
  }, {
    actionType: 3,
    Price: 72
  }, {
    actionType: 3,
    Price: 72
  }, {
    actionType: 3,
    Price: 72
  }, {
    actionType: 3,
    Price: 72
  }, {
    actionType: 3,
    Price: 72
  }, {
    actionType: 3,
    Price: 72
  }, {
    actionType: 3,
    Price: 72
  }, {
    actionType: 3,
    Price: 72
  }, ]
}