Search in sources :

Example 1 with Navigator

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);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Navigator(com.vaadin.addon.charts.model.Navigator) Chart(com.vaadin.addon.charts.Chart) PlotOptionsSeries(com.vaadin.addon.charts.model.PlotOptionsSeries)

Example 2 with Navigator

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;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Navigator(com.vaadin.addon.charts.model.Navigator) Calendar(java.util.Calendar) DataSeries(com.vaadin.addon.charts.model.DataSeries) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) YAxis(com.vaadin.addon.charts.model.YAxis)

Aggregations

Chart (com.vaadin.addon.charts.Chart)2 Configuration (com.vaadin.addon.charts.model.Configuration)2 Navigator (com.vaadin.addon.charts.model.Navigator)2 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)1 DataSeries (com.vaadin.addon.charts.model.DataSeries)1 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)1 PlotOptionsSeries (com.vaadin.addon.charts.model.PlotOptionsSeries)1 YAxis (com.vaadin.addon.charts.model.YAxis)1 Calendar (java.util.Calendar)1