Skip to content

packages/core/src/features/viz/lib/log-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 { LogScaleProps } from "./types.js";
3 import { resolveLogScale } from "./log-scale.js";
4 import { useScaleProvider } from "./scale-provider.js";
5 /**
6  * Provides a named positive logarithmic mapping to descendant marks and axes.
7  * @param props - Identity, positive domain, range, and optional tick base. See {@link LogScaleProps}.
8  * @returns Descendant content within the logarithmic scale scope.
9  */
10 export function LogScale(props: LogScaleProps) {
11   const { width, height } = useLayoutBox();
12   useScaleProvider(props.id, "log", () => resolveLogScale(
13     resolveSignalValue(props.domain), resolveSignalValue(props.range),
14     resolveSignalValue(props.reverse ?? false), width, height, resolveSignalValue(props.base ?? 10),
15   ), [props.domain, props.range, props.reverse, props.base, width, height]);
16   return props.children;
17 }
18 

Documentation built with @pibbl/core 0.0.2, revision 272a94a. ALPHA — NOT FOR PRODUCTION USE.