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/series-label.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>

<div>
  <h2>How to create a stacked column chart with multiple series</h2>
  <p>
  Flexmonster Connector for Highcharts can prepare your data for the <a href="https://www.flexmonster.com/doc/integration-with-highcharts/#!supported-charts" target="_blank">predefined set of charts</a>. To create a chart that's not in this list, you need to preprocess your data manually. It can be done using the <a href="https://www.flexmonster.com/doc/integration-with-highcharts/#!prepareDataFunction" target="_blank">prepareDataFunction</a> provided by the Connector for Highcharts.
  </p>
  <p>
    In this example, we've created a stacked column + line chart with multiple series. Check out lines 68-244 in the JavaScript box to see how the <code>prepareDataFunction</code> is defined for this chart.
  </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">Flexmonster will appear here</div>

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

CSS

#highcharts-container {
  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: 300,
  report: {
    dataSource: {
      dataSourceType: "json",
      data: getData()
    },
    options: {
      showAggregationLabels: false
    },
    slice: {
      rows: [{
        uniqueName: "Month",
        filter: {
          members: [
            "month.[jan]", "month.[feb]", "month.[mar]",
            "month.[apr]", "month.[may]", "month.[jun]"
          ]
        }
      }],
      columns: [{
        uniqueName: "[Measures]"
      }],
      measures: [{
          uniqueName: "Physical Delivery",
          aggregation: "sum"
        },
        {
          uniqueName: "Financial Hedges",
          aggregation: "sum"
        },
        {
          uniqueName: "Options Delta",
          aggregation: "sum"
        },
        {
          uniqueName: "Open Position",
          aggregation: "sum"
        },
        {
          uniqueName: "Min",
          aggregation: "sum"
        },
        {
          uniqueName: "Max",
          aggregation: "sum"
        },
        {
          uniqueName: "Nominal Options",
          aggregation: "sum"
        }
      ]
    },
  },
  reportcomplete: function() {
    pivot.off("reportcomplete");
    createStackedColumnLineChart();
  }
});


function createStackedColumnLineChart() {
  pivot.highcharts.getData({
      prepareDataFunction: function(data, options) {
        let output = {
          chart: {
            zoomType: 'xy'
          },
          title: {
            text: 'Hedging ratio',
            align: 'center'
          },
          xAxis: [{
            categories: [],
            crosshair: true
          }],
          yAxis: [{
              gridLineWidth: 0,
              title: {},
              labels: {
                format: '{value} %',
              }
            },
            {
             ...