Search in sources :

Example 1 with CustomTheme

use of com.vaadin.addon.charts.examples.themes.CustomTheme in project charts by vaadin.

the class CustomThemeUI method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    chart.setHeight("450px");
    chart.setWidth("100%");
    ChartOptions.get().setTheme(new CustomTheme());
    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().setCategories(new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" });
    YAxis yAxis = configuration.getyAxis();
    yAxis.setMin(-5d);
    yAxis.setTitle(new AxisTitle("Temperature (°C)"));
    yAxis.getTitle().setAlign(VerticalAlign.MIDDLE);
    configuration.getTooltip().setFormatter("'<b>'+ this.series.name +'</b><br/>'+this.x +': '+ this.y +'°C'");
    PlotOptionsLine plotOptions = new PlotOptionsLine();
    plotOptions.setDataLabels(new DataLabels(true));
    configuration.setPlotOptions(plotOptions);
    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);
    chart.drawChart(configuration);
    return chart;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) ListSeries(com.vaadin.addon.charts.model.ListSeries) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Chart(com.vaadin.addon.charts.Chart) CustomTheme(com.vaadin.addon.charts.examples.themes.CustomTheme) YAxis(com.vaadin.addon.charts.model.YAxis)

Aggregations

Chart (com.vaadin.addon.charts.Chart)1 CustomTheme (com.vaadin.addon.charts.examples.themes.CustomTheme)1 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)1 Configuration (com.vaadin.addon.charts.model.Configuration)1 DataLabels (com.vaadin.addon.charts.model.DataLabels)1 ListSeries (com.vaadin.addon.charts.model.ListSeries)1 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)1 YAxis (com.vaadin.addon.charts.model.YAxis)1