Search in sources :

Example 46 with VerticalLayout

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

the class BasicLineWithAutoRotation 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();
    xAxis.getLabels().setAutoRotation(new Number[] { -10, -20, -30, -40, 50, -60, -70, -80, -90 });
    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("Width (50 - 100)", 50, 100);
    slider.setWidth("200px");
    slider.setValue(100d);
    layout.addComponent(slider);
    layout.addComponent(new Button("Set min width", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            slider.setValue(50d);
        }
    }));
    slider.addValueChangeListener(event -> {
        double newValue = slider.getValue();
        chart.setWidth((float) newValue, Unit.PERCENTAGE);
    });
    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) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis)

Example 47 with VerticalLayout

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

the class ExportingExample method getChart.

@Override
protected Component getChart() {
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSpacing(true);
    verticalLayout.addComponent(new Label(getDescription(), ContentMode.HTML));
    Chart chart = (Chart) super.getChart();
    // Enabling exporting adds a button to UI via users can download the
    // chart e.g. for printing
    Exporting exporting = new Exporting(true);
    // One can customize the filename
    exporting.setFilename("mychartfile");
    // Exporting is by default done on highcharts public servers, but you
    // can also use your own server
    // exporting.setUrl("http://my.own.server.com");
    // Actually use these settings in the chart
    chart.getConfiguration().setExporting(exporting);
    // Simpler boolean API can also be used to just toggle the service
    // on/off
    // chart.getConfiguration().setExporting(true);
    verticalLayout.addComponent(chart);
    return verticalLayout;
}
Also used : Exporting(com.vaadin.addon.charts.model.Exporting) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) Chart(com.vaadin.addon.charts.Chart)

Example 48 with VerticalLayout

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

the class GettingStarted method combinationChartPreparationsSnippet2.

public void combinationChartPreparationsSnippet2(VaadinRequest request) {
    Chart chart = new Chart();
    final VerticalLayout layout = new VerticalLayout();
    layout.addComponent(chart);
}
Also used : VerticalLayout(com.vaadin.ui.VerticalLayout) Chart(com.vaadin.addon.charts.Chart)

Example 49 with VerticalLayout

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

the class GettingStarted method combinationChartPreparationsSnippet1.

public void combinationChartPreparationsSnippet1(VaadinRequest request) {
    Chart chart = new Chart();
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    ChartsData data = new ChartsData();
    layout.addComponent(chart);
}
Also used : VerticalLayout(com.vaadin.ui.VerticalLayout) Chart(com.vaadin.addon.charts.Chart)

Example 50 with VerticalLayout

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

the class MasterDetailChart method getChart.

@Override
protected Component getChart() {
    VerticalLayout lo = new VerticalLayout();
    lo.setSpacing(false);
    lo.setMargin(false);
    lo.setWidth("100%");
    lo.setHeight("600px");
    final Chart masterChart = getMasterChart();
    final Chart detailChart = getDetailChart();
    masterChart.addChartSelectionListener(new ChartSelectionListener() {

        @Override
        public void onSelection(ChartSelectionEvent event) {
            long start = event.getSelectionStart().longValue();
            long end = event.getSelectionEnd().longValue();
            // set plot band to highlight the selection on the master chart
            PlotBand plotBand1 = new PlotBand();
            PlotBand plotBand2 = new PlotBand();
            plotBand1.setColor(new SolidColor(0, 0, 0, 0.2));
            plotBand2.setColor(new SolidColor(0, 0, 0, 0.2));
            plotBand1.setFrom(Util.toHighchartsTS(DEMO_DATASET_START.atStartOfDay().toInstant(ZoneOffset.UTC)));
            plotBand1.setTo(start);
            plotBand2.setFrom(end);
            plotBand2.setTo(Util.toHighchartsTS(DEMO_DATASET_END.atStartOfDay().toInstant(ZoneOffset.UTC)));
            masterChart.getConfiguration().getxAxis().setPlotBands(plotBand1, plotBand2);
            masterChart.drawChart();
            List<Number> list = MasterDetailChart.this.getPartialList(start, end);
            Configuration configuration = detailChart.getConfiguration();
            configuration.getChart().setAnimation(false);
            ListSeries detailData = (ListSeries) configuration.getSeries().get(0);
            PlotOptionsLine plotOptionsLine = (PlotOptionsLine) detailData.getPlotOptions();
            plotOptionsLine.setPointStart(start);
            detailData.setData(list);
            detailChart.drawChart(configuration);
        }
    });
    lo.addComponent(detailChart);
    lo.addComponent(masterChart);
    return lo;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) VerticalLayout(com.vaadin.ui.VerticalLayout) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) ArrayList(java.util.ArrayList) List(java.util.List) ChartSelectionEvent(com.vaadin.addon.charts.ChartSelectionEvent) ChartSelectionListener(com.vaadin.addon.charts.ChartSelectionListener) PlotBand(com.vaadin.addon.charts.model.PlotBand) Chart(com.vaadin.addon.charts.Chart)

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