Skip to content

TransformGroup

TransformGroup provides a shared domain, size, and padding to plot components in its default slot.

Import

ts
import { TransformGroup } from '@putianyi888/vue3-plots'

Example

vue
<TransformGroup ref="transformGroup" :domain="domain" :size="{ width: 640, height: 360 }">
  <Grid :x-ticks="xTicks" :y-ticks="yTicks" />
  <Line :points="points" />
  <Scatter :points="points" />
  <Axis direction="horizontal" :ticks="xTicks" />
  <Axis direction="vertical" :ticks="yTicks" />
</TransformGroup>

Props

PropTypeDefaultDescription
sizePlotSize{ width: 320, height: 200 }Outer SVG size provided to child plot layers.
paddingPlotPaddingdefaultPlotPaddingInsets provided to child plot layers.
domainPlotDomainRequiredData-space bounds provided to child plot layers.

Slots

SlotPropsDescription
defaultNonePlot layers that share this transform context.

Exposed

ExposedTypeDescription
scaleX(value: number) => numberMaps an x value from data coordinates to SVG coordinates.
scaleY(value: number) => numberMaps a y value from data coordinates to SVG coordinates.

Notes

Child components can still pass their own domain, size, or padding props. Explicit child props override the values from TransformGroup.

Use a template ref to access the exposed scaleX and scaleY functions when custom code needs the same coordinate transform as the plot layers.