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>
<script src="https://cdn.flexmonster.com/lib/flexmonster.highcharts.js"></script>

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/drilldown.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>

<div>
  <h2>How to create a drillable bar chart</h2>
  <p>
  In integrations with charting libraries, Flexmonster serves as a data provider. If the chosen charting library supports drilling, you can create a drillable chart filled with data from Flexmonster. 
  </p>
  <p>
  The Highcharts library <a href="https://www.highcharts.com/docs/chart-concepts/drilldown" target="_blank">has drilling functionality</a>. To create a drillable Highcharts chart, use the <a href="https://www.flexmonster.com/doc/integration-with-highcharts/#withDrillDown" target="_blank">withDrilldown</a> option, which is provided by Flexmonster Connector for Highcharts. Specify <code>withDrilldown: true</code> (line 38 in the JavaScript box), and the Connector will prepare your data for a drillable chart.
  </p>
  <p>
  In the below chart, you can drill down the <code>Country</code> level to see more details.
  </p>
  <p>
  <a href="https://www.flexmonster.com/doc/integration-with-highcharts/" target="_blank">Visit our docs to learn more about the integration with Highcharts</a>.
  </p>
</div>

<div id="pivot-container"></div>

<div id="chartContainer"></div>

CSS

#chartContainer {
  margin: 20px;
}

h2 {
  text-align: center;
}

p {
  font-size: 15px;
  line-height: 1.5;
  padding-right: 10px;
  padding-left: 10px;
}

a {
  color: #00a45a;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
    font-size: 105%;
    color: #DF3800;
    background-color: #f5f5f5;
    padding: 1px 4px;
    font-family: monospace !important;
    border-radius: 4px;
}

JavaScript

let pivot = new Flexmonster({
  container: "#pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  licenseFilePath: "https://cdn.flexmonster.com/jsfiddle.charts.key",
  height: 270,
  report: {
    dataSource: {
      filename: "data/data.csv"
    },
    slice: {
      rows: [{
        uniqueName: "Country",
        filter: {
          exclude: ["France", "United States"]
        }
      }],
      columns: [{
          uniqueName: "Business Type"
        },
        {
          uniqueName: "[Measures]"
        }
      ],
      measures: [{
        uniqueName: "Quantity"
      }]
    }
  },
  reportcomplete: function() {
    pivot.off("reportcomplete");
    createBarWithDrilldown();
  }
});

function getMeasuresForLog() {
  const measures = pivot.getAllMeasures().filter(x => x.type != "string");

  return measures.map(x => {
    return {
      uniqueName: x.uniqueName,
      caption: x.caption
    }
  })
}


function createBarWithDrilldown() {
  console.log('before getData', getMeasuresForLog())

  pivot.highcharts.getData({
      "type": "bar",
      "slice": {
        "measures": [{

          "uniqueName": "CalculatedMetric-1711537868597",
          "caption": "calc metric 1",
          "visible": true,
          "aggregation": "none",
          "formula": "sum(\"Price\") * 0.98734567",
          "individual": false,
          "calculateNaN": true,
          "format": "CalculatedMetric-1711537868597",
        }, ]
      }
    },
    createAndUpdateChart,
    createAndUpdateChart
  );

  console.log('getData 1', getMeasuresForLog())

  pivot.highcharts.getData({
      "type": "bar",
      "slice": {
        "measures": [{
            "uniqueName": "CalculatedMetric-1711537868597",
            "caption": "calc metric 1",
            "visible": true,
            "aggregation": "none",
            "formula": "sum(\"Price\") * 0.98734567",
            "individual": false,
            "calculateNaN": true,
            "format":...