Vaadin Charts Exporting options

Hi,

I’m trying to create reports that include charts created with Vaadin Charts 2.0.0, but the exported charts in SVG format have a poor resolution.

There is a way to create an high-resolution image (for example a 1600px x 800px)?

To create svg image I use the following code

myChart.getConfiguration().getLegend().setEnabled(false);
SVGGenerator svgInstance = SVGGenerator.getInstance();
String svg = svgInstance .generate(myChart.getConfiguration());
myChart.getConfiguration().getLegend().setEnabled(true);
svgInstance.destroy();
FileUtils.writeStringToFile(new File(chart_to_image_path), svg);

Can anyone suggest a solution?

Thanks in advance

Luca

Hi Luca,

Have you tried with
generate(Configuration conf, int targetWidth, int targetHeight)

Hope this helps,

Guille

That javadoc link is from Vaadin Charts 2.1.3, but 2.0.0 already had that API

Hi Giullermo,

It’ worked! Thank you.

I have another question.
The SVG of the chart generated on Windows platform has all the labels correclty centered (as shown in the attachment “Chart on Windows.PNG”)

The same code running on linux platform produces a SVG in which all the labels are de-centered and alined on the left (attachment “Chart on Linux.PNG”).

I hoped that increasing resolution of generated SVG, the problem would be solved, but it’s wasn’t so.
How I can can solve this alignment problem? Do you have any suggest?

Thank you in advance.

Luca

33218.png
33219.png