Search in sources :

Example 1 with ContainerDataSeries

use of com.vaadin.v7.addon.charts.model.ContainerDataSeries in project charts by vaadin.

the class ContainerSeriesWithHighAndLow method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.COLUMNRANGE);
    Configuration conf = chart.getConfiguration();
    conf.getChart().setInverted(true);
    conf.setTitle("Temperature variation by month");
    conf.setSubTitle("Observed in Vik i Sogn, Norway, 2009");
    XAxis xAxis = new XAxis();
    xAxis.setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    conf.addxAxis(xAxis);
    YAxis yAxis = new YAxis();
    yAxis.setTitle("Temperature ( °C )");
    conf.addyAxis(yAxis);
    Tooltip tooltip = new Tooltip();
    tooltip.setValueSuffix("°C");
    conf.setTooltip(tooltip);
    PlotOptionsColumnrange columnRange = new PlotOptionsColumnrange();
    columnRange.setDataLabels(new DataLabelsRange(true));
    columnRange.getDataLabels().setFormatter("function() {return this.y + '°C';}");
    conf.setPlotOptions(columnRange);
    conf.getLegend().setEnabled(false);
    IndexedContainer vaadinContainer = new IndexedContainer();
    vaadinContainer.addContainerProperty("min", Number.class, null);
    vaadinContainer.addContainerProperty("max", Number.class, null);
    for (Number[] minMaxPair : getRawData()) {
        Item item = vaadinContainer.getItem(vaadinContainer.addItem());
        item.getItemProperty("min").setValue(minMaxPair[0]);
        item.getItemProperty("max").setValue(minMaxPair[1]);
    }
    ContainerDataSeries data = new ContainerDataSeries(vaadinContainer);
    data.setLowPropertyId("min");
    data.setHighPropertyId("max");
    data.setName("Temperatures");
    conf.setSeries(data);
    return chart;
}
Also used : Item(com.vaadin.v7.data.Item) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsColumnrange(com.vaadin.addon.charts.model.PlotOptionsColumnrange) DataLabelsRange(com.vaadin.addon.charts.model.DataLabelsRange) Tooltip(com.vaadin.addon.charts.model.Tooltip) IndexedContainer(com.vaadin.v7.data.util.IndexedContainer) ContainerDataSeries(com.vaadin.v7.addon.charts.model.ContainerDataSeries) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 2 with ContainerDataSeries

use of com.vaadin.v7.addon.charts.model.ContainerDataSeries in project charts by vaadin.

the class ContainerWithLotsOfData method getChart.

@Override
protected Component getChart() {
    HorizontalLayout lo = new HorizontalLayout();
    ContainerDataSeries container = createContainer();
    Component table = createTable(container.getVaadinContainer());
    Component chart = createChart(container);
    lo.addComponents(table);
    lo.addComponent(chart);
    table.setSizeFull();
    chart.setSizeFull();
    lo.setSizeFull();
    lo.setExpandRatio(table, 1);
    lo.setExpandRatio(chart, 5);
    return lo;
}
Also used : Component(com.vaadin.ui.Component) ContainerDataSeries(com.vaadin.v7.addon.charts.model.ContainerDataSeries) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 3 with ContainerDataSeries

use of com.vaadin.v7.addon.charts.model.ContainerDataSeries in project charts by vaadin.

the class ContainerSeriesJSONSerializationTest method setup.

@Before
public void setup() {
    vaadinContainer = new IndexedContainer();
    vaadinContainer.addContainerProperty("y", Number.class, null);
    containerSeries = new ContainerDataSeries(vaadinContainer);
}
Also used : IndexedContainer(com.vaadin.v7.data.util.IndexedContainer) ContainerDataSeries(com.vaadin.v7.addon.charts.model.ContainerDataSeries) Before(org.junit.Before)

Example 4 with ContainerDataSeries

use of com.vaadin.v7.addon.charts.model.ContainerDataSeries in project charts by vaadin.

the class ChartWithExternalContainer method createContainerView1.

private ContainerDataSeries createContainerView1(Container vaadinContainer) {
    ContainerDataSeries container = new ContainerDataSeries(vaadinContainer);
    container.setName("Order item quantities");
    container.setPlotOptions(new PlotOptionsPie());
    container.setYPropertyId(ExampleUtil.ORDER_QUANTITY_PROPERTY_ID);
    container.setNamePropertyId(ExampleUtil.ORDER_DESCRIPTION_PROPERTY_ID);
    return container;
}
Also used : PlotOptionsPie(com.vaadin.addon.charts.model.PlotOptionsPie) ContainerDataSeries(com.vaadin.v7.addon.charts.model.ContainerDataSeries)

Example 5 with ContainerDataSeries

use of com.vaadin.v7.addon.charts.model.ContainerDataSeries in project charts by vaadin.

the class ChartWithExternalContainer method getChart.

@Override
protected Component getChart() {
    HorizontalLayout lo = new HorizontalLayout();
    lo.setSpacing(true);
    Container vaadinContainer = ExampleUtil.getOrderContainer();
    ContainerDataSeries container1 = createContainerView1(vaadinContainer);
    ContainerDataSeries container2 = createContainerView2(vaadinContainer);
    Component table = createTable(vaadinContainer);
    Component chart1 = createChart1(container1);
    Component chart2 = createChart2(container2);
    table.setSizeFull();
    chart1.setSizeFull();
    chart2.setSizeFull();
    lo.setWidth("100%");
    lo.setHeight("450px");
    lo.addComponents(table);
    lo.addComponent(chart1);
    lo.addComponent(chart2);
    lo.setExpandRatio(table, 0.2f);
    lo.setExpandRatio(chart1, 0.4f);
    lo.setExpandRatio(chart2, 0.4f);
    return lo;
}
Also used : Container(com.vaadin.v7.data.Container) Component(com.vaadin.ui.Component) ContainerDataSeries(com.vaadin.v7.addon.charts.model.ContainerDataSeries) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Aggregations

ContainerDataSeries (com.vaadin.v7.addon.charts.model.ContainerDataSeries)7 IndexedContainer (com.vaadin.v7.data.util.IndexedContainer)3 Component (com.vaadin.ui.Component)2 HorizontalLayout (com.vaadin.ui.HorizontalLayout)2 Item (com.vaadin.v7.data.Item)2 Chart (com.vaadin.addon.charts.Chart)1 Configuration (com.vaadin.addon.charts.model.Configuration)1 DataLabelsRange (com.vaadin.addon.charts.model.DataLabelsRange)1 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)1 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)1 PlotOptionsColumnrange (com.vaadin.addon.charts.model.PlotOptionsColumnrange)1 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)1 Tooltip (com.vaadin.addon.charts.model.Tooltip)1 XAxis (com.vaadin.addon.charts.model.XAxis)1 YAxis (com.vaadin.addon.charts.model.YAxis)1 Container (com.vaadin.v7.data.Container)1 Before (org.junit.Before)1