Drillable bar chart

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/drilldown.js"></script>
<script src="https://code.highcharts.com/12.5.0/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

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

#chartContainer {
  margin: 20px;
}

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

function createBarWithDrilldown() {
  pivot.highcharts.getData(
  	{
      type: "bar",
      withDrilldown: true
    },
    createAndUpdateChart,
    createAndUpdateChart
  );
}

function createAndUpdateChart(chartConfig) {
  applyConfigs(chartConfig);
  chartConfig.title.text = "With Drilldown";
  Highcharts.chart('chartContainer', chartConfig);
}