Search in sources :

Example 1 with TreeSeries

use of com.vaadin.flow.component.charts.model.TreeSeries in project flow-components by vaadin.

the class Treemap method createSeries.

private TreeSeries createSeries() {
    TreeSeries series = new TreeSeries();
    TreeSeriesItem apples = new TreeSeriesItem("A", "Apples");
    apples.setColorIndex(0);
    TreeSeriesItem bananas = new TreeSeriesItem("B", "Bananas");
    bananas.setColorIndex(2);
    TreeSeriesItem oranges = new TreeSeriesItem("O", "Oranges");
    oranges.setColorIndex(3);
    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.setColorIndex(4);
    series.addAll(apples, bananas, oranges, anneA, rickA, peterA, anneB, rickB, peterB, anneO, rickO, peterO, susanne);
    return series;
}
Also used : TreeSeries(com.vaadin.flow.component.charts.model.TreeSeries) TreeSeriesItem(com.vaadin.flow.component.charts.model.TreeSeriesItem)

Example 2 with TreeSeries

use of com.vaadin.flow.component.charts.model.TreeSeries in project flow-components by vaadin.

the class TreemapWithColorAxis method createSeries.

private TreeSeries createSeries() {
    List<TreeSeriesItem> items = new ArrayList<>();
    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.flow.component.charts.model.TreeSeries) ArrayList(java.util.ArrayList) TreeSeriesItem(com.vaadin.flow.component.charts.model.TreeSeriesItem)

Example 3 with TreeSeries

use of com.vaadin.flow.component.charts.model.TreeSeries in project flow-components by vaadin.

the class TreemapWithColorAxis method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart(ChartType.TREEMAP);
    ColorAxis colorAxis = new ColorAxis();
    colorAxis.setMinColor(new SolidColor("#FFFFFF"));
    colorAxis.setMaxColor(new SolidColor("#7BB5EF"));
    chart.getConfiguration().addColorAxis(colorAxis);
    PlotOptionsTreemap plotOptions = new PlotOptionsTreemap();
    plotOptions.setLayoutAlgorithm(TreeMapLayoutAlgorithm.SQUARIFIED);
    TreeSeries series = createSeries();
    series.setPlotOptions(plotOptions);
    chart.getConfiguration().addSeries(series);
    chart.getConfiguration().setTitle("Vaadin Charts Treemap");
    add(chart);
}
Also used : TreeSeries(com.vaadin.flow.component.charts.model.TreeSeries) PlotOptionsTreemap(com.vaadin.flow.component.charts.model.PlotOptionsTreemap) ColorAxis(com.vaadin.flow.component.charts.model.ColorAxis) SolidColor(com.vaadin.flow.component.charts.model.style.SolidColor) Chart(com.vaadin.flow.component.charts.Chart)

Example 4 with TreeSeries

use of com.vaadin.flow.component.charts.model.TreeSeries in project flow-components by vaadin.

the class Treemap method initDemo.

@Override
public void initDemo() {
    Chart chart = new Chart(ChartType.TREEMAP);
    Configuration conf = chart.getConfiguration();
    conf.getTooltip().setEnabled(true);
    PlotOptionsTreemap plotOptions = new PlotOptionsTreemap();
    plotOptions.setLayoutAlgorithm(TreeMapLayoutAlgorithm.STRIPES);
    plotOptions.setAlternateStartingDirection(true);
    Level level1 = new Level();
    level1.setLevel(1);
    level1.setLayoutAlgorithm(TreeMapLayoutAlgorithm.SLICEANDDICE);
    DataLabels dataLabels = new DataLabels();
    dataLabels.setEnabled(true);
    dataLabels.setAlign(HorizontalAlign.LEFT);
    dataLabels.setVerticalAlign(VerticalAlign.TOP);
    level1.setDataLabels(dataLabels);
    plotOptions.setLevels(level1);
    TreeSeries series = createSeries();
    series.setPlotOptions(plotOptions);
    chart.getConfiguration().addSeries(series);
    chart.getConfiguration().setTitle("Fruit consumption");
    add(chart);
}
Also used : TreeSeries(com.vaadin.flow.component.charts.model.TreeSeries) DataLabels(com.vaadin.flow.component.charts.model.DataLabels) Configuration(com.vaadin.flow.component.charts.model.Configuration) PlotOptionsTreemap(com.vaadin.flow.component.charts.model.PlotOptionsTreemap) Level(com.vaadin.flow.component.charts.model.Level) Chart(com.vaadin.flow.component.charts.Chart)

Example 5 with TreeSeries

use of com.vaadin.flow.component.charts.model.TreeSeries in project flow-components by vaadin.

the class HasItemTest method getItemWithTreeSeriesThrowsUnsupportedOperationException.

@Test(expected = UnsupportedOperationException.class)
public void getItemWithTreeSeriesThrowsUnsupportedOperationException() {
    Chart chart = new Chart();
    TreeSeriesItem item = new TreeSeriesItem("1", "1");
    TreeSeries series = new TreeSeries();
    series.add(item);
    chart.getConfiguration().addSeries(series);
    HasItem hasItem = new HasItemTestImpl(chart, 0, 0);
    hasItem.getItem();
}
Also used : TreeSeries(com.vaadin.flow.component.charts.model.TreeSeries) HasItem(com.vaadin.flow.component.charts.events.HasItem) TreeSeriesItem(com.vaadin.flow.component.charts.model.TreeSeriesItem) Test(org.junit.Test)

Aggregations

TreeSeries (com.vaadin.flow.component.charts.model.TreeSeries)5 TreeSeriesItem (com.vaadin.flow.component.charts.model.TreeSeriesItem)3 Chart (com.vaadin.flow.component.charts.Chart)2 PlotOptionsTreemap (com.vaadin.flow.component.charts.model.PlotOptionsTreemap)2 HasItem (com.vaadin.flow.component.charts.events.HasItem)1 ColorAxis (com.vaadin.flow.component.charts.model.ColorAxis)1 Configuration (com.vaadin.flow.component.charts.model.Configuration)1 DataLabels (com.vaadin.flow.component.charts.model.DataLabels)1 Level (com.vaadin.flow.component.charts.model.Level)1 SolidColor (com.vaadin.flow.component.charts.model.style.SolidColor)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1