prashanth-g
prashanth-g

Reputation: 1233

How to disable HighCharts re-rendering while exporting charting into file?

I am displaying highcharts- spline chart in an application. While loading the page it renders the chart as usual. But when I export the chart as SVG image it re-renders the chart again. It makes all the ajax calls to call again.

$(function () {
// create the chart
$('#container').highcharts({
    chart: {
        events: {
            load: function () {
                alert();
                var label = this.renderer.label('Chart loaded', 100, 120)
                    .attr({
                        fill: Highcharts.getOptions().colors[0],
                        padding: 10,
                        r: 5,
                        zIndex: 8
                    })
                    .css({
                        color: '#FFFFFF'
                    })
                    .add();

                setTimeout(function () {
                    label.fadeOut();
                }, 1000);
            }
        }
    },

    series: [{
        animation: false,
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
    }],
    exporting: {
        enabled:true
    }

});

});

I put this in fiddle

http://jsfiddle.net/qpLyeks7/

you can see that alert box prompts while loading and exporting as SVG.

So , How to disable this call while exporting into a file?

Upvotes: 0

Views: 784

Answers (1)

Paweł Fus
Paweł Fus

Reputation: 45079

You can check inner property chart.options.chart.forExport which is set to true when rendering chart for export. See demo: http://jsfiddle.net/qpLyeks7/1/

if(!this.options.chart.forExport) {
  // some code here
}

Upvotes: 2

Related Questions