Search in sources :

Example 1 with RangeSeries

use of com.vaadin.addon.charts.model.RangeSeries in project charts by vaadin.

the class WebXYChartSelection method createScatterChart.

private Chart createScatterChart() {
    final Chart scatterChart = new Chart(ChartType.SCATTER);
    scatterChart.setId("chart");
    scatterChart.getConfiguration().getChart().setZoomType(ZoomType.XY);
    scatterChart.getConfiguration().disableCredits();
    scatterChart.getConfiguration().setTitle("Selections as area ranges");
    scatterChart.getConfiguration().setSubTitle("Drag with mouse to make selections. Click the legend items to toggle visibility.");
    PlotOptionsScatter scatterOptions = new PlotOptionsScatter();
    scatterOptions.setAnimation(false);
    scatterOptions.setPointStart(1);
    DataSeries series = new DataSeries();
    series.setPlotOptions(scatterOptions);
    series.setName("Original");
    Random random = new Random(0);
    for (int i = 0; i < 20; i++) {
        DataSeriesItem dsi = new DataSeriesItem();
        dsi.setY(random.nextInt(10));
        dsi.setX(random.nextInt(10));
        series.add(dsi);
    }
    scatterChart.getConfiguration().addSeries(series);
    scatterChart.addChartSelectionListener(new ChartSelectionListener() {

        @Override
        public void onSelection(ChartSelectionEvent event) {
            double xStart = event.getSelectionStart();
            double xEnd = event.getSelectionEnd();
            double yStart = event.getValueStart();
            double yEnd = event.getValueEnd();
            Number[][] data = new Number[][] { { xStart, yStart, yEnd }, { xEnd, yStart, yEnd } };
            PlotOptionsArearange areaRangePlot = new PlotOptionsArearange();
            areaRangePlot.setFillOpacity(0.1f);
            areaRangePlot.setLineWidth(0);
            RangeSeries selectionSeries = new RangeSeries("Selection", data);
            selectionSeries.setPlotOptions(areaRangePlot);
            scatterChart.getConfiguration().addSeries(selectionSeries);
            scatterChart.drawChart();
            areaRangePlot.setAnimation(false);
        }
    });
    scatterChart.drawChart();
    return scatterChart;
}
Also used : PlotOptionsScatter(com.vaadin.addon.charts.model.PlotOptionsScatter) Random(java.util.Random) RangeSeries(com.vaadin.addon.charts.model.RangeSeries) DataSeries(com.vaadin.addon.charts.model.DataSeries) ChartSelectionEvent(com.vaadin.addon.charts.ChartSelectionEvent) ChartSelectionListener(com.vaadin.addon.charts.ChartSelectionListener) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem) PlotOptionsArearange(com.vaadin.addon.charts.model.PlotOptionsArearange)

Example 2 with RangeSeries

use of com.vaadin.addon.charts.model.RangeSeries in project charts by vaadin.

the class ResizeInsideVaadinComponent method createChart.

private Chart createChart() {
    Chart chart = new Chart(ChartType.AREARANGE);
    chart.setSizeFull();
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Temperature variation by day");
    XAxis axis = new XAxis();
    axis.setType(AxisType.DATETIME);
    axis.setCrosshair(new Crosshair());
    conf.addxAxis(axis);
    conf.addyAxis(new YAxis());
    Tooltip tooltip = new Tooltip();
    tooltip.setShared(true);
    tooltip.setValueSuffix("°C");
    conf.setTooltip(tooltip);
    RangeSeries data = new RangeSeries("Temperatures", getRawData());
    conf.setSeries(data);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) RangeSeries(com.vaadin.addon.charts.model.RangeSeries) Crosshair(com.vaadin.addon.charts.model.Crosshair) Tooltip(com.vaadin.addon.charts.model.Tooltip) Chart(com.vaadin.addon.charts.Chart) XAxis(com.vaadin.addon.charts.model.XAxis) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 3 with RangeSeries

use of com.vaadin.addon.charts.model.RangeSeries in project charts by vaadin.

the class AreaRange method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart(ChartType.AREARANGE);
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Temperature variation by day");
    conf.getxAxis().setType(DATETIME);
    conf.getxAxis().setCrosshair(new Crosshair());
    conf.addyAxis(new YAxis());
    Tooltip tooltip = new Tooltip();
    tooltip.setShared(true);
    tooltip.setValueSuffix("°C");
    conf.setTooltip(tooltip);
    RangeSeries data = new RangeSeries("Temperatures", getRawData());
    conf.setSeries(data);
    chart.drawChart(conf);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) RangeSeries(com.vaadin.addon.charts.model.RangeSeries) Crosshair(com.vaadin.addon.charts.model.Crosshair) Tooltip(com.vaadin.addon.charts.model.Tooltip) Chart(com.vaadin.addon.charts.Chart) YAxis(com.vaadin.addon.charts.model.YAxis)

Example 4 with RangeSeries

use of com.vaadin.addon.charts.model.RangeSeries in project charts by vaadin.

the class ChartTypes method chartTypesRangeChartsSnippet1.

public void chartTypesRangeChartsSnippet1() {
    Chart chart = new Chart(ChartType.AREARANGE);
    chart.setWidth("400px");
    chart.setHeight("300px");
    // Modify the default configuration a bit
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Extreme Temperature Range in Finland");
    // Create the range series
    // Source: http://ilmatieteenlaitos.fi/lampotilaennatyksia
    RangeSeries series = new RangeSeries("Temperature Extremes", new Double[] { -51.5, 10.9 }, new Double[] { -49.0, 11.8 }, // 
    new Double[] { -47.0, 10.8 });
    conf.addSeries(series);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) RangeSeries(com.vaadin.addon.charts.model.RangeSeries) Chart(com.vaadin.addon.charts.Chart)

Example 5 with RangeSeries

use of com.vaadin.addon.charts.model.RangeSeries in project charts by vaadin.

the class ChartData method rangeDataSnippet1.

public void rangeDataSnippet1(Configuration conf) {
    RangeSeries series = new RangeSeries("Temperature Extremes");
    // Give low-high values in constructor
    series.add(new DataSeriesItem(0, -51.5, 10.9));
    series.add(new DataSeriesItem(1, -49.0, 11.8));
    // Set low-high values with setters
    DataSeriesItem point = new DataSeriesItem();
    point.setX(2);
    point.setLow(-44.3);
    point.setHigh(17.5);
    series.add(point);
}
Also used : RangeSeries(com.vaadin.addon.charts.model.RangeSeries) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Aggregations

RangeSeries (com.vaadin.addon.charts.model.RangeSeries)6 Chart (com.vaadin.addon.charts.Chart)4 Configuration (com.vaadin.addon.charts.model.Configuration)3 Crosshair (com.vaadin.addon.charts.model.Crosshair)2 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)2 Tooltip (com.vaadin.addon.charts.model.Tooltip)2 YAxis (com.vaadin.addon.charts.model.YAxis)2 ChartSelectionEvent (com.vaadin.addon.charts.ChartSelectionEvent)1 ChartSelectionListener (com.vaadin.addon.charts.ChartSelectionListener)1 DataSeries (com.vaadin.addon.charts.model.DataSeries)1 PlotOptionsArearange (com.vaadin.addon.charts.model.PlotOptionsArearange)1 PlotOptionsScatter (com.vaadin.addon.charts.model.PlotOptionsScatter)1 XAxis (com.vaadin.addon.charts.model.XAxis)1 Random (java.util.Random)1