Drag Column Chart - Getting data with getDataWithId method

Created using FusionCharts Suite XT - www.fusioncharts.com

by FusionCharts

HTML

<script src="https://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<script src="https://static.fusioncharts.com/code/latest/fusioncharts.charts.js"></script>
<script src="https://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js"></script>
<!-- Drag-able chart - Getting data through `getDataWithId` method. After rendering the chart we retrieve the data with `getDataWithId` method and display the data in a tabular format.

method:
    # getDataWithId
    
-->
<div id="indicatorDiv">Method Name: <b>getDataWithId()</b>
  
  <p>Returns a three-dimensional array that contains the data and the dataset IDs. Once the reference for the chart is obtained, this function can be invoked to data.</p>
  <p>The table rendered below the chart shows the data retrieved from the drag-able column 2D chart shown here.</p>

</div>

<div class="text-center">
	<div id="chart-container">FusionCharts will render here</div>
</div>
  <div id="tableCont">
    <table id="data-table">
    </table>
  </div>

CSS

body {
  font-family: "Arial", "Verdana", "sans";
  font-size: 80%;
}

body > div {
  /*only one in this sample */
  width: 600px;
}

strong{
  font-weight: bold;
}

.text-center {
  text-align: center;
}

p {
  margin: 10px auto;
}

.mb-20 {
  margin-bottom: 20px;
}

table {
  margin: 5px auto;
  border-collapse: collapse;
  border: 1px solid;
  border-bottom: 2px solid #6baa01;
}

th {
  background-color: #008ee4;
  color: #ffffff;
}

th,
td {
  border: 1px solid #6baa01;
  padding: 10px 5px;
  min-width: 70px;
  text-align: center;
}

#tableCont {
  width: 90%;
}

#tableCont table {
  width: 96%;
}

#indicatorDiv {
  width: 500px;
  font-family: 'Arial', 'Helvetica';
  font-size: 13px;
}

JavaScript

FusionCharts.ready(function() {
  var inventoryChart = new FusionCharts({
    type: 'dragcolumn2d',
    renderAt: 'chart-container',
    width: '500',
    height: '350',
    dataFormat: 'json',
    dataSource: {
      "chart": {
        "caption": "Inventory status - Bakersfield Central",
        "subCaption": "Top 5 Food items",
        "xAxisName": "Food Item",
        "yAxisName": "No. of Units",
        "theme": "fint"
      },
      "categories": [{
        "category": [{
          "label": "Poultry"
        }, {
          "label": "Rice"
        }, {
          "label": "Peanut Butter"
        }, {
          "label": "Salmon"
        }, {
          "label": "Cereal"
        }]
      }],
      "dataset": [{
        "seriesname": "Available Stock",
        "allowDrag": "0",
        "data": [{
          "id": "P_AS",
          "value": "6000"
        }, {
          "id": "R_AS",
          "value": "9500"
        }, {
          "id": "PB_AS",
          "value": "11900"
        }, {
          "id": "S_AS",
          "value": "8000"
        }, {
          "id": "C_AS",
          "value": "9700"
        }]
      }, {
        "seriesname": "Estimated Demand",
        "dashed": "1",
        "data": [{
          "id": "P_ED",
          "value": "19000"
        }, {
          "id": "R_ED",
          "value": "16500"
        }, {
          "id": "PB_ED",
          "value": "14300"
        }, {
          "id": "S_ED",
          "value": "10000"
        }, {
          "id": "C_ED",
          "value": "9800"
        }]
      }]
    },
    events: {
      'rendered': function(evt, arg) {
        var chartIns = evt && evt.sender,
          data = chartIns && chartIns.getDataWithId(),
          dataTable = document.getElementById("data-table"),
          i,
          j,
          len = data && data.length,
          len2,
          tableStr = "";

        for (i = 0; i < len; i += 1) {
          tableStr += "<tr>";
          len2 = data[i].length;
          for (j = 0; j <...