amcharts / export

Apache License 2.0
56 stars 33 forks source link

Using my own buttons to invoke the export (outside of the chart) #81

Open morrow95 opened 6 years ago

morrow95 commented 6 years ago

I am trying to invoke export with my own buttons, outside of the chart, but am getting the following error :

TypeError: AmCharts.AmExport is not a constructor

I was using an example I found on stackoverflow at http://jsfiddle.net/BGuuT/2/ which works by the way, but doesn't seem to in my own implementation for some reason. Maybe I have a newer version?

I am including in my page :

amcharts-3.21.12/amcharts.js
amcharts-3.21.12/serial.js
amcharts-3.21.12/plugins/export/export.js

html is :

<ul id="chart-selector">
    <li class="dropdown-item" data-click="JPG">JPG</li>
    <li class="dropdown-item" data-click="PNG">PNG</li>
    <li class="dropdown-item" data-click="SVG">SVG</li>
    <li class="dropdown-item" data-click="CSV">CSV</li>
    <li class="dropdown-item" data-click="JSON">JSON</li>
    <li class="dropdown-item" data-click="PDF">PDF</li>
    <li class="dropdown-item" data-click="XLSX">XLSX</li>
    <li class="dropdown-item" data-click="PRINT">Print</li>
</ul>

I am getting the correct export value to pass here, but the constructor error still shows :

chart = AmCharts.makeChart("chart_chart", { .......... });

$('body').on('click', '#chart-selector .dropdown-item', function(e) {

    var test = $(this).data('click');

    //chart download action
    var exp = new AmCharts.AmExport(chart);
        exp.init();
        exp.output({
            format: test
        });
});

The only difference I can see between the mine and the link given is export.js compared to amexport_combined.js - the latter is not a file given in amcharts though. Ideas?

amcharts commented 6 years ago

New comment from Zendesk by Anthony Piris on ticket 37219. (replying here will automatically notify amCharts support agent)

Hi there,

I responded to your stackoverflow post here: https://stackoverflow.com/a/50629996/6106614

To summarize - the example you're referencing is using an old version of the plugin, which is why you get the undefined AmExport error. The examples I linked, along with the one I created should get you started. The export plugin documentation also talks about the API methods in more detail.

I hope this helps.

Best,

Anthony Piris amCharts

hshahul commented 3 years ago

Can you provide the any example in amchart4 as same like above?

Is it possible to call amchart export adaptor functionality in amcharts4 v?