use of com.vaadin.flow.component.charts.model.PlotOptionsPolygon in project flow-components by vaadin.
the class ScatterAndPolygon method initDemo.
@Override
public void initDemo() {
final Chart chart = new Chart(ChartType.SCATTER);
Configuration conf = chart.getConfiguration();
chart.setId("chart");
conf.getChart().setZoomType(Dimension.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);
add(chart);
}
Aggregations