Search in sources :

Example 96 with DataSeries

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

the class UtcTimeDataAndTooltipDateFormat method getChart.

@Override
protected Component getChart() {
    Chart chart = new Chart();
    chart.setHeight("450px");
    chart.setWidth("100%");
    Configuration configuration = chart.getConfiguration();
    configuration.setTitle("Time and date in tooltip");
    configuration.getChart().setType(ChartType.SPLINE);
    configuration.getxAxis().setType(AxisType.DATETIME);
    // Finnish convention for date formatting
    configuration.getTooltip().setXDateFormat("%d.%m. %Y %H:%M");
    // This test uses UTC time stamps, this way chart is independent about
    // execution environment, unlike when using Date
    TimeZone timeZone = TimeZone.getTimeZone("GMT");
    Calendar c = Calendar.getInstance(timeZone);
    c.set(Calendar.MILLISECOND, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.HOUR_OF_DAY, 12);
    c.set(2013, 2, 11);
    DataSeries dataSeries = new DataSeries();
    Number[] values = new Number[] { 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4 };
    Random r = new Random(0);
    for (Number number : values) {
        c.add(Calendar.MINUTE, r.nextInt(30));
        DataSeriesItem item = new DataSeriesItem(c.getTimeInMillis(), number);
        dataSeries.add(item);
    }
    configuration.addSeries(dataSeries);
    chart.drawChart(configuration);
    return chart;
}
Also used : TimeZone(java.util.TimeZone) Configuration(com.vaadin.addon.charts.model.Configuration) Random(java.util.Random) Calendar(java.util.Calendar) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 97 with DataSeries

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

the class ChartTypes method chartTypesPieDataSnippet2.

public void chartTypesPieDataSnippet2() {
    DataSeriesItem earth = new DataSeriesItem("Earth", 12800);
    earth.setSliced(true);
    DataSeries series = new DataSeries();
    series.add(earth);
}
Also used : DataSeries(com.vaadin.addon.charts.model.DataSeries) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Example 98 with DataSeries

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

the class ChartTypes method chartTypesBoxplotPlotoptionsSnippet2.

public void chartTypesBoxplotPlotoptionsSnippet2() {
    Chart chart = new Chart(ChartType.BOXPLOT);
    Configuration conf = chart.getConfiguration();
    // Orienteering control point times for runners
    double[][] data = new double[5][5];
    DataSeries series = new DataSeries();
    for (double[] cpointtimes : data) {
        StatAnalysis analysis = new StatAnalysis(cpointtimes);
        series.add(new BoxPlotItem(analysis.low(), analysis.firstQuartile(), analysis.median(), analysis.thirdQuartile(), analysis.high()));
    }
    conf.setSeries(series);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) BoxPlotItem(com.vaadin.addon.charts.model.BoxPlotItem)

Example 99 with DataSeries

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

the class ChartTypes method chartTypesPolygon.

public void chartTypesPolygon() {
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Height vs Weight");
    XAxis xAxis = conf.getxAxis();
    xAxis.setStartOnTick(true);
    xAxis.setEndOnTick(true);
    xAxis.setShowLastLabel(true);
    xAxis.setTitle("Height (cm)");
    YAxis yAxis = conf.getyAxis();
    yAxis.setTitle("Weight (kg)");
    PlotOptionsScatter optionsScatter = new PlotOptionsScatter();
    DataSeries scatter = new DataSeries();
    scatter.setPlotOptions(optionsScatter);
    scatter.setName("Observations");
    scatter.add(new DataSeriesItem(160, 67));
    scatter.add(new DataSeriesItem(180, 75));
    conf.addSeries(scatter);
    DataSeries polygon = new DataSeries();
    PlotOptionsPolygon optionsPolygon = new PlotOptionsPolygon();
    optionsPolygon.setEnableMouseTracking(false);
    polygon.setPlotOptions(optionsPolygon);
    polygon.setName("Target");
    polygon.add(new DataSeriesItem(153, 42));
    polygon.add(new DataSeriesItem(149, 46));
    polygon.add(new DataSeriesItem(173, 52));
    polygon.add(new DataSeriesItem(166, 45));
    conf.addSeries(polygon);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsScatter(com.vaadin.addon.charts.model.PlotOptionsScatter) PlotOptionsPolygon(com.vaadin.addon.charts.model.PlotOptionsPolygon) DataSeries(com.vaadin.addon.charts.model.DataSeries) 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 100 with DataSeries

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

the class ChartTypes method chartTypesScatterSnippet1.

public void chartTypesScatterSnippet1() {
    Chart chart = new Chart(ChartType.SCATTER);
    chart.setWidth("500px");
    chart.setHeight("500px");
    // Modify the default configuration a bit
    Configuration conf = chart.getConfiguration();
    conf.setTitle("Random Sphere");
    // Disable legend
    conf.getLegend().setEnabled(false);
    PlotOptionsScatter options = new PlotOptionsScatter();
    // ... Give overall plot options here ...
    conf.setPlotOptions(options);
    DataSeries series = new DataSeries();
    for (int i = 0; i < 300; i++) {
        double lng = Math.random() * 2 * Math.PI;
        double lat = Math.random() * Math.PI - Math.PI / 2;
        double x = Math.cos(lat) * Math.sin(lng);
        double y = Math.sin(lat);
        double z = Math.cos(lng) * Math.cos(lat);
        DataSeriesItem point = new DataSeriesItem(x, y);
        Marker marker = new Marker();
        // Make settings as described later
        point.setMarker(marker);
        series.add(point);
    }
    conf.addSeries(series);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsScatter(com.vaadin.addon.charts.model.PlotOptionsScatter) DataSeries(com.vaadin.addon.charts.model.DataSeries) Marker(com.vaadin.addon.charts.model.Marker) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Aggregations

DataSeries (com.vaadin.addon.charts.model.DataSeries)118 Chart (com.vaadin.addon.charts.Chart)81 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)81 Configuration (com.vaadin.addon.charts.model.Configuration)71 YAxis (com.vaadin.addon.charts.model.YAxis)38 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)26 XAxis (com.vaadin.addon.charts.model.XAxis)25 DataLabels (com.vaadin.addon.charts.model.DataLabels)21 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)17 Tooltip (com.vaadin.addon.charts.model.Tooltip)15 Test (org.junit.Test)15 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)14 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)14 Marker (com.vaadin.addon.charts.model.Marker)13 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)13 Style (com.vaadin.addon.charts.model.style.Style)10 Random (java.util.Random)10 Legend (com.vaadin.addon.charts.model.Legend)9 PlotLine (com.vaadin.addon.charts.model.PlotLine)9 StockPrices (com.vaadin.addon.charts.examples.timeline.util.StockPrices)8