JSFiddle - React, Tailwind, and code Playground

by juvian

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/",
  width: "100%",
  height: 430,
  toolbar: true,
  report: {
    dataSource: {
      data: getData(),
      mapping: {
        "Date": {
          caption: "Flight Date",
          type: "year/month/day"
        },
        "Price": {
          caption: "Price",
          type: "number"
        }
      }
    },
    "slice": {
      "rows": [{
        "uniqueName": "Date",
        "levelName": "Date.Year"
      }],
      "columns": [{
        "uniqueName": "[Measures]"
      }],
      "measures": [{
        "uniqueName": "Price",
        "aggregation": "sum"
      }],
      "drills": {
        "rows": [{
            "tuple": [
              "date.[2021]"
            ]
          },
          {
            "tuple": [
              "date.[2020]"
            ]
          }
        ]
      }
    }
  }
});

function getData() {
  return [{
    "Date": "2021-01-11",
    "Price": 5477
  }, {
    "Date": "2020-11-03",
    "Price": 2455
  }, {
    "Date": "2021-03-19",
    "Price": 2457
  }, {
    "Date": "2021-05-09",
    "Price": 4367
  }];
}