Rakesh Tripathi
Rakesh Tripathi

Reputation: 43

Change filename - When export graph amcharts

I want to change the filename while export from amcharts graph download option. Currently it was downloading with name amcharts.jpg or amcharts.pdf.

Kindly assists.

Thanks in advance

Upvotes: 0

Views: 4231

Answers (3)

rensothearin
rensothearin

Reputation: 766

Or you can do something like this:

var chart = am4core.create("Any chartname", am4charts.XYChart3D);

chart.exporting.menu = new am4core.ExportMenu();
chart.exporting.filePrefix = "The exporting file name";

Upvotes: 1

raj
raj

Reputation: 91

create an amChart and prefix the chart with preferred file name

chart: any;
this.chart = am4core.create('core-chart', am4charts.XYChart);
this.chart.exporting.filePrefix = "preferred file name";

Upvotes: 1

xorspark
xorspark

Reputation: 16012

You can change the filename by setting the fileName property, as indicated in the export plugin documentation.

var chart = AmCharts.makeChart("chartdiv", {
  // ...
  "export": {
    "enabled": true,
    "fileName": "your new file name without extension", 
    // ...
  }
});

You can also set the fileName at the format level through the menuReviver callback. You can use this to override the top level fileName property depending on the format.

var chart = AmCharts.makeChart("chartdiv", {
  // ...
  "export": {
    "enabled": true,
    "fileName": "top level filename",
    "menuReviver": function(item, li) {
      if (item.format === "JPG") {
        item.fileName = "customJPGName"; //different file name for JPG files
      }
      return li;
    }
  }
});

Demo

Upvotes: 5

Related Questions