It is currently Mon Sep 24, 2018 2:50 am Advanced search

format export csv

Technical support, bug reports and more.

format export csv

Postby abutler » Tue Feb 20, 2018 5:43 pm

Hello,
I have a column range chart and would like to export the data differently than what the default dataset is. Specifically, we want a user to be able to download the axis labels for x values and a total value for the y values instead of the default category 0,1,2,3... and the data as low and high values. Do you have the ability to change this somewhere?
Thanks,
Alyssa
abutler
 
Posts: 18
Joined: Thu Jan 18, 2018 12:06 pm

Re: format export csv

Postby cosy » Tue Feb 20, 2018 6:54 pm

Hi Alyssa!

You have to create a second hidden chart with the preferred series data structure and use this hidden chart to export to CSV.

Best regards,
Sophie
cosy
 
Posts: 118
Joined: Fri Feb 02, 2018 12:22 pm

Re: format export csv

Postby abutler » Mon Apr 16, 2018 4:08 pm

Hello Sophie,
Thanks for your help! Sorry for the delayed response but I am just now getting around to having time to work on this and I have a follow up question...

What about if I still want the user to be able to download images of the first non-hidden graph? With your recommendation I now have to have two download buttons?

Thanks,
Alyssa
abutler
 
Posts: 18
Joined: Thu Jan 18, 2018 12:06 pm

Re: format export csv

Postby cosy » Mon Apr 16, 2018 5:41 pm

Hello Alyssa!

There is no need for a second menu. You can define your own buttons in the visible chart menu: http://jsfiddle.net/uecop7qc/
Code: Select all
var chart = Highcharts.chart('container', {
    exporting: {
        buttons: {
            contextButton: {
                menuItems: ['customButton']
            }
        },
        menuItemDefinitions: {
            'customButton': {
                onclick: function() {
                    alert('Hello!');
                },
                text: 'Hello'
            }
        }
    },
    [...]
});

See the documentation: https://api.highcharts.com/highcharts/e ... .menuItems

The export for the hidden chart can be triggered with the exportChart function on the chart reference.
Code: Select all
hiddenChart.exportChart(...);

See the documentation: https://api.highcharts.com/class-refere ... xportChart for the possible export options.

Best regards,
Sophie
cosy
 
Posts: 118
Joined: Fri Feb 02, 2018 12:22 pm

Re: format export csv

Postby abutler » Thu Apr 26, 2018 3:50 pm

Hello again Sophie,
Thanks for this, it is very helpful! However, I am still confused as to how to export the data? From the documentation, it appears that the exportChart() is for the export module of images and not the data-export module for data. I tried getCSV but it is also not working. Sorry if I am missing something obvious, but what would you pass to exportChart() to specify a csv or excel download?
Thanks!
Alyssa
abutler
 
Posts: 18
Joined: Thu Jan 18, 2018 12:06 pm

Re: format export csv

Postby cosy » Fri Apr 27, 2018 10:38 am

Hello Alyssa!

The correct chart function for CSV is called downloadCSV(). Here are the function names of the default exporting menu:
Code: Select all
// part of exporting module
chart.exportChart(); // PNG
chart.exportChart({type:"image/jpeg"}); // JPEG
chart.exportChart({type:"application/pdf"}); // PDF
chart.exportChart({type:"image/svg+xml"}); // SVG
// part of export-data module
chart.downloadCSV();
chart.downloadXLS();


I created an example with the basic principals of my previous posts in action: https://jsfiddle.net/2149nmdg/

Let me know, if you have more questions.

Best regards,
Sophie
cosy
 
Posts: 118
Joined: Fri Feb 02, 2018 12:22 pm


Return to Highcharts Usage

Who is online

Users browsing this forum: Bing [Bot] and 3 guests

cron