Search in sources :

Example 1 with PlotOptionsPolygon

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

the class ScatterAndPolygon method getChart.

@Override
protected Component getChart() {
    final Chart chart = new Chart(ChartType.SCATTER);
    Configuration conf = chart.getConfiguration();
    chart.setId("chart");
    conf.getChart().setZoomType(ZoomType.XY);
    conf.disableCredits();
    conf.setTitle("Height vs Weight");
    conf.setSubTitle("Polygon series in Vaadin Charts.");
    Tooltip tooltip = conf.getTooltip();
    tooltip.setHeaderFormat("<b>{series.name}</b><br>");
    tooltip.setPointFormat("{point.x} cm, {point.y} kg");
    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 plotOptionsScatter = new PlotOptionsScatter();
    DataSeries scatter = new DataSeries();
    scatter.setPlotOptions(plotOptionsScatter);
    scatter.setName("Observations");
    fillScatter(scatter);
    DataSeries polygon = new DataSeries();
    PlotOptionsPolygon plotOptionsPolygon = new PlotOptionsPolygon();
    plotOptionsPolygon.setEnableMouseTracking(false);
    polygon.setPlotOptions(plotOptionsPolygon);
    polygon.setName("Target");
    polygon.add(new DataSeriesItem(153, 42));
    polygon.add(new DataSeriesItem(149, 46));
    polygon.add(new DataSeriesItem(149, 55));
    polygon.add(new DataSeriesItem(152, 60));
    polygon.add(new DataSeriesItem(159, 70));
    polygon.add(new DataSeriesItem(170, 77));
    polygon.add(new DataSeriesItem(180, 70));
    polygon.add(new DataSeriesItem(180, 60));
    polygon.add(new DataSeriesItem(173, 52));
    polygon.add(new DataSeriesItem(166, 45));
    conf.addSeries(polygon);
    conf.addSeries(scatter);
    return chart;
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsScatter(com.vaadin.addon.charts.model.PlotOptionsScatter) PlotOptionsPolygon(com.vaadin.addon.charts.model.PlotOptionsPolygon) Tooltip(com.vaadin.addon.charts.model.Tooltip) 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 2 with PlotOptionsPolygon

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

Aggregations

Chart (com.vaadin.addon.charts.Chart)2 Configuration (com.vaadin.addon.charts.model.Configuration)2 DataSeries (com.vaadin.addon.charts.model.DataSeries)2 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)2 PlotOptionsPolygon (com.vaadin.addon.charts.model.PlotOptionsPolygon)2 PlotOptionsScatter (com.vaadin.addon.charts.model.PlotOptionsScatter)2 XAxis (com.vaadin.addon.charts.model.XAxis)2 YAxis (com.vaadin.addon.charts.model.YAxis)2 Tooltip (com.vaadin.addon.charts.model.Tooltip)1