packages/core/src/features/viz/lib/linear-scale-component.ts
This is the source snapshot used to build these API details. View this revision on GitHub.
1 import { resolveSignalValue, useLayoutBox } from "@pibbl/core";
2 import type { LinearScaleProps } from "./types.js";
3 import { resolveLinearScale } from "./linear-scale.js";
4 import { useScaleProvider } from "./scale-provider.js";
5 /**
6 * Provides a named linear mapping to descendant visualization components.
7 * @param props - Identity, domain, range, and children. See {@link LinearScaleProps}.
8 * @returns Descendant content within the scale scope.
9 */
10 export function LinearScale(props: LinearScaleProps) {
11 const { width, height } = useLayoutBox();
12 useScaleProvider(props.id, "linear", () => resolveLinearScale(
13 resolveSignalValue(props.domain), resolveSignalValue(props.range),
14 resolveSignalValue(props.reverse ?? false), width, height,
15 ), [props.domain, props.range, props.reverse, width, height]);
16 return props.children;
17 }
18
Documentation version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision 2dccb19. ALPHA — NOT FOR PRODUCTION USE.