Docs Charts Primitives

Polygon

React example follows below.
ts
import { Polygon } from "@grassroot/charts-react";
export default function PolygonDemo() {
return (
<div>
<svg
viewBox="0 0 360 220"
width="360"
height="220"
style={{ maxWidth: "100%" }}
role="img"
aria-label="Weekday electricity demand profile from 00:00 to 22:00, peaking at 18:00"
>
<title>Weekday electricity demand profile</title>
<Polygon
points={[
[28, 176],
[28, 154],
[52, 148],
[74, 136],
[98, 128],
[120, 118],
[144, 104],
[166, 86],
[188, 58],
[212, 44],
[236, 52],
[258, 76],
[282, 98],
[304, 122],
[332, 146],
[332, 176],
]}
fill="var(--accent)"
fillOpacity={0.24}
stroke="var(--accent)"
/>
<text x={220} y={38} fontSize={12} fill="var(--vs-chart-ink)">
Peak demand · 18:00
</text>
</svg>
</div>
);
}
ts
<script setup lang="ts">
import { Polygon } from "@grassroot/charts-vue";
</script>
<template>
<svg
viewBox="0 0 360 220"
width="360"
height="220"
style="max-width: 100%"
role="img"
aria-label="Weekday electricity demand profile from 00:00 to 22:00, peaking at 18:00"
>
<title>Weekday electricity demand profile</title>
<Polygon
:points="[
[28, 176],
[28, 154],
[52, 148],
[74, 136],
[98, 128],
[120, 118],
[144, 104],
[166, 86],
[188, 58],
[212, 44],
[236, 52],
[258, 76],
[282, 98],
[304, 122],
[332, 146],
[332, 176],
]"
fill="var(--accent)"
:fill-opacity="0.24"
stroke="var(--accent)"
/>
<text x="220" y="38" font-size="12" fill="var(--vs-chart-ink)">Peak demand · 18:00</text>
</svg>
</template>
ts
import { ChangeDetectionStrategy, Component } from "@angular/core";
import { GrassrootPolygon } from "@grassroot/charts-angular";
@Component({
selector: "app-polygon-chart-demo",
standalone: true,
imports: [GrassrootPolygon],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `<svg
viewBox="0 0 360 220"
width="360"
height="220"
style="max-width: 100%"
role="img"
aria-label="Weekday electricity demand profile from 00:00 to 22:00, peaking at 18:00"
>
<title>Weekday electricity demand profile</title>
<polygon
grassroot-polygon
[points]="[
[28, 176],
[28, 154],
[52, 148],
[74, 136],
[98, 128],
[120, 118],
[144, 104],
[166, 86],
[188, 58],
[212, 44],
[236, 52],
[258, 76],
[282, 98],
[304, 122],
[332, 146],
[332, 176],
]"
fill="var(--accent)"
[fillOpacity]="0.24"
stroke="var(--accent)"
></polygon>
<text x="220" y="38" font-size="12" fill="var(--vs-chart-ink)">Peak demand · 18:00</text>
</svg>`,
})
export class PolygonDemoComponent {}
export default PolygonDemoComponent;
ts
<script lang="ts">
import { Polygon } from "@grassroot/charts-svelte";
</script>
<svg
viewBox="0 0 360 220"
width="360"
height="220"
style="max-width: 100%"
role="img"
aria-label="Weekday electricity demand profile from 00:00 to 22:00, peaking at 18:00"
>
<title>Weekday electricity demand profile</title>
<Polygon
points={[
[28, 176],
[28, 154],
[52, 148],
[74, 136],
[98, 128],
[120, 118],
[144, 104],
[166, 86],
[188, 58],
[212, 44],
[236, 52],
[258, 76],
[282, 98],
[304, 122],
[332, 146],
[332, 176],
]}
fill="var(--accent)"
fillOpacity={0.24}
stroke="var(--accent)"
/>
<text x="220" y="38" font-size="12" fill="var(--vs-chart-ink)">Peak demand · 18:00</text>
</svg>
ts
/** @jsxImportSource solid-js */
import { Polygon } from "@grassroot/charts-solid";
export default function PolygonDemo() {
return (
<svg
viewBox="0 0 360 220"
width="360"
height="220"
style={{ "max-width": "100%" }}
role="img"
aria-label="Weekday electricity demand profile from 00:00 to 22:00, peaking at 18:00"
>
<title>Weekday electricity demand profile</title>
<Polygon
points={[
[28, 176],
[28, 154],
[52, 148],
[74, 136],
[98, 128],
[120, 118],
[144, 104],
[166, 86],
[188, 58],
[212, 44],
[236, 52],
[258, 76],
[282, 98],
[304, 122],
[332, 146],
[332, 176],
]}
fill="var(--accent)"
fillOpacity={0.24}
stroke="var(--accent)"
/>
<text x="220" y="38" font-size="12" fill="var(--vs-chart-ink)">
Peak demand · 18:00
</text>
</svg>
);
}

Installation

API Reference

Import

import { Polygon } from "@grassroot/charts-react";

Props

Prop
Type
Default
Requirement
points
readonly (readonly [number, number])[]
—
required
Prop
points
Type
readonly (readonly [number, number])[]
Default
—
Requirement
required

Native attributes

Standard DOM and ARIA attributes not listed above spread onto the root element.

Import

import { Polygon } from "@grassroot/charts-vue";

Props

Prop
Type
Default
Requirement
points
readonly (readonly [number, number])[]
—
required
fill
string | undefined
"var(--accent, #b5342a)"
optional
fillOpacity
number | undefined
0.18
optional
stroke
string | undefined
"var(--accent, #b5342a)"
optional
Prop
points
Type
readonly (readonly [number, number])[]
Default
—
Requirement
required
Prop
fill
Type
string | undefined
Default
"var(--accent, #b5342a)"
Requirement
optional
Prop
fillOpacity
Type
number | undefined
Default
0.18
Requirement
optional
Prop
stroke
Type
string | undefined
Default
"var(--accent, #b5342a)"
Requirement
optional

Import

import { ChangeDetectionStrategy, Component } from "@angular/core";
import { GrassrootPolygon } from "@grassroot/charts-angular";

Props

Prop
Type
Default
Requirement
points
readonly (readonly [number, number])[]
—
required
fill
string
"var(--accent, #b5342a)"
optional
fillOpacity
number
0.18
optional
stroke
string
"var(--accent, #b5342a)"
optional
Prop
points
Type
readonly (readonly [number, number])[]
Default
—
Requirement
required
Prop
fill
Type
string
Default
"var(--accent, #b5342a)"
Requirement
optional
Prop
fillOpacity
Type
number
Default
0.18
Requirement
optional
Prop
stroke
Type
string
Default
"var(--accent, #b5342a)"
Requirement
optional

Import

import { Polygon } from "@grassroot/charts-svelte";

Props

Prop
Type
Default
Requirement
points
readonly (readonly [number, number])[]
—
required
fill
string
"var(--accent, #b5342a)"
optional
fillOpacity
number
0.18
optional
stroke
string
"var(--accent, #b5342a)"
optional
class
string
—
optional
Prop
points
Type
readonly (readonly [number, number])[]
Default
—
Requirement
required
Prop
fill
Type
string
Default
"var(--accent, #b5342a)"
Requirement
optional
Prop
fillOpacity
Type
number
Default
0.18
Requirement
optional
Prop
stroke
Type
string
Default
"var(--accent, #b5342a)"
Requirement
optional
Prop
class
Type
string
Default
—
Requirement
optional

Import

import { Polygon } from "@grassroot/charts-solid";

Props

Prop
Type
Default
Requirement
points
readonly (readonly [number, number])[]
—
required
fill
string
—
optional
fillOpacity
number
—
optional
stroke
string
—
optional
class
string
—
optional
Prop
points
Type
readonly (readonly [number, number])[]
Default
—
Requirement
required
Prop
fill
Type
string
Default
—
Requirement
optional
Prop
fillOpacity
Type
number
Default
—
Requirement
optional
Prop
stroke
Type
string
Default
—
Requirement
optional
Prop
class
Type
string
Default
—
Requirement
optional

Native attributes

Standard DOM and ARIA attributes not listed above spread onto the root element.