Stacked column + line chart with multiple series

Integration with Highcharts

by Flexmonster Pivot Table

HTML

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

<div>
  <h2>How to create a stacked column + line 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"></div>
<div id="highcharts-container"></div>

CSS

@import url(https://cdn.flexmonster.com/assets/jsfiddle-styles.css);

#highcharts-container {
  margin: 20px;
}

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 applyConfigs(config) {
  config.chart.style = {
    fontSize: "18px",
    fontFamily: "Arial, sans-serif"
  };
}


function createStackedColumnLineChart() {
  pivot.highcharts.getData({
      prepareDataFunction: function(data, options) {
        let output = {
          chart: {
            zoomType: 'xy'
          },
          title: {
            text: 'Hedging ratio',
            align: 'center'
          },
          xAxis: [{
            categories: [],
           ...