amcharts / export

Apache License 2.0
56 stars 33 forks source link

chart export blurs on zoom #84

Open wildan2711 opened 5 years ago

wildan2711 commented 5 years ago

I'm trying to export a chart that is zoomed. This is from a screenshot:

image

When I export to PNG using this function:

this.chart.export.capture({}, function() {
    this.toPNG({
        quality: 1,
        multiplier: 2
    }, function(data) {
        this.download(data, 'image/png', 'chart.png')
    })
})

The PNG blurs like this:

chart 35

I'm using guides so I had to set the minimum and maximum of the axis explicitly.

Thank you.

RobbiesCode commented 5 years ago

That looks a little too blurry, I agree! Do you have your chart online somewhere, so we can have a closer look? Also, can you provide some details, like browser and OS where this is happening?

wildan2711 commented 5 years ago

I managed to create a codepen that reproduces the issue, here it is:

https://codepen.io/wildan2711/pen/REOOjB?editors=1111

Thanks.

martynasma commented 5 years ago

We're trying to get to the bottom of it.

Meanwhile, it looks like it is caused by trend lines. If you remove that section, exports become fine.

wildan2711 commented 5 years ago

Yes, although some of our charts does not blur when using trend lines.

wildan2711 commented 5 years ago

any news on this?

martynasma commented 5 years ago

Sorry for the wait.

Export plugin was just updated. It should fix the issue.

martynasma commented 5 years ago

Ah sorry, the plugin was not updated. We do have a solution, though.

Please refer to this demo: https://codepen.io/anon/pen/GeOWzg?editors=0010

This section should fix the issue:

  "export": {
    "backgroundColor": "#ffffff",
    "enabled": true,
    "reviver": function(obj) {
      if ( obj.width > this.setup.chart.realWidth ) {
        obj.width = this.setup.chart.realWidth;
      }
    }
  },
wildan2711 commented 5 years ago

Nice, it works! Thanks for the workaround.