packages/core/src/features/viz/lib/log-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 { 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 version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision 2dccb19. ALPHA — NOT FOR PRODUCTION USE.