use of com.vaadin.v7.data.Container 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;
}
use of com.vaadin.v7.data.Container in project charts by vaadin.
the class ContainerWithLotsOfData method createContainer.
@SuppressWarnings("unchecked")
private ContainerDataSeries createContainer() {
IndexedContainer vaadinContainer = new IndexedContainer();
ContainerDataSeries container = new ContainerDataSeries(vaadinContainer);
vaadinContainer.addContainerProperty("y", Number.class, null);
for (int i = 0; i < getContainerData().length; i++) {
Item item = vaadinContainer.addItem(i);
item.getItemProperty("y").setValue(getContainerData()[i]);
}
container.setName("USD to EUR");
container.setPlotOptions(new PlotOptionsArea());
container.setYPropertyId("y");
return container;
}
use of com.vaadin.v7.data.Container in project charts by vaadin.
the class ContainerWithLotsOfData method createTable.
private Component createTable(Container container) {
Table t = new Table();
t.setCaption("Data from Vaadin Container");
t.setContainerDataSource(container);
t.setItemCaptionMode(ItemCaptionMode.ID);
t.setImmediate(true);
return t;
}
use of com.vaadin.v7.data.Container 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;
}
use of com.vaadin.v7.data.Container in project charts by vaadin.
the class ContainerDataSeriesBeanSerializer method createDataArray.
private ArrayNode createDataArray(Container container, Map<String, Object> pidMap) {
ArrayNode data = JsonNodeFactory.instance.arrayNode();
Mode mode = null;
for (Object o : pidMap.keySet()) {
if (!(o.equals(ContainerDataSeries.SERIES_DEFAULT_ATTRIBUTE1) || o.equals(ContainerDataSeries.SERIES_DEFAULT_ATTRIBUTE2))) {
mode = Mode.OBJECT;
break;
}
}
Object xProperty = pidMap.get(ContainerDataSeries.SERIES_DEFAULT_ATTRIBUTE1);
if (xProperty == null) {
xProperty = ContainerDataSeries.SERIES_DEFAULT_ATTRIBUTE1;
}
Object yProperty = pidMap.get(ContainerDataSeries.SERIES_DEFAULT_ATTRIBUTE2);
if (yProperty == null) {
yProperty = ContainerDataSeries.SERIES_DEFAULT_ATTRIBUTE2;
}
checkRequiredProperties(container, pidMap, yProperty);
if (mode != Mode.OBJECT) {
if (container.getContainerPropertyIds().contains(xProperty)) {
mode = Mode.XY;
} else {
mode = Mode.ONLY_Y;
}
}
for (Object iid : container.getItemIds()) {
Item item = container.getItem(iid);
switch(mode) {
case ONLY_Y:
addValue(data, item.getItemProperty(yProperty));
break;
case XY:
Property itemPropertyX = item.getItemProperty(xProperty);
Property itemPropertyY = item.getItemProperty(yProperty);
if (itemPropertyX.getValue() != null && itemPropertyY.getValue() != null) {
ArrayNode entryArray = JsonNodeFactory.instance.arrayNode();
data.add(entryArray);
addValue(entryArray, itemPropertyX);
addValue(entryArray, itemPropertyY);
} else {
data.addNull();
}
break;
default:
// render as json object
ObjectNode entryObject = JsonNodeFactory.instance.objectNode();
Property<?> x = item.getItemProperty(xProperty);
if (x != null) {
addNamedValue(entryObject, ContainerDataSeries.SERIES_DEFAULT_ATTRIBUTE1, x);
}
Property<?> y = item.getItemProperty(yProperty);
if (y != null) {
addNamedValue(entryObject, ContainerDataSeries.SERIES_DEFAULT_ATTRIBUTE2, y);
}
Iterator<String> iter = pidMap.keySet().iterator();
while (iter.hasNext()) {
String name = iter.next();
Object id = pidMap.get(name);
if (!id.equals(xProperty) && !id.equals(yProperty)) {
addNamedValue(entryObject, name, item.getItemProperty(id));
}
}
data.add(entryObject);
break;
}
}
return data;
}
Aggregations