Search in sources :

Example 51 with Chart

use of com.vaadin.addon.charts.Chart in project charts by vaadin.

the class BasicLineWithDataLabels 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.getTitle().setText("Monthly Average Temperature");
    configuration.getSubTitle().setText("Source: WorldClimate.com");
    configuration.getxAxis().setCategories("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    YAxis yAxis = configuration.getyAxis();
    yAxis.setTitle(new AxisTitle("Temperature (°C)"));
    configuration.getTooltip().setFormatter("'<b>'+ this.series.name +'</b><br/>'+this.x +': '+ this.y +'°C'");
    PlotOptionsLine plotOptions = new PlotOptionsLine();
    plotOptions.setDataLabels(new DataLabels(true));
    plotOptions.setEnableMouseTracking(false);
    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);
    ls = new ListSeries();
    ls.setName("London");
    ls.setData(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8);
    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) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 52 with Chart

use of com.vaadin.addon.charts.Chart 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 53 with Chart

use of com.vaadin.addon.charts.Chart in project charts by vaadin.

the class NoDataExample method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(PIE);
    Configuration conf = chart.getConfiguration();
    conf.getNoData().getPosition().setVerticalAlign(VerticalAlign.TOP);
    Lang lang = new Lang();
    lang.setNoData("Ups, there is no data to show, :'(");
    ChartOptions.get().setLang(lang);
    conf.setTitle("No data in pie chart");
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Lang(com.vaadin.addon.charts.model.Lang) Chart(com.vaadin.addon.charts.Chart)

Example 54 with Chart

use of com.vaadin.addon.charts.Chart in project charts by vaadin.

the class ChartPluginExamples method createHeatMap.

public static Chart createHeatMap() {
    final Chart chart = new Chart(CustomChartTypes.MAP);
    chart.setWidth("800px");
    chart.setHeight("500px");
    final Configuration configuration = chart.getConfiguration();
    ChartModel model = new ChartModel();
    configuration.setChart(model);
    model.setType(CustomChartTypes.MAP);
    model.setBorderWidth(1);
    model.setZoomType(ZoomType.XY);
    model.setInverted(false);
    configuration.getTitle().setText("Vaadin Charts Test for complex highcharts plugin");
    XAxis xAxis = configuration.getxAxis();
    xAxis.setEndOnTick(false);
    xAxis.setGridLineWidth(0);
    xAxis.getLabels().setEnabled(false);
    xAxis.setLineWidth(0);
    xAxis.setMinPadding(0);
    xAxis.setMaxPadding(0);
    xAxis.setStartOnTick(false);
    xAxis.setTickWidth(0);
    YAxis yAxis = configuration.getyAxis();
    yAxis.setEndOnTick(false);
    yAxis.setGridLineWidth(0);
    yAxis.getLabels().setEnabled(false);
    yAxis.setLineWidth(0);
    yAxis.setMinPadding(0);
    yAxis.setMaxPadding(0);
    yAxis.setStartOnTick(false);
    yAxis.setTickWidth(0);
    yAxis.setTitle("");
    yAxis.setReversed(true);
    Legend legend = configuration.getLegend();
    legend.setHorizontalAlign(HorizontalAlign.LEFT);
    legend.setVerticalAlign(VerticalAlign.BOTTOM);
    legend.setFloating(true);
    legend.setLayout(LayoutDirection.VERTICAL);
    configuration.setExporting(false);
    MapSeries series = new MapSeries();
    series.addValueRange(new ValueRange(null, 3, new SolidColor(19, 64, 117, 0.05)));
    series.addValueRange(new ValueRange(3, 10, new SolidColor(19, 64, 117, 0.2)));
    series.addValueRange(new ValueRange(10, 30, new SolidColor(19, 64, 117, 0.4)));
    series.addValueRange(new ValueRange(30, 100, new SolidColor(19, 64, 117, 0.5)));
    series.addValueRange(new ValueRange(100, 300, new SolidColor(19, 64, 117, 0.6)));
    series.addValueRange(new ValueRange(300, 1000, new SolidColor(19, 64, 117, 0.8)));
    series.addValueRange(new ValueRange(1000, null, new SolidColor(19, 64, 117, 1)));
    Random random = new Random();
    for (String c : Locale.getISOCountries()) {
        DataSeriesItem p = new DataSeriesItem(c.toLowerCase(), random.nextInt(1200));
        series.add(p);
    }
    configuration.addSeries(series);
    chart.drawChart(configuration);
    return chart;
}
Also used : ValueRange(com.vaadin.demo.chartplugin.model.ValueRange) Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) Random(java.util.Random) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) ChartModel(com.vaadin.addon.charts.model.ChartModel) MapSeries(com.vaadin.demo.chartplugin.model.MapSeries) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 55 with Chart

use of com.vaadin.addon.charts.Chart in project charts by vaadin.

the class Migration method exampleResult.

public Chart exampleResult() {
    Chart chart = new Chart();
    Configuration config = chart.getConfiguration();
    config.setTitle("Charts migration");
    config.getTitle().setAlign(HorizontalAlign.LEFT);
    Crosshair xCrossHair = new Crosshair();
    xCrossHair.setColor(SolidColor.BLACK);
    xCrossHair.setDashStyle(DashStyle.SOLID);
    xCrossHair.setWidth(10);
    xCrossHair.setZIndex(0);
    config.getxAxis().setCrosshair(xCrossHair);
    Crosshair yCrossHair = new Crosshair();
    yCrossHair.setColor(new SolidColor("#880000"));
    yCrossHair.setDashStyle(DashStyle.DOT);
    yCrossHair.setWidth(5);
    yCrossHair.setZIndex(1);
    config.getyAxis().setCrosshair(yCrossHair);
    config.getLegend().setEnabled(false);
    config.getTooltip().setEnabled(false);
    ListSeries ls = new ListSeries();
    ls.setName("Data");
    ls.setData(29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4);
    PlotOptionsAreaspline plotOptions = new PlotOptionsAreaspline();
    plotOptions.setColor(SolidColor.BURLYWOOD);
    plotOptions.setDataLabels(new DataLabels(false));
    ls.setPlotOptions(plotOptions);
    config.setSeries(ls);
    return chart;
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) ListSeries(com.vaadin.addon.charts.model.ListSeries) Crosshair(com.vaadin.addon.charts.model.Crosshair) PlotOptionsAreaspline(com.vaadin.addon.charts.model.PlotOptionsAreaspline) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Chart(com.vaadin.addon.charts.Chart)

Aggregations

Chart (com.vaadin.addon.charts.Chart)243 Configuration (com.vaadin.addon.charts.model.Configuration)196 YAxis (com.vaadin.addon.charts.model.YAxis)105 DataSeries (com.vaadin.addon.charts.model.DataSeries)81 ListSeries (com.vaadin.addon.charts.model.ListSeries)76 XAxis (com.vaadin.addon.charts.model.XAxis)71 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)57 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)55 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)50 DataLabels (com.vaadin.addon.charts.model.DataLabels)45 Tooltip (com.vaadin.addon.charts.model.Tooltip)44 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)34 Legend (com.vaadin.addon.charts.model.Legend)29 Marker (com.vaadin.addon.charts.model.Marker)23 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)21 Style (com.vaadin.addon.charts.model.style.Style)20 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)19 Labels (com.vaadin.addon.charts.model.Labels)18 VerticalLayout (com.vaadin.ui.VerticalLayout)18 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)16