Search in sources :

Example 1 with BeanItemContainer

use of com.vaadin.v7.data.util.BeanItemContainer in project charts by vaadin.

the class SparklineExampleWithLargeDataset method getChart.

@Override
protected Component getChart() {
    List<StockData> data = new LinkedList<StockData>();
    for (int i = 0; i < 200; i++) {
        data.addAll(getStockData());
    }
    Container container = new BeanItemContainer<StockData>(StockData.class, data);
    Table table = new Table();
    table.setContainerDataSource(container);
    table.addGeneratedColumn("values", new Table.ColumnGenerator() {

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            return new Sparkline(100, 20, (Number[]) source.getItem(itemId).getItemProperty(columnId).getValue());
        }
    });
    table.setVisibleColumns("month", "values", "latest");
    table.setHeightUndefined();
    return table;
}
Also used : BeanItemContainer(com.vaadin.v7.data.util.BeanItemContainer) Container(com.vaadin.v7.data.Container) Table(com.vaadin.v7.ui.Table) BeanItemContainer(com.vaadin.v7.data.util.BeanItemContainer) LinkedList(java.util.LinkedList) Sparkline(com.vaadin.addon.charts.Sparkline)

Example 2 with BeanItemContainer

use of com.vaadin.v7.data.util.BeanItemContainer in project charts by vaadin.

the class SimpleSparklineExample method getChart.

@Override
protected Component getChart() {
    Container container = new BeanItemContainer<StockData>(StockData.class, getStockData());
    Table table = new Table();
    table.setContainerDataSource(container);
    table.addGeneratedColumn("values", new Table.ColumnGenerator() {

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            return new Sparkline(100, 20, (Number[]) source.getItem(itemId).getItemProperty(columnId).getValue());
        }
    });
    table.setVisibleColumns("month", "values", "latest");
    table.setHeightUndefined();
    return table;
}
Also used : BeanItemContainer(com.vaadin.v7.data.util.BeanItemContainer) Container(com.vaadin.v7.data.Container) Table(com.vaadin.v7.ui.Table) BeanItemContainer(com.vaadin.v7.data.util.BeanItemContainer) Sparkline(com.vaadin.addon.charts.Sparkline)

Aggregations

Sparkline (com.vaadin.addon.charts.Sparkline)2 Container (com.vaadin.v7.data.Container)2 BeanItemContainer (com.vaadin.v7.data.util.BeanItemContainer)2 Table (com.vaadin.v7.ui.Table)2 LinkedList (java.util.LinkedList)1