Search code examples
chartsamchartsexport-to-pdf

Amchart - Export pie chart with background image?


I have to make pie charts with a background image. While clicking the export icon, it is showing the background image which is added to css. But when the file is downloaded, the image is missing. I see a 'fabric' option in exports. Is there any properties or methods to set the background image?

    AmCharts.makeChart( "chartdiv", {
  "export": {
    "enabled": true,
    "fabric":{},
    "menu": [ {
      "class": "export-main",
      "menu": [ {
        "label": "Download",
        "menu": [ "PNG", "JPG", "CSV" ]
      }, {
        "label": "Annotate",
        "action": "draw",
        "menu": [ {
          "class": "export-drawing",
          "menu": [ "PNG", "JPG" ]
        } ]
      } ]
    } ]
  }
} );

Solution

  • you can set the background image using before Capture function.

    "export": {
          "enabled": true,
          "pageOrientation": "landscape",
          "beforeCapture": function() { 
               var cloneChart = this.setup.chart;
               cloneChart.backgroundImage="$image_url";
           }
    }