Search in sources :

Example 6 with Container

use of com.vaadin.v7.data.Container 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 7 with Container

use of com.vaadin.v7.data.Container in project charts by vaadin.

the class ChartsDemoUI method init.

@Override
protected void init(VaadinRequest request) {
    initGATracker();
    tabSheet = new TabSheet();
    tabSheet.addSelectedTabChangeListener(new TabSheet.SelectedTabChangeListener() {

        @Override
        public void selectedTabChange(TabSheet.SelectedTabChangeEvent event) {
            com.vaadin.ui.JavaScript.eval("setTimeout(function(){prettyPrint();},300);");
        }
    });
    tabSheet.setSizeFull();
    tabSheet.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR);
    Link homepage = new Link("Home page", new ExternalResource("https://vaadin.com/add-ons/charts"));
    Link javadoc = new Link("JavaDoc", new ExternalResource("http://demo.vaadin.com/javadoc/com.vaadin/vaadin-charts/" + getVersion() + "/"));
    Link manual = new Link("Manual", new ExternalResource("https://vaadin.com/docs/-/part/charts/charts-overview.html"));
    Label version = new Label("Version " + getVersion());
    version.addStyleName("version");
    HorizontalLayout links = new HorizontalLayout(homepage, javadoc, manual);
    links.setSpacing(true);
    links.addStyleName("links");
    final HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel();
    horizontalSplitPanel.setSecondComponent(tabSheet);
    horizontalSplitPanel.setSplitPosition(300, Unit.PIXELS);
    horizontalSplitPanel.addStyleName("main-layout");
    ChartOptions.get().setTheme(new ValoLightTheme());
    themeSelector = new ComboBox("Charts Theme:");
    themeSelector.addStyleName("theme-selector");
    themeSelector.addStyleName(ValoTheme.COMBOBOX_SMALL);
    themeSelector.setTextInputAllowed(false);
    com.vaadin.addon.charts.model.style.Theme defaultTheme = new ValoLightTheme();
    Map<com.vaadin.addon.charts.model.style.Theme, String> mapThemes = new HashMap<>();
    com.vaadin.addon.charts.model.style.Theme[] themes = new com.vaadin.addon.charts.model.style.Theme[] { defaultTheme, new ValoDarkTheme(), new VaadinTheme(), new HighChartsDefaultTheme(), new GridTheme(), new GrayTheme(), new SkiesTheme() };
    mapThemes.put(themes[0], "Valo Light");
    mapThemes.put(themes[1], "Valo Dark");
    mapThemes.put(themes[2], "Vaadin");
    mapThemes.put(themes[3], "HighCharts");
    mapThemes.put(themes[4], "Grid");
    mapThemes.put(themes[5], "Gray");
    mapThemes.put(themes[6], "Skies");
    themeSelector.setEmptySelectionAllowed(false);
    themeSelector.setItems(themes);
    themeSelector.setSelectedItem(defaultTheme);
    themeSelector.setItemCaptionGenerator(mapThemes::get);
    themeSelector.addSelectionListener(e -> {
        ChartOptions.get().setTheme(e.getValue());
    });
    final HierarchicalContainer container = getContainer();
    VerticalLayout content = new VerticalLayout();
    content.setSpacing(true);
    content.setMargin(false);
    Label logo = new Label("Vaadin Charts");
    logo.setWidth("100%");
    logo.addStyleName("h3");
    logo.addStyleName("logo");
    TextField filterField = new TextField();
    filterField.setPlaceholder("Filter examples");
    filterField.setIcon(FontAwesome.SEARCH);
    filterField.addStyleName("filter");
    filterField.setWidth("100%");
    filterField.addValueChangeListener(e -> {
        container.removeAllContainerFilters();
        String text = e.getValue();
        if (text != null && !text.isEmpty()) {
            expandForFiltering();
            container.addContainerFilter("searchName", text, true, false);
        } else {
            restoreExpandedStates();
        }
    });
    tree = new Tree();
    tree.setImmediate(true);
    tree.setContainerDataSource(container);
    tree.setItemCaptionPropertyId("displayName");
    tree.setNullSelectionAllowed(false);
    tree.setWidth("100%");
    tree.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            Object value = event.getProperty().getValue();
            if (value instanceof Class) {
                updateTabSheet((Class) value);
            } else {
                tree.expandItemsRecursively(value);
            }
        }
    });
    Button feedback = new Button("Got feedback?", FontAwesome.COMMENTING_O);
    feedback.addStyleName("feedback-button");
    feedback.addStyleName(ValoTheme.BUTTON_PRIMARY);
    feedback.addStyleName(ValoTheme.BUTTON_TINY);
    feedback.addClickListener(e -> {
        getUI().addWindow(new FeedbackForm());
    });
    content.addComponents(logo, links, feedback, filterField, tree, version);
    content.setComponentAlignment(feedback, Alignment.MIDDLE_CENTER);
    horizontalSplitPanel.setFirstComponent(content);
    selectItem();
    Page.getCurrent().addUriFragmentChangedListener(new Page.UriFragmentChangedListener() {

        @Override
        public void uriFragmentChanged(Page.UriFragmentChangedEvent event) {
            selectItem();
        }
    });
    setContent(new CssLayout() {

        {
            setSizeFull();
            addComponent(horizontalSplitPanel);
            addComponent(themeSelector);
        }
    });
    if (tracker != null) {
        tracker.trackPageview("/charts");
    }
}
Also used : SkiesTheme(com.vaadin.addon.charts.themes.SkiesTheme) HighChartsDefaultTheme(com.vaadin.addon.charts.themes.HighChartsDefaultTheme) ValoLightTheme(com.vaadin.addon.charts.themes.ValoLightTheme) HashMap(java.util.HashMap) Label(com.vaadin.ui.Label) VaadinTheme(com.vaadin.addon.charts.themes.VaadinTheme) Page(com.vaadin.server.Page) GrayTheme(com.vaadin.addon.charts.themes.GrayTheme) HorizontalLayout(com.vaadin.ui.HorizontalLayout) ValoDarkTheme(com.vaadin.addon.charts.themes.ValoDarkTheme) CssLayout(com.vaadin.ui.CssLayout) Button(com.vaadin.ui.Button) VerticalLayout(com.vaadin.ui.VerticalLayout) TextField(com.vaadin.ui.TextField) Tree(com.vaadin.v7.ui.Tree) Property(com.vaadin.v7.data.Property) ComboBox(com.vaadin.ui.ComboBox) GridTheme(com.vaadin.addon.charts.themes.GridTheme) ExternalResource(com.vaadin.server.ExternalResource) TabSheet(com.vaadin.ui.TabSheet) HorizontalSplitPanel(com.vaadin.ui.HorizontalSplitPanel) ValoLightTheme(com.vaadin.addon.charts.themes.ValoLightTheme) ValoDarkTheme(com.vaadin.addon.charts.themes.ValoDarkTheme) ValoTheme(com.vaadin.ui.themes.ValoTheme) Theme(com.vaadin.annotations.Theme) GrayTheme(com.vaadin.addon.charts.themes.GrayTheme) VaadinTheme(com.vaadin.addon.charts.themes.VaadinTheme) GridTheme(com.vaadin.addon.charts.themes.GridTheme) HighChartsDefaultTheme(com.vaadin.addon.charts.themes.HighChartsDefaultTheme) SkiesTheme(com.vaadin.addon.charts.themes.SkiesTheme) HierarchicalContainer(com.vaadin.v7.data.util.HierarchicalContainer) Link(com.vaadin.ui.Link)

Example 8 with Container

use of com.vaadin.v7.data.Container in project charts by vaadin.

the class ExampleUtil method getOrderContainer.

public static IndexedContainer getOrderContainer() {
    IndexedContainer container = new IndexedContainer();
    // Create the container properties
    container.addContainerProperty(ORDER_DESCRIPTION_PROPERTY_ID, String.class, "");
    container.addContainerProperty(ORDER_QUANTITY_PROPERTY_ID, Integer.class, 0);
    container.addContainerProperty(ORDER_UNITPRICE_PROPERTY_ID, Double.class, 0);
    container.addContainerProperty(ORDER_ITEMPRICE_PROPERTY_ID, Double.class, 0);
    // Create some orders
    addOrderToContainer(container, "Domain Name", 3, 7.99);
    addOrderToContainer(container, "SSL Certificate", 1, 119.00);
    addOrderToContainer(container, "Web Hosting", 1, 19.95);
    addOrderToContainer(container, "Email Box", 20, 0.15);
    addOrderToContainer(container, "E-Commerce Setup", 1, 25.00);
    addOrderToContainer(container, "Technical Support", 1, 50.00);
    return container;
}
Also used : IndexedContainer(com.vaadin.v7.data.util.IndexedContainer)

Example 9 with Container

use of com.vaadin.v7.data.Container 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)

Example 10 with Container

use of com.vaadin.v7.data.Container in project charts by vaadin.

the class ChartWithExternalContainer method createContainerView2.

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

Aggregations

ContainerDataSeries (com.vaadin.v7.addon.charts.model.ContainerDataSeries)5 Table (com.vaadin.v7.ui.Table)5 Item (com.vaadin.v7.data.Item)4 HorizontalLayout (com.vaadin.ui.HorizontalLayout)3 Container (com.vaadin.v7.data.Container)3 IndexedContainer (com.vaadin.v7.data.util.IndexedContainer)3 Sparkline (com.vaadin.addon.charts.Sparkline)2 ExternalResource (com.vaadin.server.ExternalResource)2 Component (com.vaadin.ui.Component)2 Label (com.vaadin.ui.Label)2 Link (com.vaadin.ui.Link)2 VerticalLayout (com.vaadin.ui.VerticalLayout)2 Property (com.vaadin.v7.data.Property)2 BeanItemContainer (com.vaadin.v7.data.util.BeanItemContainer)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 AbstractVaadinChartExample (com.vaadin.addon.charts.examples.AbstractVaadinChartExample)1 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)1 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)1 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)1