FusionCharts - Configuring anchors visibility in Sparkline chart

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>
<!-- Configure open, close, high/low anchors visibility in SparkLine chart using attributes:

    # showOpenAnchor - Whether to show anchor for opening value
    # showCloseAnchor - Whether to show anchor for closing value
    # showHighAnchor - Whether to show anchor for high value
    # showLowAnchor	- Whether to show anchor for low value

-->
<div id="chart-container">FusionCharts will render here</div>

<div id="checkbox-container">
  <input type="checkbox" id="open">Show Open Anchor ?</input>
  <input type="checkbox" id="close">Show Close Anchor ?</input>
  <input type="checkbox" id="high">Show High Anchor ?</input>
  <input type="checkbox" id="low">Show Low Anchor ?</input>
</div>

CSS

#checkbox-container {
  margin-top: 10px;
  width: 400px;
}

body {
  font-family: 'Helvetica Neue', Arial;
  font-size: 11px;
  font-weight: normal;
}

JavaScript

FusionCharts.ready(function() {
  var openCB = document.getElementById('open'),
    closeCB = document.getElementById('close'),
    highCB = document.getElementById('high'),
    lowCB = document.getElementById('low'),
    //Function to show/hide anchors
    showAnchor = function(evt) {
      //Storing the attributes names to get the names dynamically
      var attrbObj = {
          open: 'showOpenAnchor',
          close: 'showCloseAnchor',
          high: 'showHighAnchor',
          low: 'showLowAnchor'
        },
        attrbName = attrbObj[evt.target.id];
      (evt.target.checked) ? stockPriceChart.setChartAttribute(attrbName, 1): stockPriceChart.setChartAttribute(attrbName, 0);
    },
    stockPriceChart = new FusionCharts({
      type: 'sparkline',
      renderAt: 'chart-container',
      width: '450',
      height: '70',
      dataFormat: 'json',
      dataSource: {
        "chart": {
          "theme": "fusion",
          "caption": "Stock Price",
          "subcaption": "Last month",
          "numberPrefix": "$",
          "chartBottomMargin": "30",
          "showOpenAnchor": "0",
          "showCloseAnchor": "0",
          "showHighAnchor": "0",
          "showLowAnchor": "0"
        },
        "dataset": [{
          "data": [{
              "value": "38.42"
            },
            {
              "value": "41.43"
            },
            {
              "value": "34.78"
            },
            {
              "value": "40.67"
            },
            {
              "value": "44.12"
            },
            {
              "value": "38.45"
            },
            {
              "value": "40.71"
            },
            {
              "value": "49.90"
            },
            {
              "value": "40.12"
            },
            {
              "value": "34.91"
            },
            {
              "value": "42.02"
            },
            {
              "value": "35.21"
            },
            {
             ...