Search in sources :

Example 71 with DataSeriesItem

use of com.vaadin.addon.charts.model.DataSeriesItem 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 72 with DataSeriesItem

use of com.vaadin.addon.charts.model.DataSeriesItem 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 73 with DataSeriesItem

use of com.vaadin.addon.charts.model.DataSeriesItem 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 74 with DataSeriesItem

use of com.vaadin.addon.charts.model.DataSeriesItem 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)

Example 75 with DataSeriesItem

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

the class ChartTypes method chartTypesPieDataSnippet1.

public void chartTypesPieDataSnippet1() {
    Chart chart = new Chart();
    Configuration conf = chart.getConfiguration();
    DataSeries series = new DataSeries();
    series.add(new DataSeriesItem("Mercury", 4900));
    series.add(new DataSeriesItem("Venus", 12100));
    conf.addSeries(series);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) DataSeries(com.vaadin.addon.charts.model.DataSeries) Chart(com.vaadin.addon.charts.Chart) DataSeriesItem(com.vaadin.addon.charts.model.DataSeriesItem)

Aggregations

DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)88 DataSeries (com.vaadin.addon.charts.model.DataSeries)81 Chart (com.vaadin.addon.charts.Chart)57 Configuration (com.vaadin.addon.charts.model.Configuration)51 YAxis (com.vaadin.addon.charts.model.YAxis)27 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)19 DataLabels (com.vaadin.addon.charts.model.DataLabels)17 XAxis (com.vaadin.addon.charts.model.XAxis)17 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)12 Random (java.util.Random)12 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)11 Test (org.junit.Test)11 Tooltip (com.vaadin.addon.charts.model.Tooltip)10 Marker (com.vaadin.addon.charts.model.Marker)9 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)8 PlotLine (com.vaadin.addon.charts.model.PlotLine)7 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)7 StockPrices (com.vaadin.addon.charts.examples.timeline.util.StockPrices)6 ListSeries (com.vaadin.addon.charts.model.ListSeries)6 Style (com.vaadin.addon.charts.model.style.Style)6