Search in sources :

Example 1 with SVGGenerator

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();
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) Random(java.util.Random) SVGGenerator(com.vaadin.addon.charts.util.SVGGenerator) DataSeries(com.vaadin.addon.charts.model.DataSeries) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) Test(org.junit.Test)

Aggregations

Configuration (com.vaadin.addon.charts.model.Configuration)1 DataSeries (com.vaadin.addon.charts.model.DataSeries)1 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)1 Legend (com.vaadin.addon.charts.model.Legend)1 SVGGenerator (com.vaadin.addon.charts.util.SVGGenerator)1 Random (java.util.Random)1 Test (org.junit.Test)1