Skip to content

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

@morrow95

Description

@morrow95

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions