Search in sources :

Example 1 with PlotOptionsTreemap

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

the class TreemapWithLevels method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.TREEMAP);
    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);
    Style style = new Style();
    style.setFontSize("15px");
    style.setFontWeight(FontWeight.BOLD);
    dataLabels.setStyle(style);
    level1.setDataLabels(dataLabels);
    plotOptions.setLevels(level1);
    TreeSeries series = createSeries();
    series.setPlotOptions(plotOptions);
    chart.getConfiguration().addSeries(series);
    chart.getConfiguration().setTitle("Fruit consumption");
    return chart;
}
Also used : TreeSeries(com.vaadin.addon.charts.model.TreeSeries) DataLabels(com.vaadin.addon.charts.model.DataLabels) PlotOptionsTreemap(com.vaadin.addon.charts.model.PlotOptionsTreemap) Style(com.vaadin.addon.charts.model.style.Style) Level(com.vaadin.addon.charts.model.Level) Chart(com.vaadin.addon.charts.Chart)

Example 2 with PlotOptionsTreemap

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

the class ChartDesignReaderTest method readConfiguration_arrayType_theNewValueIsAddedToArrayInConfiguration.

@Test
public void readConfiguration_arrayType_theNewValueIsAddedToArrayInConfiguration() {
    Elements elements = createElements("<plot-options><treemap><levels level=\"1\"></levels></treemap></plot-options>");
    Configuration configuration = new Configuration();
    ChartDesignReader.readConfigurationFromElements(elements, configuration);
    PlotOptionsTreemap lineOptions = (PlotOptionsTreemap) configuration.getPlotOptions(ChartType.TREEMAP);
    assertEquals(1, lineOptions.getLevels().length);
    assertEquals(1L, lineOptions.getLevels()[0].getLevel());
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsTreemap(com.vaadin.addon.charts.model.PlotOptionsTreemap) Elements(org.jsoup.select.Elements) Test(org.junit.Test)

Example 3 with PlotOptionsTreemap

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

the class TreemapWithColorAxis method getChart.

@Override
protected Component getChart() {
    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");
    return chart;
}
Also used : TreeSeries(com.vaadin.addon.charts.model.TreeSeries) PlotOptionsTreemap(com.vaadin.addon.charts.model.PlotOptionsTreemap) ColorAxis(com.vaadin.addon.charts.model.ColorAxis) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Chart(com.vaadin.addon.charts.Chart)

Example 4 with PlotOptionsTreemap

use of com.vaadin.addon.charts.model.PlotOptionsTreemap 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)

Example 5 with PlotOptionsTreemap

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

the class PlotOptionsJSONSerializationTest method toString_treeMapTurboThresholdIsSet_plotOptionsSerializedWithTurboThreshold.

@Test
public void toString_treeMapTurboThresholdIsSet_plotOptionsSerializedWithTurboThreshold() {
    PlotOptionsTreemap plotOptions = new PlotOptionsTreemap();
    plotOptions.setTurboThreshold(0);
    String json = toJSON(plotOptions);
    String expected = "{\"turboThreshold\":0}";
    assertEquals(expected, json);
}
Also used : PlotOptionsTreemap(com.vaadin.addon.charts.model.PlotOptionsTreemap) Test(org.junit.Test)

Aggregations

PlotOptionsTreemap (com.vaadin.addon.charts.model.PlotOptionsTreemap)5 Chart (com.vaadin.addon.charts.Chart)3 TreeSeries (com.vaadin.addon.charts.model.TreeSeries)3 DataLabels (com.vaadin.addon.charts.model.DataLabels)2 Level (com.vaadin.addon.charts.model.Level)2 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)2 Style (com.vaadin.addon.charts.model.style.Style)2 Test (org.junit.Test)2 ColorAxis (com.vaadin.addon.charts.model.ColorAxis)1 Configuration (com.vaadin.addon.charts.model.Configuration)1 DashStyle (com.vaadin.addon.charts.model.DashStyle)1 TreeSeriesItem (com.vaadin.addon.charts.model.TreeSeriesItem)1 Elements (org.jsoup.select.Elements)1