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;
}
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;
}
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);
}
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);
}
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;
}
Aggregations