Sooriya Dasanayake
Sooriya Dasanayake

Reputation: 1156

How to Export multiple fusion charts to separate image files

On page I have several charts. They are build with Fusion Chart library.

There are three different charts.I need to export them all as separate PNG files. So I add button, on click on which I need to have separate png-files.But the current code returns separate images but the same chart. What can we do ?

export method :

 function export_chart() {
        var format = document.getElementById("format").value;
        revenueChart0.exportChart({
            "exportFormat": format
        });
         revenueChart1.exportChart({
            "exportFormat": format
        });
         revenueChart2.exportChart({
            "exportFormat": format
        });
    }

Example: https://jsfiddle.net/73xgmacm/249/

Upvotes: 0

Views: 307

Answers (1)

Zapdos13
Zapdos13

Reputation: 865

In order to export the chart in multiple files on one button click please use batchExport functionality to achieve this, here is a code snippet

batchExportConfig1 = function() {
  FusionCharts.batchExport({
    "charts": [{
      "id": "chart-1",
    }],
    "exportFileName": "chart1",
    "exportFormat": "jpg"
  })
  FusionCharts.batchExport({
    "charts": [{
      "id": "chart-2",
    }],
    "exportFileName": "chart2",
    "exportFormat": "jpg"
  })
  FusionCharts.batchExport({
    "charts": [{
      "id": "chart-3",
    }],
    "exportFileName": "chart3",
    "exportFormat": "jpg"
  })
  FusionCharts.batchExport({
    "charts": [{
      "id": "chart-4",
    }],
    "exportFileName": "chart4",
    "exportFormat": "jpg"
  })
}

Here is a sample fiddle - http://jsfiddle.net/khjt8c7m/

Upvotes: 1

Related Questions