export icon indicating copy to clipboard operation
export copied to clipboard

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

Open morrow95 opened this issue 6 years ago • 2 comments

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?

morrow95 avatar May 31 '18 15:05 morrow95

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

amcharts avatar May 31 '18 17:05 amcharts

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

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

hshahul avatar Feb 01 '21 22:02 hshahul