JSFiddle - React, Tailwind, and code Playground

Options

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

JavaScript

let pivot = new Flexmonster({
  container: "pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  toolbar: true,
  report: {
    dataSource: {
      data: getData(),
    },
    options: {
      editing: true,
      showAggregationLabels: false,
    },
    slice: {
      rows: [{ uniqueName: "Color" }],
      columns: [{ uniqueName: "[Measures]" }],
      measures: [
        { uniqueName: "Quantity" },
        { uniqueName: "Price" },
        { uniqueName: "Total", formula: "sum('Price')*sum('Quantity')" },
      ],
    },
  },
})

function getData() {
  return [
    {
      Color: "green",
      Country: "Canada",
      State: "Ontario",
      City: "Toronto",
      Price: 100,
      Quantity: 4,
    },
    {
      Color: "green",
      Country: "Canada",
      State: "Ontario",
      City: "Toronto",
      Price: 50,
      Quantity:6,
    },
    {
      Color: "red",
      Country: "USA",
      State: "California",
      City: "Los Angeles",
      Price: 10,
      Quantity: 30,
    },
    {
      Color: "red",
      Country: "USA",
      State: "California",
      City: "Los Angeles",
      Price: 1,
      Quantity: 3,
    },
  ]
}