Skip to content Skip to sidebar Skip to footer

Amcharts Removing Columns From Dataprovider With Validatedata() Not Working

I recently asked about a way to hide columns in AmCharts using hide/show buttons, and it worked pretty well. However, I am now separating functions into different files to create a

Solution 1:

This probably has to do with recreating the chart every time displayAmCharts is called. It is unneccessary and will get amCharts confused. I would define chart as a global variable and only create the chart once.

Your globals

var hiddenValues = [];
var dataProviderVals;
var chart = null; // chart as global variable

displayAmCharts function

functiondisplayAmCharts(additionalData){

  var graphsVals = graphValues;
  dataProviderVals = dataValues;

  // create chart only onceif(chart == null){

    chart = AmCharts.makeChart("chartdiv", {
      "type": "serial",
      "dataProvider": dataProviderVals,
      // ...
    });

  }

  if(additionalData != undefined){
    // Replace the dataProvider with additionalData from hideValue and redraw the chart.
    chart.dataProvider = additionalData;
    chart.validateData();
  }

  // ...

}

That should solve the issue :-)

Post a Comment for "Amcharts Removing Columns From Dataprovider With Validatedata() Not Working"