ellipse
Draws an ellipse. Unlike circle, allows independent control of width and height.
js
gf.ellipse({ w: 100, h: 60, fill: "mediumseagreen" }).render(root, {
w: 150,
h: 100,
});Signature
ts
ellipse({ w?, h?, fill?, stroke?, strokeWidth?, opacity = 1, fillOpacity? })Parameters
An ellipse. Box geometry via the shared dims channels; paint is paint plus fillOpacity.
| Option | Type | Default | Description |
|---|---|---|---|
w | number | string | FieldExpr | Length | Width. Also percent(n), n percent of the room it is laid out in (its parent's, or the canvas), or fr(k), k shares of the room its nearest scope divides. | |
h | number | string | FieldExpr | Length | Height. Also percent(n), n percent of the room it is laid out in (its parent's, or the canvas), or fr(k), k shares of the room its nearest scope divides. | |
filter | Filter | string | A filter over this whole drawing: a Filter strategy (Filter.grayscale(), Filter.luminanceToAlpha()) or a raw CSS filter string ("blur(2px)", "url(#shadow)"). | |
fill | string | FieldExpr | Fill color, or a field name for a color scale. | |
stroke | string | FieldExpr | Stroke color. Defaults to fill. | |
strokeWidth | number | 0 | Stroke width in pixels. |
opacity | number | 1 | Opacity, 0 to 1. |
fillOpacity | number | Opacity of the fill alone, 0 to 1. The stroke keeps opacity. | |
aspectRatio | number | w/h ratio to enforce. When both dims are data-driven, the constraining axis is used. | |
debug | boolean | Dev-only flag: logs this mark's key and datum to the console as it is built. It changes nothing about what is drawn. |
Box dimensions
| Option | Type | Default | Description |
|---|---|---|---|
x | number | string | FieldExpr | Left edge position. | |
cx | number | string | FieldExpr | Center x. | |
x2 | number | string | FieldExpr | Right edge position. | |
emX | boolean | Embed x in the parent's x space. | |
y | number | string | FieldExpr | Start edge on y: the top edge where y reads top-down, the bottom edge where it grows upward. | |
cy | number | string | FieldExpr | Center y. | |
y2 | number | string | FieldExpr | Other y edge position. | |
emY | boolean | Embed y in the parent's y space. | |
dims | Record<string, AxisDimsValue> | Box dimensions by axis name: x/y, or a name the enclosing coordinate space declares (polar theta/r, geo lon/lat). Each value is a position (like x) or an interval {min, center, max, size, embedded}. |
Examples
ts
// Fixed size ellipse
ellipse({ w: 80, h: 40, fill: "coral" });
// Ellipse with stroke
ellipse({ w: 60, h: 30, fill: "white", stroke: "black", strokeWidth: 2 });
// Data-driven dimensions
ellipse({ w: "width", h: "height", fill: "category" });
// Translucent ellipse
ellipse({ w: 80, h: 40, fill: "coral", opacity: 0.5 });