amcharts / amcharts3

JavaScript Charts V3
Other
395 stars 129 forks source link

Global settings #215

Open rinatio opened 5 years ago

rinatio commented 5 years ago

We're looking into how to enable AmCharts exporting here: http://www.amcharts.com/kbase/intro-exporting-charts/ and it says that config needs to be updated like this:

        "export": {
          "enabled": true
        }

Is it possible to specify this globally so all charts will have export enabled unless it is explicitly disabled?

martynasma commented 5 years ago

Yes:

AmCharts.addInitHandler(function(chart) {
  chart["export"].enabled = chart["export"] == undefined || chart["export"] != false;
});
rinatio commented 5 years ago

thanks @martynasma! can you tell if it's possible to do with amcharts3-react? It gives an error TypeError: Cannot set property 'enabled' of undefined

martynasma commented 5 years ago

@Pauan Can you elaborate? I personally don't have experience with React.

Pauan commented 5 years ago

@martynasma It should work the same in amcharts3-react, your init handler was just a bit wrong:

AmCharts.addInitHandler(function(chart) {
  if (chart["export"] == null) {
    chart["export"] = {};
  }

  if (chart["export"].enabled == null) {
    chart["export"].enabled = true;
  }
});
rinatio commented 5 years ago

@Pauan Doesn't seem to be working. Investigating.