use of com.vaadin.addon.charts.util.SVGGenerator in project charts by vaadin.
the class SVGGeneratorTest method testWide.
@Test
public void testWide() throws InterruptedException, URISyntaxException {
Configuration conf = new Configuration();
conf.getChart().setType(ChartType.COLUMN);
conf.getChart().setMarginRight(200);
Legend legend = conf.getLegend();
legend.setLayout(LayoutDirection.VERTICAL);
legend.setAlign(HorizontalAlign.RIGHT);
legend.setVerticalAlign(VerticalAlign.MIDDLE);
legend.setBorderWidth(0);
Random r = new Random();
for (int i = 0; i < 20; i++) {
String name = RandomStringUtils.randomAlphabetic(r.nextInt(20));
DataSeries dataSeries = new DataSeries(name);
dataSeries.add(new DataSeriesItem(name, r.nextInt(100)));
conf.addSeries(dataSeries);
}
SVGGenerator instance = SVGGenerator.getInstance();
String generatedSVG = instance.withHeight(400).withWidth(1200).generate(conf);
Assert.assertTrue(generatedSVG.contains("width=\"1200\""));
Assert.assertTrue(generatedSVG.contains("height=\"400\""));
SVGGenerator.getInstance().destroy();
}
Aggregations