Search in sources :

Example 16 with Configuration

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

the class Basic3DColumn method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.COLUMN);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Monthly Average Rainfall");
    conf.setSubTitle("Source: WorldClimate.com");
    XAxis x = new XAxis();
    x.setCategories("Jan", "Feb", "Mar", "Apr");
    conf.addxAxis(x);
    YAxis y = new YAxis();
    y.setMin(0);
    y.setTitle("Rainfall (mm)");
    conf.addyAxis(y);
    Tooltip tooltip = new Tooltip();
    tooltip.setFormatter("this.x +': '+ this.y +' mm'");
    conf.setTooltip(tooltip);
    PlotOptionsColumn plot = new PlotOptionsColumn();
    plot.setPointPadding(0.2);
    plot.setBorderWidth(0);
    plot.setGroupZPadding(10);
    conf.setPlotOptions(plot);
    Options3d options3d = new Options3d();
    options3d.setEnabled(true);
    options3d.setAlpha(5);
    options3d.setBeta(30);
    options3d.setDepth(100);
    options3d.setViewDistance(200);
    Frame frame = new Frame();
    options3d.setFrame(frame);
    conf.getChart().setOptions3d(options3d);
    conf.addSeries(new ListSeries("Tokyo", 49.9, 71.5, 106.4, 129.2));
    conf.addSeries(new ListSeries("New York", 83.6, 78.8, 98.5, 93.4));
    conf.addSeries(new ListSeries("London", 48.9, 38.8, 39.3, 41.4));
    conf.addSeries(new ListSeries("Berlin", 42.4, 33.2, 34.5, 39.7));
    chart.drawChart(conf);
    return chart;
}
Also used : Frame(com.vaadin.addon.charts.model.Frame) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsColumn(com.vaadin.addon.charts.model.PlotOptionsColumn) ListSeries(com.vaadin.addon.charts.model.ListSeries) Tooltip(com.vaadin.addon.charts.model.Tooltip) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) Options3d(com.vaadin.addon.charts.model.Options3d) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 17 with Configuration

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

the class Basic3DPie method createChart.

public static Chart createChart() {
    Chart chart = new Chart(ChartType.PIE);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Browser market shares at a specific website, 2010");
    PlotOptionsPie plotOptions = new PlotOptionsPie();
    plotOptions.setCursor(Cursor.POINTER);
    DataLabels dataLabels = new DataLabels(true);
    dataLabels.setFormatter("'<b>'+ this.point.name +'</b>: '+ this.percentage +' %'");
    plotOptions.setDataLabels(dataLabels);
    plotOptions.setDepth(45);
    conf.setPlotOptions(plotOptions);
    final DataSeries series = new DataSeries();
    series.add(new DataSeriesItem("Firefox", 45.0));
    series.add(new DataSeriesItem("IE", 26.8));
    DataSeriesItem chrome = new DataSeriesItem("Chrome", 12.8);
    chrome.setSliced(true);
    chrome.setSelected(true);
    series.add(chrome);
    series.add(new DataSeriesItem("Safari", 8.5));
    series.add(new DataSeriesItem("Opera", 6.2));
    series.add(new DataSeriesItem("Others", 0.7));
    conf.setSeries(series);
    Options3d options3d = new Options3d();
    options3d.setEnabled(true);
    options3d.setAlpha(60);
    conf.getChart().setOptions3d(options3d);
    chart.addPointClickListener(new PointClickListener() {

        @Override
        public void onClick(PointClickEvent event) {
            Notification.show("Click: " + series.get(event.getPointIndex()).getName());
        }
    });
    chart.drawChart(conf);
    return chart;
}
Also used : PlotOptionsPie(com.vaadin.addon.charts.model.PlotOptionsPie) DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) PointClickListener(com.vaadin.addon.charts.PointClickListener) PointClickEvent(com.vaadin.addon.charts.PointClickEvent) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) Options3d(com.vaadin.addon.charts.model.Options3d)

Example 18 with Configuration

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

the class ChartDesignReaderTest method readConfiguration_enumValueDefinedInFragment_theSameValueIsInConfiguration.

@Test
public void readConfiguration_enumValueDefinedInFragment_theSameValueIsInConfiguration() {
    Elements elements = createElements("<legend layout=\"vertical\"></legend>");
    Configuration configuration = new Configuration();
    ChartDesignReader.readConfigurationFromElements(elements, configuration);
    assertEquals(LayoutDirection.VERTICAL, configuration.getLegend().getLayout());
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Elements(org.jsoup.select.Elements) Test(org.junit.Test)

Example 19 with Configuration

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

the class ChartDesignReaderTest method readConfiguration_plotOptionsWithReservedTagName_plotOptionsIsAddedToConfiguration.

@Test
public void readConfiguration_plotOptionsWithReservedTagName_plotOptionsIsAddedToConfiguration() {
    Elements elements = createElements("<plot-options><chart-area></chart-area></plot-options>");
    Configuration configuration = new Configuration();
    ChartDesignReader.readConfigurationFromElements(elements, configuration);
    assertEquals(1, configuration.getPlotOptions().size());
    assertThat(configuration.getPlotOptions(ChartType.AREA), instanceOf(PlotOptionsArea.class));
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) Elements(org.jsoup.select.Elements) Test(org.junit.Test)

Example 20 with Configuration

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

Aggregations

Configuration (com.vaadin.addon.charts.model.Configuration)257 Chart (com.vaadin.addon.charts.Chart)196 YAxis (com.vaadin.addon.charts.model.YAxis)100 DataSeries (com.vaadin.addon.charts.model.DataSeries)72 ListSeries (com.vaadin.addon.charts.model.ListSeries)70 XAxis (com.vaadin.addon.charts.model.XAxis)65 Test (org.junit.Test)58 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)56 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)54 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)51 Tooltip (com.vaadin.addon.charts.model.Tooltip)42 DataLabels (com.vaadin.addon.charts.model.DataLabels)41 Legend (com.vaadin.addon.charts.model.Legend)30 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)30 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)27 Elements (org.jsoup.select.Elements)27 Marker (com.vaadin.addon.charts.model.Marker)22 DesignContext (com.vaadin.ui.declarative.DesignContext)22 Element (org.jsoup.nodes.Element)22 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)20