Home Forums Chart Support I Want Capture a Screenshots of Whole Canvas Chart. Reply To: I Want Capture a Screenshots of Whole Canvas Chart.

#36485

@keval-panchal,

exportChart method exports the entire chart irrespective of the scrollbar. In cases where you zoom into a region of the chart (either by zooming using mouse or zooming programmatically by setting viewportMinimum and/or viewportMaximum) & try to export, it exports the entire chart with the axis-range that you have zoomed into.

In order to show the entire viewport Range on the image while exporting, you can reset the viewportMinimum and viewportMaximum property before exporting as shown in the code-snippet below,

document.getElementById("exportChart").addEventListener("click",function(){
  var tempViewportMinimum = chart.axisX[0].get("viewportMinimum");
  var tempViewportMaximum = chart.axisX[0].get("viewportMaximum");

  chart.axisX[0].set("viewportMaximum", null, false);
  chart.axisX[0].set("viewportMinimum", null);

  chart.exportChart({format: "jpg"});

  chart.axisX[0].set("viewportMinimum", tempViewportMinimum, false);
  chart.axisX[0].set("viewportMaximum", tempViewportMaximum);
}); 

Kindly take a look at this JSFiddle for an example on the same.


Adithya Menon
Team CanvasJS