FusionCharts - Showing / hiding chart value in Cylinder Gauge

Created using FusionCharts Suite XT - www.fusioncharts.com

by FusionCharts

HTML

<script src="https://cdn.fusioncharts.com/fusioncharts/latest/fusioncharts.js"></script>
<script src="https://cdn.fusioncharts.com/fusioncharts/latest/themes/fusioncharts.theme.fusion.js"></script>
<!-- Hiding chart value in Cylinder gauge showing the consumption of Diesel in Generator in Bakersfield Central outlet using attribute:

    # showValue - Whether to show/hide chart value. (Boolean 0/1)

-->
<div id="chart-container">FusionCharts will render here</div>
<div id="checkbox-container">
  <input type="checkbox" id="showVal">Show Value ?</input>
</div>

JavaScript

FusionCharts.ready(function() {
  var showValueCB = document.getElementById('showVal'),
    fuelWidget = new FusionCharts({
      type: 'cylinder',
      dataFormat: 'json',
      id: 'fuelMeter',
      renderAt: 'chart-container',
      width: '200',
      height: '350',
      dataSource: {
        "chart": {
          "theme": "fusion",
          "caption": "Diesel Level in Generator",
          "subcaption": "Bakersfield Central",
          "lowerLimit": "0",
          "upperLimit": "120",
          "lowerLimitDisplay": "Empty",
          "upperLimitDisplay": "Full",
          "numberSuffix": " ltrs",
          "showValue": "0",
          "chartBottomMargin": "25"
        },
        "value": "75"
      }
    }).render();
  //Set event listener for check boxes
  showValueCB.addEventListener && showValueCB.addEventListener("click", showValue);
  //Function to show/hide value
  function showValue(evt, obj) {
    //Using showValue attribute to show hide gauge value
    if (showVal.checked) {
      fuelWidget.setChartAttribute('showValue', 1);
    } else {
      fuelWidget.setChartAttribute('showValue', 0);
    }
  }
});