highcharts / export-csv

Highcharts plugin to export chart data to CSV
http://www.highcharts.com/plugin-registry/single/7/Export-CSV
MIT License
76 stars 95 forks source link

CSV Export: a.Click() doen't work from a chart inside a overlay frame #111

Closed Kytrix closed 7 years ago

Kytrix commented 7 years ago

Hello

My highchart object is displayed inside a overlay frame of my document. after installing the plugins I was unable to download a csv or xls file. (but data were ok) The problem is the download of the csv file create an anchor inside the document itself, but the browser is not able to click it (because only the overlay frame is usable)

So I made a modification :

            a = document.createElement('a');
            a.href = href;
            a.target = '_blank';
            a.download = name + '.' + extension;
        //old not working from a overlay frame
            //document.body.appendChild(a);
        //write the anchor directly inside the chart container works
        chart.container.append(a);
            a.click();
            a.remove();

Instead of writing the anchor inside the document, I write it inside the chart's container.

Kytrix.

TorsteinHonsi commented 7 years ago

Thanks!

Kytrix commented 7 years ago

You are welcome :)

pmatiash commented 6 years ago

it's not working for me since chart.container is not a jquery object. It's not working also for their fiddle demo: https://jsfiddle.net/highcharts/cqjvD/ "TypeError: chart.container.append is not a function" So probably should be .appendChild() instead. https://github.com/highcharts/highcharts/pull/7065