Search in sources :

Example 6 with PlotOptionsScatter

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

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

Chart (com.vaadin.addon.charts.Chart)7 DataSeries (com.vaadin.addon.charts.model.DataSeries)7 PlotOptionsScatter (com.vaadin.addon.charts.model.PlotOptionsScatter)7 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)5 XAxis (com.vaadin.addon.charts.model.XAxis)5 Configuration (com.vaadin.addon.charts.model.Configuration)4 YAxis (com.vaadin.addon.charts.model.YAxis)4 Bottom (com.vaadin.addon.charts.model.Bottom)2 Frame (com.vaadin.addon.charts.model.Frame)2 Marker (com.vaadin.addon.charts.model.Marker)2 Options3d (com.vaadin.addon.charts.model.Options3d)2 PlotOptionsPolygon (com.vaadin.addon.charts.model.PlotOptionsPolygon)2 ChartSelectionEvent (com.vaadin.addon.charts.ChartSelectionEvent)1 ChartSelectionListener (com.vaadin.addon.charts.ChartSelectionListener)1 Hover (com.vaadin.addon.charts.model.Hover)1 ListSeries (com.vaadin.addon.charts.model.ListSeries)1 PlotOptionsArearange (com.vaadin.addon.charts.model.PlotOptionsArearange)1 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)1 RangeSeries (com.vaadin.addon.charts.model.RangeSeries)1 States (com.vaadin.addon.charts.model.States)1