Search in sources :

Example 96 with VerticalLayout

use of com.vaadin.ui.VerticalLayout in project charts by vaadin.

the class ResizeInsideVaadinComponent method getChart.

@Override
protected Component getChart() {
    VerticalSplitPanel verticalSplitPanel = new VerticalSplitPanel();
    HorizontalSplitPanel horizontalSplitPanel = new HorizontalSplitPanel();
    horizontalSplitPanel.setSecondComponent(verticalSplitPanel);
    verticalSplitPanel.setFirstComponent(createChart());
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setMargin(true);
    verticalLayout.setSpacing(true);
    verticalLayout.addComponent(new Label("Relatively sized components resize themselves automatically when in Vaadin component."));
    Button button = new Button("Open in a window");
    button.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Window window = new Window("Chart windodw");
            VerticalLayout layout = new VerticalLayout(createChart());
            layout.setMargin(true);
            layout.setSizeFull();
            window.setContent(layout);
            window.setWidth("50%");
            window.setHeight("50%");
            getUI().addWindow(window);
        }
    });
    verticalLayout.addComponent(button);
    horizontalSplitPanel.setFirstComponent(verticalLayout);
    return horizontalSplitPanel;
}
Also used : Window(com.vaadin.ui.Window) Button(com.vaadin.ui.Button) HorizontalSplitPanel(com.vaadin.ui.HorizontalSplitPanel) ClickEvent(com.vaadin.ui.Button.ClickEvent) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) VerticalSplitPanel(com.vaadin.ui.VerticalSplitPanel) ClickListener(com.vaadin.ui.Button.ClickListener)

Example 97 with VerticalLayout

use of com.vaadin.ui.VerticalLayout in project charts by vaadin.

the class TreeMapPointClick method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.TREEMAP);
    chart.addPointClickListener(new PointClickListener() {

        @Override
        public void onClick(PointClickEvent event) {
            lastAction.setValue(event.getClass().getSimpleName());
        }
    });
    chart.getConfiguration().addSeries(createSeries());
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.addComponent(chart);
    verticalLayout.addComponent(lastAction);
    return verticalLayout;
}
Also used : PointClickListener(com.vaadin.addon.charts.PointClickListener) PointClickEvent(com.vaadin.addon.charts.PointClickEvent) VerticalLayout(com.vaadin.ui.VerticalLayout) Chart(com.vaadin.addon.charts.Chart)

Example 98 with VerticalLayout

use of com.vaadin.ui.VerticalLayout in project charts by vaadin.

the class BasicLineWithTickCount method getChart.

@Override
protected Component getChart() {
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(false);
    layout.setMargin(false);
    final Chart chart = new Chart(ChartType.LINE);
    chart.setHeight("400px");
    chart.setWidth("100%");
    Configuration configuration = chart.getConfiguration();
    configuration.getTitle().setText("Monthly Average Temperature");
    configuration.getSubTitle().setText("Source: WorldClimate.com");
    configuration.getxAxis().setCategories("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
    XAxis xAxis = configuration.getxAxis();
    Labels xLabels = new Labels();
    xLabels.setAutoRotation(new Number[] { -10, -20, -30, -40, 50, -60, -70, -80, -90 });
    xAxis.setLabels(xLabels);
    final YAxis yAxis = configuration.getyAxis();
    yAxis.setTickAmount(10);
    ListSeries ls = new ListSeries();
    ls.setName("Tokyo");
    ls.setData(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6);
    configuration.addSeries(ls);
    ls = new ListSeries();
    ls.setName("New York");
    ls.setData(-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5);
    configuration.addSeries(ls);
    layout.addComponent(chart);
    final Slider slider = new Slider("Tick count (2 - 16)", 2, 16);
    slider.setWidth("200px");
    slider.setValue(10d);
    layout.addComponent(slider);
    layout.addComponent(new Button("Set max amount", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            slider.setValue(16d);
        }
    }));
    slider.addValueChangeListener(event -> {
        double newValue = slider.getValue();
        yAxis.setTickAmount(newValue);
        chart.drawChart();
    });
    return layout;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Slider(com.vaadin.ui.Slider) ListSeries(com.vaadin.addon.charts.model.ListSeries) Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) VerticalLayout(com.vaadin.ui.VerticalLayout) Labels(com.vaadin.addon.charts.model.Labels) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 99 with VerticalLayout

use of com.vaadin.ui.VerticalLayout in project charts by vaadin.

the class ChartTypes method chartTypesSolidGaugeDataSnippet2.

public void chartTypesSolidGaugeDataSnippet2() {
    VerticalLayout layout = new VerticalLayout();
    final ListSeries series = new ListSeries("Pressure MPa", 80);
    final TextField tf = new TextField("Enter a new value");
    layout.addComponent(tf);
    Button update = new Button("Update", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Integer newValue = new Integer(tf.getValue());
            series.updatePoint(0, newValue);
        }
    });
    layout.addComponent(update);
}
Also used : ListSeries(com.vaadin.addon.charts.model.ListSeries) Button(com.vaadin.ui.Button) VerticalLayout(com.vaadin.ui.VerticalLayout) TextField(com.vaadin.ui.TextField)

Example 100 with VerticalLayout

use of com.vaadin.ui.VerticalLayout in project charts by vaadin.

the class ChartTypes method chartTypesGaugeDataSnippet2.

public void chartTypesGaugeDataSnippet2() {
    VerticalLayout layout = new VerticalLayout();
    final ListSeries series = new ListSeries("Speed", 80);
    final TextField tf = new TextField("Enter a new value");
    layout.addComponent(tf);
    Button update = new Button("Update", new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Integer newValue = new Integer(tf.getValue());
            series.updatePoint(0, newValue);
            ;
        }
    });
    layout.addComponent(update);
}
Also used : ListSeries(com.vaadin.addon.charts.model.ListSeries) Button(com.vaadin.ui.Button) VerticalLayout(com.vaadin.ui.VerticalLayout) TextField(com.vaadin.ui.TextField)

Aggregations

VerticalLayout (com.vaadin.ui.VerticalLayout)101 Label (com.vaadin.ui.Label)38 HorizontalLayout (com.vaadin.ui.HorizontalLayout)25 Button (com.vaadin.ui.Button)24 Chart (com.vaadin.addon.charts.Chart)18 ClickEvent (com.vaadin.ui.Button.ClickEvent)15 Link (com.vaadin.ui.Link)15 ExternalResource (com.vaadin.server.ExternalResource)11 Configuration (com.vaadin.addon.charts.model.Configuration)10 ListSeries (com.vaadin.addon.charts.model.ListSeries)9 ClickListener (com.vaadin.ui.Button.ClickListener)8 PostConstruct (javax.annotation.PostConstruct)8 YAxis (com.vaadin.addon.charts.model.YAxis)7 DataSeries (com.vaadin.addon.charts.model.DataSeries)6 Panel (com.vaadin.ui.Panel)6 XAxis (com.vaadin.addon.charts.model.XAxis)5 Embedded (com.vaadin.ui.Embedded)5 TextField (com.vaadin.ui.TextField)5 PointClickEvent (com.vaadin.addon.charts.PointClickEvent)4 PointClickListener (com.vaadin.addon.charts.PointClickListener)4