amcharts / export

Apache License 2.0
56 stars 33 forks source link

Exporting tall chart to PDF does not work #24

Closed ksurakka closed 8 years ago

ksurakka commented 8 years ago

If I have tall enough chart and try to export that to PDF file, I either get blank PDF file or browser jams. Tested with Chrome (ver 46).

CodePen environment to reproduce this error: http://codepen.io/anon/pen/NxKVGY Reproduce steps: Hover over Download button on chart > Hover over "Download as..." > Click "PDF"

Result: Got PDF file with no chart Expected result: To get PDF file with chart

Then you can edit css height of #chartdiv to 500px and try again, PDF export works.

maertz commented 8 years ago

Looks like pdfMake has an issue splitting image data across multiple pages. You can adapt the boundary box for the image to make it fit in one page, if that's fine for you.

Check the pdfMake property within the config to overwrite the defaults: http://codepen.io/team/amcharts/pen/VeZOXb (forked sample)

ksurakka commented 8 years ago

Ok and thanks, the "fit" property did the job.

I needed to set values a little bit smaller than mentioned in documentation, there might be some margins applying.

E.g. this worked for me:

"content": [
    {
        "image": "reference",
        "fit": [ 500.28, 749.89 ] // fit image to A4
    }      
]

And here is working (Chrome) Codepen link: http://codepen.io/anon/pen/xZbbRj