use of com.vaadin.addon.charts.model.Navigator in project charts by vaadin.
the class Timeline method chartsTimelineIntroSnippet1.
public void chartsTimelineIntroSnippet1() {
Chart chart = new Chart();
Configuration configuration = chart.getConfiguration();
Navigator navigator = configuration.getNavigator();
navigator.setEnabled(true);
navigator.setMargin(75);
PlotOptionsSeries plotOptions = new PlotOptionsSeries();
plotOptions.setColor(SolidColor.BROWN);
navigator.setSeries(plotOptions);
}
use of com.vaadin.addon.charts.model.Navigator in project charts by vaadin.
the class BasicLineWithNavigator method getChart.
@Override
protected Component getChart() {
Chart chart = new Chart();
chart.setHeight("450px");
chart.setWidth("100%");
Configuration configuration = chart.getConfiguration();
configuration.getChart().setType(ChartType.LINE);
configuration.getChart().setMarginRight(130);
configuration.getChart().setMarginBottom(25);
configuration.getTitle().setText("Monthly Average Temperature");
configuration.getSubTitle().setText("Source: WorldClimate.com");
configuration.getxAxis().setType(AxisType.DATETIME);
YAxis yAxis = configuration.getyAxis();
yAxis.setMin(-5d);
yAxis.setTitle(new AxisTitle("Temperature (°C)"));
yAxis.getTitle().setAlign(VerticalAlign.MIDDLE);
DataSeries ds = new DataSeries();
ds.setName("Tokyo");
List<Double> values = Arrays.asList(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6);
Calendar calendar = getCalendar();
for (Double value : values) {
DataSeriesItem item = new DataSeriesItem(calendar.getTime(), value);
ds.add(item);
calendar.add(Calendar.MONTH, 1);
}
configuration.addSeries(ds);
ds = new DataSeries();
ds.setName("New York");
values = Arrays.asList(-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5);
calendar = getCalendar();
for (Double value : values) {
DataSeriesItem item = new DataSeriesItem(calendar.getTime(), value);
ds.add(item);
calendar.add(Calendar.MONTH, 1);
}
configuration.addSeries(ds);
Navigator navigator = configuration.getNavigator();
navigator.setMargin(75);
navigator.setEnabled(true);
chart.drawChart(configuration);
return chart;
}
Aggregations