Skip to content

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 })

Parameters ​

An ellipse. Box geometry via the shared dims channels; paint is a strict subset of paint (no filter).

OptionTypeDefaultDescription
fillstring | FieldExprFill color, or a field name for a color scale.
strokestring | FieldExprStroke color. Defaults to fill.
strokeWidthnumber0Stroke width in pixels.
opacitynumber1Opacity, 0 to 1.
aspectRationumberw/h ratio to enforce. When both dims are data-driven, the constraining axis is used.
debugbooleanDev-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 ​

OptionTypeDefaultDescription
xnumber | string | FieldExprLeft edge position.
cxnumber | string | FieldExprCenter x.
x2number | string | FieldExprRight edge position.
wnumber | string | FieldExprWidth.
emXbooleanEmbed x in the parent's x space.
ynumber | string | FieldExprTop/bottom edge position (y-up: bottom).
cynumber | string | FieldExprCenter y.
y2number | string | FieldExprOther y edge position.
hnumber | string | FieldExprHeight.
emYbooleanEmbed y in the parent's y space.
dimsRecord<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 });

See Also ​

  • circle — Equal width and height (circular shape)
  • rect — Rectangular shape