> Markdown version of [Polygon](https://vaadin.com/docs/next/components/charts/charttypes/polygon). Section index: [llms.txt](https://vaadin.com/docs/next/components/llms.txt)

# <a id="charts.charttypes.polygon"></a>Polygons

A polygon can be used to draw any freeform filled or stroked shape in the Cartesian plane.

Polygons consist of connected data points. `DataSeries` or `ContainerSeries` are usually the most meaningful data series types for polygon charts. In both cases, the `x` and `y` properties should be set.

[Image: charts polygon]

Polygon Combined with Scatter

Polygons have chart type `POLYGON`.

For example:

```java
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);
```

## <a id="charts.charttypes.polygon.plotoptions"></a>Plot Options

Polygon chart options can be configured in a `PlotOptionsPolygon` object, although it doesn’t have any chart-type-specific options.

## <a id="polygon-example"></a>Polygon Example

**Flow** — `ChartTypePolygon.java`

```java
Chart chart = new Chart(ChartType.POLYGON);

Configuration conf = chart.getConfiguration();

chart.setId("chart");
conf.getChart().getZooming().setType(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);
```
