Skip to content

packages/core/src/features/viz/lib/utc-scale-component.ts

Read as Markdown

This is the source snapshot used to build these API details. View this revision on GitHub.

Back to reference

1 import { resolveSignalValue, useLayoutBox } from "@pibbl/core";
2 import type { UTCScaleProps } from "./types.js";
3 import { resolveUtcScale } from "./utc-scale.js";
4 import { useScaleProvider } from "./scale-provider.js";
5 /**
6  * Provides a named utc mapping to descendant visualization components.
7  * @param props - Identity, domain, range, and children. See {@link UTCScaleProps}.
8  * @returns Descendant content within the scale scope.
9  */
10 export function UTCScale(props: UTCScaleProps) {
11   const { width, height } = useLayoutBox();
12   useScaleProvider(props.id, "utc", () => resolveUtcScale(
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 built with @pibbl/core 0.0.2, revision 2dccb19. ALPHA — NOT FOR PRODUCTION USE.