Search in sources :

Example 1 with TreeSeriesItem

use of com.vaadin.addon.charts.model.TreeSeriesItem in project charts by vaadin.

the class SVGGeneratorTest method generate_TreemapChart_withoutException.

@Test
public void generate_TreemapChart_withoutException() {
    Chart chart = new Chart(ChartType.TREEMAP);
    Configuration conf = chart.getConfiguration();
    TreeSeries series = new TreeSeries();
    conf.setSeries(series);
    for (int i = 0; i < 10; ++i) {
        double y = Math.random();
        TreeSeriesItem item = new TreeSeriesItem("Attempt " + i, (int) Math.floor(y * 100));
        int r = (int) (255 * y);
        int g = 255 - (int) (255 * y);
        item.setColor(new SolidColor(r, g, 100));
        series.add(item);
    }
    String generatedSVG = SVGGenerator.getInstance().generate(conf);
    Assert.assertTrue(generatedSVG != null);
}
Also used : TreeSeries(com.vaadin.addon.charts.model.TreeSeries) Configuration(com.vaadin.addon.charts.model.Configuration) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) TreeSeriesItem(com.vaadin.addon.charts.model.TreeSeriesItem) Chart(com.vaadin.addon.charts.Chart) Test(org.junit.Test)

Example 2 with TreeSeriesItem

use of com.vaadin.addon.charts.model.TreeSeriesItem in project charts by vaadin.

the class TreemapWithColorAxis method createSeries.

private TreeSeries createSeries() {
    List<TreeSeriesItem> items = new ArrayList<TreeSeriesItem>();
    items.add(new TreeSeriesItem("A", 6));
    items.add(new TreeSeriesItem("B", 6));
    items.add(new TreeSeriesItem("C", 4));
    items.add(new TreeSeriesItem("D", 3));
    items.add(new TreeSeriesItem("E", 2));
    items.add(new TreeSeriesItem("F", 2));
    items.add(new TreeSeriesItem("G", 1));
    for (int i = 1; i <= items.size(); i++) {
        items.get(i - 1).setColorValue(i);
    }
    TreeSeries series = new TreeSeries();
    series.setData(items);
    return series;
}
Also used : TreeSeries(com.vaadin.addon.charts.model.TreeSeries) ArrayList(java.util.ArrayList) TreeSeriesItem(com.vaadin.addon.charts.model.TreeSeriesItem)

Example 3 with TreeSeriesItem

use of com.vaadin.addon.charts.model.TreeSeriesItem in project charts by vaadin.

the class PointClickCoordinatesTreeMapChart method addSeries.

@Override
protected void addSeries(Configuration conf) {
    TreeSeries series = new TreeSeries();
    TreeSeriesItem apples = new TreeSeriesItem("A", "Apples");
    apples.setColor(new SolidColor("#EC2500"));
    TreeSeriesItem bananas = new TreeSeriesItem("B", "Bananas");
    bananas.setColor(new SolidColor("#ECE100"));
    TreeSeriesItem oranges = new TreeSeriesItem("O", "Oranges");
    oranges.setColor(new SolidColor("#EC9800"));
    TreeSeriesItem anneA = new TreeSeriesItem("Anne", apples, 5);
    TreeSeriesItem rickA = new TreeSeriesItem("Rick", apples, 3);
    TreeSeriesItem peterA = new TreeSeriesItem("Peter", apples, 4);
    TreeSeriesItem anneB = new TreeSeriesItem("Anne", bananas, 4);
    TreeSeriesItem rickB = new TreeSeriesItem("Rick", bananas, 10);
    TreeSeriesItem peterB = new TreeSeriesItem("Peter", bananas, 1);
    TreeSeriesItem anneO = new TreeSeriesItem("Anne", oranges, 1);
    TreeSeriesItem rickO = new TreeSeriesItem("Rick", oranges, 3);
    TreeSeriesItem peterO = new TreeSeriesItem("Peter", oranges, 3);
    TreeSeriesItem susanne = new TreeSeriesItem("Susanne", 2);
    susanne.setParent("Kiwi");
    susanne.setColor(new SolidColor("#9EDE00"));
    series.addAll(apples, bananas, oranges, anneA, rickA, peterA, anneB, rickB, peterB, anneO, rickO, peterO, susanne);
    conf.addSeries(series);
}
Also used : TreeSeries(com.vaadin.addon.charts.model.TreeSeries) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) TreeSeriesItem(com.vaadin.addon.charts.model.TreeSeriesItem)

Example 4 with TreeSeriesItem

use of com.vaadin.addon.charts.model.TreeSeriesItem in project charts by vaadin.

the class DeclarativeTreemapWithLevels method createSeries.

private TreeSeries createSeries() {
    TreeSeries series = new TreeSeries();
    TreeSeriesItem apples = new TreeSeriesItem("A", "Apples");
    apples.setColor(new SolidColor("#EC2500"));
    TreeSeriesItem bananas = new TreeSeriesItem("B", "Bananas");
    bananas.setColor(new SolidColor("#ECE100"));
    TreeSeriesItem oranges = new TreeSeriesItem("O", "Oranges");
    oranges.setColor(new SolidColor("#EC9800"));
    TreeSeriesItem anneA = new TreeSeriesItem("Anne", apples, 5);
    TreeSeriesItem rickA = new TreeSeriesItem("Rick", apples, 3);
    TreeSeriesItem peterA = new TreeSeriesItem("Peter", apples, 4);
    TreeSeriesItem anneB = new TreeSeriesItem("Anne", bananas, 4);
    TreeSeriesItem rickB = new TreeSeriesItem("Rick", bananas, 10);
    TreeSeriesItem peterB = new TreeSeriesItem("Peter", bananas, 1);
    TreeSeriesItem anneO = new TreeSeriesItem("Anne", oranges, 1);
    TreeSeriesItem rickO = new TreeSeriesItem("Rick", oranges, 3);
    TreeSeriesItem peterO = new TreeSeriesItem("Peter", oranges, 3);
    TreeSeriesItem susanne = new TreeSeriesItem("Susanne", 2);
    susanne.setParent("Kiwi");
    susanne.setColor(new SolidColor("#9EDE00"));
    series.addAll(apples, bananas, oranges, anneA, rickA, peterA, anneB, rickB, peterB, anneO, rickO, peterO, susanne);
    return series;
}
Also used : TreeSeries(com.vaadin.addon.charts.model.TreeSeries) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) TreeSeriesItem(com.vaadin.addon.charts.model.TreeSeriesItem)

Example 5 with TreeSeriesItem

use of com.vaadin.addon.charts.model.TreeSeriesItem in project charts by vaadin.

the class ChartTypes method chartTypesTreemap.

public void chartTypesTreemap() {
    Chart chart = new Chart();
    PlotOptionsTreemap plotOptions = new PlotOptionsTreemap();
    plotOptions.setLayoutAlgorithm(TreeMapLayoutAlgorithm.STRIPES);
    plotOptions.setAlternateStartingDirection(true);
    Level level = new Level();
    level.setLevel(1);
    level.setLayoutAlgorithm(TreeMapLayoutAlgorithm.SLICEANDDICE);
    DataLabels dataLabels = new DataLabels();
    dataLabels.setEnabled(true);
    dataLabels.setAlign(HorizontalAlign.LEFT);
    dataLabels.setVerticalAlign(VerticalAlign.TOP);
    Style style = new Style();
    style.setFontSize("15px");
    style.setFontWeight(FontWeight.BOLD);
    dataLabels.setStyle(style);
    level.setDataLabels(dataLabels);
    plotOptions.setLevels(level);
    TreeSeries series = new TreeSeries();
    TreeSeriesItem apples = new TreeSeriesItem("A", "Apples");
    apples.setColor(new SolidColor("#EC2500"));
    TreeSeriesItem bananas = new TreeSeriesItem("B", "Bananas");
    bananas.setColor(new SolidColor("#ECE100"));
    TreeSeriesItem oranges = new TreeSeriesItem("O", "Oranges");
    oranges.setColor(new SolidColor("#EC9800"));
    TreeSeriesItem anneA = new TreeSeriesItem("Anne", apples, 5);
    TreeSeriesItem rickA = new TreeSeriesItem("Rick", apples, 3);
    TreeSeriesItem paulA = new TreeSeriesItem("Paul", apples, 4);
    TreeSeriesItem anneB = new TreeSeriesItem("Anne", bananas, 4);
    TreeSeriesItem rickB = new TreeSeriesItem("Rick", bananas, 10);
    TreeSeriesItem paulB = new TreeSeriesItem("Paul", bananas, 1);
    TreeSeriesItem anneO = new TreeSeriesItem("Anne", oranges, 1);
    TreeSeriesItem rickO = new TreeSeriesItem("Rick", oranges, 3);
    TreeSeriesItem paulO = new TreeSeriesItem("Paul", oranges, 3);
    TreeSeriesItem susanne = new TreeSeriesItem("Susanne", 2);
    susanne.setParent("Kiwi");
    susanne.setColor(new SolidColor("#9EDE00"));
    series.addAll(apples, bananas, oranges, anneA, rickA, paulA, anneB, rickB, paulB, anneO, rickO, paulO, susanne);
    series.setPlotOptions(plotOptions);
    chart.getConfiguration().addSeries(series);
    chart.getConfiguration().setTitle("Fruit consumption");
}
Also used : TreeSeries(com.vaadin.addon.charts.model.TreeSeries) DataLabels(com.vaadin.addon.charts.model.DataLabels) PlotOptionsTreemap(com.vaadin.addon.charts.model.PlotOptionsTreemap) DashStyle(com.vaadin.addon.charts.model.DashStyle) Style(com.vaadin.addon.charts.model.style.Style) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Level(com.vaadin.addon.charts.model.Level) TreeSeriesItem(com.vaadin.addon.charts.model.TreeSeriesItem) Chart(com.vaadin.addon.charts.Chart)

Aggregations

TreeSeries (com.vaadin.addon.charts.model.TreeSeries)7 TreeSeriesItem (com.vaadin.addon.charts.model.TreeSeriesItem)7 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)6 Chart (com.vaadin.addon.charts.Chart)2 Configuration (com.vaadin.addon.charts.model.Configuration)1 DashStyle (com.vaadin.addon.charts.model.DashStyle)1 DataLabels (com.vaadin.addon.charts.model.DataLabels)1 Level (com.vaadin.addon.charts.model.Level)1 PlotOptionsTreemap (com.vaadin.addon.charts.model.PlotOptionsTreemap)1 Style (com.vaadin.addon.charts.model.style.Style)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1