semiotic 3.8.0 → 3.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +12 -9
- package/README.md +39 -39
- package/ai/dist/mcp-server.js +98 -17
- package/ai/schema.json +1 -1
- package/ai/surface-manifest.json +3 -2
- package/ai/system-prompt.md +3 -2
- package/dist/__tests__/scenarios/mcpProtocolTypes.d.ts +20 -0
- package/dist/components/AccessibleNavTree.d.ts +7 -1
- package/dist/components/ai/chartClinicMetadata.generated.d.ts +15 -0
- package/dist/components/ai/useNavigationSync.d.ts +17 -2
- package/dist/components/chartContainerMobile.d.ts +9 -0
- package/dist/components/charts/geo/ChoroplethMap.d.ts +19 -2
- package/dist/components/charts/geo/DistanceCartogram.d.ts +14 -2
- package/dist/components/charts/geo/FlowMap.d.ts +10 -6
- package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +14 -2
- package/dist/components/charts/index.d.ts +6 -0
- package/dist/components/charts/network/ChordDiagram.d.ts +9 -1
- package/dist/components/charts/network/ForceDirectedGraph.d.ts +11 -0
- package/dist/components/charts/network/SankeyDiagram.d.ts +9 -1
- package/dist/components/charts/ordinal/BarChart.d.ts +21 -0
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +11 -0
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +11 -0
- package/dist/components/charts/physics/CollisionSwarmChart.d.ts +7 -0
- package/dist/components/charts/physics/EventDropChart.d.ts +7 -0
- package/dist/components/charts/physics/GaltonBoardChart.d.ts +8 -0
- package/dist/components/charts/physics/PhysicsCustomChart.d.ts +4 -25
- package/dist/components/charts/physics/PhysicsPileChart.d.ts +7 -0
- package/dist/components/charts/physics/physicsChartShared.d.ts +17 -1
- package/dist/components/charts/physics/physicsCustomLayout.d.ts +32 -0
- package/dist/components/charts/shared/AnnotationLabel.d.ts +88 -0
- package/dist/components/charts/shared/annotationActivation.d.ts +35 -0
- package/dist/components/charts/shared/annotationLabelLayout.d.ts +5 -0
- package/dist/components/charts/shared/annotationRules.d.ts +2 -1
- package/dist/components/charts/shared/chartSelectionUtils.d.ts +4 -0
- package/dist/components/charts/shared/chartSpecCore.d.ts +3 -3
- package/dist/components/charts/shared/datumTypes.d.ts +2 -0
- package/dist/components/charts/shared/diagnoseAnnotationChecks.d.ts +2 -0
- package/dist/components/charts/shared/formatUtils.d.ts +3 -3
- package/dist/components/charts/shared/hatchFill.d.ts +87 -0
- package/dist/components/charts/shared/hooks.d.ts +7 -6
- package/dist/components/charts/shared/knownChartComponents.d.ts +9 -0
- package/dist/components/charts/shared/leastSquaresRegression.d.ts +16 -0
- package/dist/components/charts/shared/mergeShapeStyle.d.ts +3 -2
- package/dist/components/charts/shared/semanticInteractions.d.ts +42 -0
- package/dist/components/charts/shared/sparseArray.d.ts +1 -1
- package/dist/components/charts/shared/streamPropsHelpers.d.ts +6 -4
- package/dist/components/charts/shared/styleRules.d.ts +205 -0
- package/dist/components/charts/shared/tooltipUtils.d.ts +22 -9
- package/dist/components/charts/shared/types.d.ts +9 -6
- package/dist/components/charts/shared/useAreaSeriesSetup.d.ts +16 -2
- package/dist/components/charts/shared/useChartSetup.d.ts +2 -2
- package/dist/components/charts/shared/useCustomChartSetup.d.ts +3 -0
- package/dist/components/charts/shared/useFrameImperativeHandle.d.ts +1 -2
- package/dist/components/charts/shared/useLikertAggregation.d.ts +4 -4
- package/dist/components/charts/shared/useOrdinalBrush.d.ts +2 -1
- package/dist/components/charts/shared/useOrdinalPieceStyle.d.ts +24 -1
- package/dist/components/charts/shared/useStreamingLegend.d.ts +1 -1
- package/dist/components/charts/shared/useXYLineStyle.d.ts +10 -0
- package/dist/components/charts/shared/useXYPointStyle.d.ts +19 -1
- package/dist/components/charts/shared/validateChartData.d.ts +7 -5
- package/dist/components/charts/shared/validationMap.d.ts +11 -2
- package/dist/components/charts/shared/validationMap.generated.d.ts +6 -0
- package/dist/components/charts/shared/withChartWrapper.d.ts +4 -3
- package/dist/components/charts/value/targetPresentation.d.ts +22 -0
- package/dist/components/charts/value/types.d.ts +5 -6
- package/dist/components/charts/xy/AreaChart.d.ts +8 -0
- package/dist/components/charts/xy/BubbleChart.d.ts +9 -0
- package/dist/components/charts/xy/ConnectedScatterplot.d.ts +7 -0
- package/dist/components/charts/xy/DifferenceChart.d.ts +1 -52
- package/dist/components/charts/xy/Heatmap.d.ts +2 -2
- package/dist/components/charts/xy/LineChart.d.ts +11 -0
- package/dist/components/charts/xy/QuadrantChart.d.ts +7 -0
- package/dist/components/charts/xy/Scatterplot.d.ts +10 -0
- package/dist/components/charts/xy/StackedAreaChart.d.ts +7 -0
- package/dist/components/charts/xy/differenceSegments.d.ts +49 -0
- package/dist/components/charts/xy/scatterplotMatrixInteractionTypes.d.ts +12 -0
- package/dist/components/controls/SentenceFilter.d.ts +97 -0
- package/dist/components/data/fromVegaLite.d.ts +19 -9
- package/dist/components/rough/createRoughRenderMode.d.ts +46 -0
- package/dist/components/semiotic-ai.d.ts +3 -1
- package/dist/components/semiotic-controls.d.ts +2 -0
- package/dist/components/semiotic-geo.d.ts +4 -0
- package/dist/components/semiotic-network.d.ts +4 -0
- package/dist/components/semiotic-ordinal.d.ts +6 -0
- package/dist/components/semiotic-physics.d.ts +4 -0
- package/dist/components/semiotic-rough.d.ts +4 -0
- package/dist/components/semiotic-utils-core.d.ts +4 -0
- package/dist/components/semiotic-xy.d.ts +4 -0
- package/dist/components/semiotic.d.ts +9 -1
- package/dist/components/server/optionalImageTypes.d.ts +37 -0
- package/dist/components/server/serverChartConfigShared.d.ts +9 -5
- package/dist/components/server/serverChartConfigs.d.ts +4 -4
- package/dist/components/server/staticAnnotations.d.ts +6 -3
- package/dist/components/server/staticLegend.d.ts +1 -1
- package/dist/components/server/staticNetwork.d.ts +4 -4
- package/dist/components/server/staticSVGChrome.d.ts +2 -2
- package/dist/components/store/ObservationStore.d.ts +21 -1
- package/dist/components/stream/AccessibleDataTable.d.ts +4 -10
- package/dist/components/stream/AriaLiveTooltip.d.ts +9 -0
- package/dist/components/stream/CanvasHitTester.d.ts +4 -4
- package/dist/components/stream/DataSourceAdapter.d.ts +1 -1
- package/dist/components/stream/FrameRuntime.d.ts +57 -0
- package/dist/components/stream/GeoParticlePool.d.ts +1 -1
- package/dist/components/stream/GeoPipelineStore.d.ts +43 -12
- package/dist/components/stream/GeoSVGOverlay.d.ts +64 -0
- package/dist/components/stream/NetworkCanvasHitTester.d.ts +2 -1
- package/dist/components/stream/NetworkPipelineStore.d.ts +24 -21
- package/dist/components/stream/NetworkSSRFrame.d.ts +17 -0
- package/dist/components/stream/NetworkSVGOverlay.d.ts +6 -0
- package/dist/components/stream/OrdinalCanvasHitTester.d.ts +2 -2
- package/dist/components/stream/OrdinalPipelineStore.d.ts +13 -13
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +9 -1
- package/dist/components/stream/OrdinalStyleResolver.d.ts +12 -0
- package/dist/components/stream/ParticlePool.d.ts +1 -1
- package/dist/components/stream/PipelineStore.d.ts +12 -16
- package/dist/components/stream/SVGOverlay.d.ts +6 -0
- package/dist/components/stream/SceneGraph.d.ts +3 -3
- package/dist/components/stream/accessorUtils.d.ts +2 -2
- package/dist/components/stream/annotationAccessorResolver.d.ts +2 -2
- package/dist/components/stream/frameGraphics.d.ts +4 -0
- package/dist/components/stream/frameKeyboardNavigation.d.ts +45 -0
- package/dist/components/stream/geoPipelineHelpers.d.ts +3 -3
- package/dist/components/stream/geoPipelineUpdateResults.d.ts +34 -0
- package/dist/components/stream/geoSceneBuilder.d.ts +16 -0
- package/dist/components/stream/geoTypes.d.ts +48 -15
- package/dist/components/stream/hitTestUtils.d.ts +2 -2
- package/dist/components/stream/hoverUtils.d.ts +4 -2
- package/dist/components/stream/layouts/forceLayoutWorkerClient.d.ts +1 -0
- package/dist/components/stream/layouts/hierarchyUtils.d.ts +2 -2
- package/dist/components/stream/networkCustomLayoutRunner.d.ts +23 -0
- package/dist/components/stream/networkCustomRestyle.d.ts +15 -0
- package/dist/components/stream/networkFrameAnimation.d.ts +7 -0
- package/dist/components/stream/networkFrameHandleTypes.d.ts +39 -0
- package/dist/components/stream/networkFrameObservations.d.ts +15 -0
- package/dist/components/stream/networkFramePaint.d.ts +11 -2
- package/dist/components/stream/networkInteractionTypes.d.ts +26 -0
- package/dist/components/stream/networkPipelineConfig.d.ts +2 -2
- package/dist/components/stream/networkPipelineUpdateResults.d.ts +38 -0
- package/dist/components/stream/networkTypes.d.ts +37 -56
- package/dist/components/stream/ordinalCanvasRenderers.d.ts +2 -2
- package/dist/components/stream/ordinalPipelineUpdateResults.d.ts +20 -1
- package/dist/components/stream/ordinalSceneBuilders/types.d.ts +2 -2
- package/dist/components/stream/ordinalTypes.d.ts +30 -3
- package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +2 -0
- package/dist/components/stream/physics/PhysicsSVGOverlay.d.ts +6 -0
- package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +21 -6
- package/dist/components/stream/physics/physicsFrameObservations.d.ts +19 -0
- package/dist/components/stream/physics/physicsFrameSetup.d.ts +4 -0
- package/dist/components/stream/physics/physicsPipelineUpdateResults.d.ts +19 -1
- package/dist/components/stream/physics/usePhysicsFrameLifecyclePolicy.d.ts +3 -1
- package/dist/components/stream/pipelineConfig.d.ts +4 -2
- package/dist/components/stream/pipelineDecay.d.ts +2 -2
- package/dist/components/stream/pipelinePulse.d.ts +2 -2
- package/dist/components/stream/pipelineStoreUpdateResults.d.ts +23 -2
- package/dist/components/stream/pipelineTransitions.d.ts +1 -1
- package/dist/components/stream/pipelineUpdateContract.d.ts +7 -0
- package/dist/components/stream/pipelineUpdateStore.d.ts +21 -0
- package/dist/components/stream/renderBackend.d.ts +27 -0
- package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +15 -1
- package/dist/components/stream/renderers/geoCanvasRenderer.d.ts +3 -2
- package/dist/components/stream/renderers/networkParticleRenderer.d.ts +1 -1
- package/dist/components/stream/sceneRenderBackendTypes.d.ts +28 -0
- package/dist/components/stream/sceneRevisionDiagnostics.d.ts +31 -4
- package/dist/components/stream/streamSemanticTypes.d.ts +16 -0
- package/dist/components/stream/streamThemeTypes.d.ts +14 -0
- package/dist/components/stream/svgOverlayUtils.d.ts +10 -0
- package/dist/components/stream/test-utils/frameScheduler.d.ts +12 -0
- package/dist/components/stream/test-utils/revisionConsumption.d.ts +13 -0
- package/dist/components/stream/titleLayout.d.ts +31 -0
- package/dist/components/stream/types.d.ts +30 -65
- package/dist/components/stream/useCanvasFrameHost.d.ts +71 -0
- package/dist/components/stream/useFrame.d.ts +23 -0
- package/dist/components/stream/useLegendCategoryEmission.d.ts +3 -3
- package/dist/components/stream/useSemanticFrameInteractions.d.ts +22 -0
- package/dist/components/stream/useUpdateResultSnapshot.d.ts +7 -0
- package/dist/components/stream/xyFrameAxisTypes.d.ts +50 -0
- package/dist/components/stream/xySceneBuilders/types.d.ts +6 -5
- package/dist/controls.min.js +1 -1
- package/dist/controls.module.min.js +1 -1
- package/dist/forceLayoutWorker.js +1 -1
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/physics.min.js +1 -1
- package/dist/physics.module.min.js +1 -1
- package/dist/physicsWorker.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/rough.min.js +1 -0
- package/dist/rough.module.min.js +1 -0
- package/dist/semiotic-ai-core.min.js +1 -1
- package/dist/semiotic-ai-core.module.min.js +1 -1
- package/dist/semiotic-ai.d.ts +3 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-controls.d.ts +2 -0
- package/dist/semiotic-data.min.js +1 -1
- package/dist/semiotic-data.module.min.js +1 -1
- package/dist/semiotic-experimental.min.js +1 -1
- package/dist/semiotic-experimental.module.min.js +1 -1
- package/dist/semiotic-geo.d.ts +4 -0
- package/dist/semiotic-network.d.ts +4 -0
- package/dist/semiotic-ordinal.d.ts +6 -0
- package/dist/semiotic-physics.d.ts +4 -0
- package/dist/semiotic-realtime-core.min.js +1 -1
- package/dist/semiotic-realtime-core.module.min.js +1 -1
- package/dist/semiotic-realtime-react.min.js +1 -1
- package/dist/semiotic-realtime-react.module.min.js +1 -1
- package/dist/semiotic-rough.d.ts +4 -0
- package/dist/semiotic-server-edge.min.js +1 -1
- package/dist/semiotic-server-edge.module.min.js +1 -1
- package/dist/semiotic-server-node.min.js +1 -1
- package/dist/semiotic-server-node.module.min.js +1 -1
- package/dist/semiotic-utils-core.d.ts +4 -0
- package/dist/semiotic-utils-core.min.js +1 -1
- package/dist/semiotic-utils-core.module.min.js +1 -1
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-value.min.js +1 -1
- package/dist/semiotic-value.module.min.js +1 -1
- package/dist/semiotic-xy.d.ts +4 -0
- package/dist/semiotic.d.ts +9 -1
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/test-utils/capturedFrameProps.d.ts +67 -0
- package/dist/test-utils/frameMock.d.ts +12 -9
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +26 -7
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Datum } from "./datumTypes";
|
|
3
|
+
import type { OnObservationCallback, ObservationInputType } from "../../store/ObservationStore";
|
|
4
|
+
export type ChartAnnotation = Datum;
|
|
5
|
+
export interface AnnotationActivationEvent {
|
|
6
|
+
annotation: ChartAnnotation;
|
|
7
|
+
annotationId?: string;
|
|
8
|
+
chartId?: string;
|
|
9
|
+
inputType: ObservationInputType;
|
|
10
|
+
}
|
|
11
|
+
export type OnAnnotationActivateCallback = (event: AnnotationActivationEvent) => void;
|
|
12
|
+
export interface AnnotationActivationOptions {
|
|
13
|
+
onAnnotationActivate?: OnAnnotationActivateCallback;
|
|
14
|
+
onObservation?: OnObservationCallback;
|
|
15
|
+
chartId?: string;
|
|
16
|
+
chartType?: string;
|
|
17
|
+
}
|
|
18
|
+
/** Route annotation activation to both a direct callback and the observation store. */
|
|
19
|
+
export declare function useAnnotationActivationOptions(options: AnnotationActivationOptions): AnnotationActivationOptions;
|
|
20
|
+
/**
|
|
21
|
+
* Resolve a durable annotation identity without ever falling back to array
|
|
22
|
+
* position. Provenance stable IDs are accepted for agent-authored notes.
|
|
23
|
+
*/
|
|
24
|
+
export declare function annotationStableId(annotation: ChartAnnotation): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Event props for a widget's existing HTML boundary. Capture phase observes
|
|
27
|
+
* arbitrary descendant controls without replacing their behavior or adding a
|
|
28
|
+
* nested interactive element.
|
|
29
|
+
*/
|
|
30
|
+
export declare function annotationActivationProps(annotation: ChartAnnotation, options?: AnnotationActivationOptions): React.HTMLAttributes<HTMLDivElement> & {
|
|
31
|
+
"data-semiotic-annotation-id"?: string;
|
|
32
|
+
"data-semiotic-annotation-widget": "";
|
|
33
|
+
};
|
|
34
|
+
/** True when a bubbled frame click originated inside a widget annotation. */
|
|
35
|
+
export declare function isAnnotationActivationTarget(target: EventTarget | null): boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const TOP_LABEL_BASELINE = 16;
|
|
2
|
+
/** Keep a horizontal-threshold label inside the plot when its rule is near the top. */
|
|
3
|
+
export declare function thresholdLabelY(y: number, height: number): number;
|
|
4
|
+
/** Place a horizontal-band label just inside its visible top edge. */
|
|
5
|
+
export declare function bandLabelY(y0: number, y1: number): number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { AnnotationContext } from "../../realtime/types";
|
|
3
3
|
import type { Datum } from "./datumTypes";
|
|
4
|
+
import { type AnnotationActivationOptions } from "./annotationActivation";
|
|
4
5
|
export { applyAnnotationEmphasis, type AnnotationRenderPair } from "./annotationHierarchy";
|
|
5
6
|
type AnnotationRule = (annotation: Datum, index: number, context: AnnotationContext) => React.ReactNode | null;
|
|
6
7
|
/**
|
|
@@ -17,4 +18,4 @@ type AnnotationRule = (annotation: Datum, index: number, context: AnnotationCont
|
|
|
17
18
|
* through to the default rule, preserving the existing override contract.
|
|
18
19
|
*/
|
|
19
20
|
export declare function renderAnnotationPass(annotations: ReadonlyArray<Datum>, defaultRule: AnnotationRule, userRule: AnnotationRule | undefined, context: AnnotationContext): React.ReactNode[];
|
|
20
|
-
export declare function createDefaultAnnotationRules(_frameType: "xy" | "ordinal" | "network"): (annotation: Datum, index: number, context: AnnotationContext) => React.ReactNode | null;
|
|
21
|
+
export declare function createDefaultAnnotationRules(_frameType: "xy" | "ordinal" | "network", activation?: AnnotationActivationOptions): (annotation: Datum, index: number, context: AnnotationContext) => React.ReactNode | null;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Datum } from "./datumTypes";
|
|
2
|
+
export declare function resolveHoverXPosition(interactionDatum: Datum, datum: Datum | null | undefined, xField: string): number | null;
|
|
3
|
+
export declare function observationDatum(interactionDatum: Datum): Datum;
|
|
4
|
+
export declare function hasOwnEnumerableKey(value: object | undefined | null): boolean;
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* - `src/components/charts/shared/validationMap.ts` (runtime prop validation)
|
|
7
7
|
* - `ai/componentMetadata.cjs` (category buckets)
|
|
8
8
|
*
|
|
9
|
-
* Today, `validationMap.ts`
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Today, `validationMap.generated.ts` and `ai/schema.json` are generated from
|
|
10
|
+
* this registry — run `npm run docs:chart-specs:schema` to refresh both after
|
|
11
|
+
* editing a spec. `componentMetadata.cjs` is still
|
|
12
12
|
* hand-edited but gated for parity by the registry: `check:chart-specs` (run
|
|
13
13
|
* via `npm run check:chart-specs`) regenerates each chart's schema/
|
|
14
14
|
* validation/metadata entries with the pure functions in
|
|
@@ -18,3 +18,5 @@
|
|
|
18
18
|
* reason" referenced by the lint policy for `@typescript-eslint/no-explicit-any`.
|
|
19
19
|
*/
|
|
20
20
|
export type Datum = Record<string, any>;
|
|
21
|
+
/** Values that can be returned by a chart accessor or stored in a datum field. */
|
|
22
|
+
export type DatumValue = string | number | boolean | Date | Datum | Datum[] | null | undefined;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Datum } from "./datumTypes";
|
|
2
2
|
import type { Diagnosis } from "./diagnoseTypes";
|
|
3
|
+
/** Interactive widgets need durable identity for replay and normalized events. */
|
|
4
|
+
export declare function checkInteractiveAnnotationIds(_component: string, props: Datum, out: Diagnosis[]): void;
|
|
3
5
|
export declare function checkAnnotationConnectors(_component: string, props: Datum, out: Diagnosis[]): void;
|
|
4
6
|
export declare function checkAnnotationDensity(_component: string, props: Datum, out: Diagnosis[]): void;
|
|
@@ -58,7 +58,7 @@ export declare function formatAxis(type?: "number" | "date" | "percent" | "curre
|
|
|
58
58
|
* )
|
|
59
59
|
* ```
|
|
60
60
|
*/
|
|
61
|
-
export declare function createTooltip(fields: string[], formatters?: Record<string, (
|
|
61
|
+
export declare function createTooltip(fields: string[], formatters?: Record<string, (value: string | number | Date) => string>, labels?: Record<string, string>): (d: Datum) => React.JSX.Element;
|
|
62
62
|
/**
|
|
63
63
|
* Formats large numbers with K/M/B suffixes
|
|
64
64
|
*
|
|
@@ -85,7 +85,7 @@ export declare function formatLargeNumber(value: number, decimals?: number): str
|
|
|
85
85
|
*
|
|
86
86
|
* Used as the default axis tickFormat when no explicit format is provided.
|
|
87
87
|
*/
|
|
88
|
-
export declare function smartTickFormat(value:
|
|
88
|
+
export declare function smartTickFormat(value: string | number | Date | null | undefined): string;
|
|
89
89
|
type TimeGranularity = "seconds" | "minutes" | "hours" | "days" | "months" | "years";
|
|
90
90
|
/**
|
|
91
91
|
* Creates a hierarchical time axis formatter.
|
|
@@ -112,7 +112,7 @@ type TimeGranularity = "seconds" | "minutes" | "hours" | "days" | "months" | "ye
|
|
|
112
112
|
* <LineChart data={ts} xFormat={adaptiveTimeTicks("minutes")} />
|
|
113
113
|
* ```
|
|
114
114
|
*/
|
|
115
|
-
export declare function adaptiveTimeTicks(granularity?: TimeGranularity): (value:
|
|
115
|
+
export declare function adaptiveTimeTicks(granularity?: TimeGranularity): (value: string | number | Date, index?: number, allTicks?: number[]) => string;
|
|
116
116
|
/**
|
|
117
117
|
* Truncates text to specified length with ellipsis
|
|
118
118
|
*
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declarative hatch-fill descriptor — a single value that renders as a
|
|
3
|
+
* diagonal-line pattern on BOTH rendering backends.
|
|
4
|
+
*
|
|
5
|
+
* The library historically had two disjoint hatch primitives: a canvas
|
|
6
|
+
* `createHatchPattern` (→ `CanvasPattern`) and an SVG `<pattern>` builder
|
|
7
|
+
* (`hatchFill` recipe / `createSVGHatchPattern`). A caller had to know
|
|
8
|
+
* which medium they were painting into and hand-produce the right thing —
|
|
9
|
+
* which is why a `CanvasPattern` returned from a `pieceStyle` silently
|
|
10
|
+
* collapses to a solid color in SSR (`svgFill` drops non-string fills).
|
|
11
|
+
*
|
|
12
|
+
* `HatchFill` closes that gap: it is a plain, serializable descriptor that
|
|
13
|
+
* can be set directly as `style.fill`. The canvas renderer resolves it to a
|
|
14
|
+
* `CanvasPattern` (`resolveHatchCanvasPattern`); the SVG serializer resolves
|
|
15
|
+
* it to a `<pattern>` def + `url(#id)` (`hatchPatternDef` / `hatchFillId`).
|
|
16
|
+
* One declaration, both mediums — so a bar hatched via a style rule looks
|
|
17
|
+
* identical whether it is drawn to canvas in the browser or serialized to
|
|
18
|
+
* SVG on the server.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <BarChart
|
|
23
|
+
* styleRules={[
|
|
24
|
+
* { when: { gt: 10 }, style: { fill: { type: "hatch", background: "#ffd166", stroke: "#e0a92a" } } },
|
|
25
|
+
* ]}
|
|
26
|
+
* />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
import * as React from "react";
|
|
30
|
+
/**
|
|
31
|
+
* A declarative diagonal-hatch fill. Assign it anywhere a `style.fill`
|
|
32
|
+
* is accepted (`pieceStyle`, `styleRules`, annotation region `fill`).
|
|
33
|
+
* Backend-agnostic: resolved to a `CanvasPattern` for canvas and an SVG
|
|
34
|
+
* `<pattern>` for SSR / the SVG overlay.
|
|
35
|
+
*/
|
|
36
|
+
export interface HatchFill {
|
|
37
|
+
/** Discriminator — marks this fill as a hatch descriptor. */
|
|
38
|
+
type: "hatch";
|
|
39
|
+
/** Tile background color painted under the lines. @default "transparent" */
|
|
40
|
+
background?: string;
|
|
41
|
+
/** Color of the diagonal lines. @default "#000" */
|
|
42
|
+
stroke?: string;
|
|
43
|
+
/** Width of the diagonal lines in px. @default 1.5 */
|
|
44
|
+
lineWidth?: number;
|
|
45
|
+
/** Spacing between lines in px. @default 6 */
|
|
46
|
+
spacing?: number;
|
|
47
|
+
/** Angle of the lines in degrees (0 = horizontal, 45 = diagonal). @default 45 */
|
|
48
|
+
angle?: number;
|
|
49
|
+
/** Opacity applied to the hatch lines (SVG `<line>` stroke opacity). @default 1 */
|
|
50
|
+
lineOpacity?: number;
|
|
51
|
+
}
|
|
52
|
+
/** Type guard — is a resolved `style.fill` a `HatchFill` descriptor? */
|
|
53
|
+
export declare function isHatchFill(fill: unknown): fill is HatchFill;
|
|
54
|
+
/**
|
|
55
|
+
* Stable, content-derived key for a hatch descriptor. Used to cache canvas
|
|
56
|
+
* patterns and to mint deterministic SVG `<pattern>` ids so identical
|
|
57
|
+
* descriptors dedupe rather than proliferate.
|
|
58
|
+
*/
|
|
59
|
+
export declare function hatchFillKey(h: HatchFill): string;
|
|
60
|
+
/** Deterministic, SVG-id-safe identifier for a hatch descriptor. */
|
|
61
|
+
export declare function hatchFillId(prefix: string, h: HatchFill): string;
|
|
62
|
+
/**
|
|
63
|
+
* Resolve a `HatchFill` descriptor to a `CanvasPattern` for the given
|
|
64
|
+
* context. Cached by descriptor content + DPR. Returns `null` only when
|
|
65
|
+
* the environment can't create a pattern (SSR/test) — callers fall back
|
|
66
|
+
* to the descriptor's `background` color.
|
|
67
|
+
*/
|
|
68
|
+
export declare function resolveHatchCanvasPattern(h: HatchFill, ctx: CanvasRenderingContext2D): CanvasPattern | null;
|
|
69
|
+
/**
|
|
70
|
+
* Render a `HatchFill` descriptor as an SVG `<pattern>` element.
|
|
71
|
+
* Place the returned element inside `<defs>` (or anywhere valid) and set
|
|
72
|
+
* `fill="url(#id)"` on the target shape. Mirrors the canvas tile exactly:
|
|
73
|
+
* parallel lines rotated by `angle` so the two backends read identically.
|
|
74
|
+
*/
|
|
75
|
+
export declare function hatchPatternDef(h: HatchFill, id: string): React.ReactElement;
|
|
76
|
+
/**
|
|
77
|
+
* Resolve a `style.fill` for an SVG shape. Returns the paint string to use
|
|
78
|
+
* plus, when the fill is a `HatchFill`, the `<pattern>` def to inject.
|
|
79
|
+
*
|
|
80
|
+
* @param fill the raw `style.fill` (string color, `HatchFill`, or `CanvasPattern`)
|
|
81
|
+
* @param idBase prefix for the generated pattern id (should be node-unique-ish)
|
|
82
|
+
* @param fallback solid color used when `fill` is null/undefined or a raw CanvasPattern
|
|
83
|
+
*/
|
|
84
|
+
export declare function resolveSvgFill(fill: string | HatchFill | CanvasPattern | null | undefined, idBase: string, fallback?: string): {
|
|
85
|
+
fill: string;
|
|
86
|
+
def?: React.ReactElement;
|
|
87
|
+
};
|
|
@@ -7,6 +7,7 @@ import type { TransitionConfig } from "../../stream/types";
|
|
|
7
7
|
import type { Datum } from "./datumTypes";
|
|
8
8
|
import type { MobileVisualizationContract } from "./auditMobileVisualization";
|
|
9
9
|
import type { ResponsiveRule } from "./responsiveRules";
|
|
10
|
+
import type { SemanticClickBehavior, SemanticHoverBehavior } from "./semanticInteractions";
|
|
10
11
|
/**
|
|
11
12
|
* Default fill color used when no colorBy is specified
|
|
12
13
|
*/
|
|
@@ -46,13 +47,13 @@ export declare function resolveDefaultFill(color: string | undefined, themeCateg
|
|
|
46
47
|
* Resolve an accessor (string key or function) into a function.
|
|
47
48
|
* Used across chart components to normalize `valueAccessor`, `categoryAccessor`, etc.
|
|
48
49
|
*/
|
|
49
|
-
export declare function resolveAccessor<T =
|
|
50
|
+
export declare function resolveAccessor<T = string | number | boolean | Date | Datum | null | undefined>(accessor: string | ((d: Datum, i?: number) => T)): (d: Datum) => T;
|
|
50
51
|
/**
|
|
51
52
|
* Hook to create a color scale from data and colorBy configuration.
|
|
52
53
|
* Returns undefined when colorBy is absent or data is empty (push API mode).
|
|
53
54
|
* Supports both string and function accessors for colorBy.
|
|
54
55
|
*/
|
|
55
|
-
export declare function useColorScale(data: Array<Datum>, colorBy: string | ((d:
|
|
56
|
+
export declare function useColorScale(data: Array<Datum>, colorBy: string | ((d: Datum, i?: number) => string | number) | undefined, colorScheme?: string | string[] | Record<string, string>): ((v: string) => string) | undefined;
|
|
56
57
|
/**
|
|
57
58
|
* Hook to sort data by a value accessor.
|
|
58
59
|
* Used by BarChart and DotPlot.
|
|
@@ -83,7 +84,7 @@ export declare function useChartSelection({ selection, linkedHover, fallbackFiel
|
|
|
83
84
|
onObservation?: OnObservationCallback;
|
|
84
85
|
chartType?: string;
|
|
85
86
|
chartId?: string;
|
|
86
|
-
onClick?: (datum:
|
|
87
|
+
onClick?: (datum: Datum, event: {
|
|
87
88
|
x: number;
|
|
88
89
|
y: number;
|
|
89
90
|
}) => void;
|
|
@@ -93,8 +94,8 @@ export declare function useChartSelection({ selection, linkedHover, fallbackFiel
|
|
|
93
94
|
}): {
|
|
94
95
|
activeSelectionHook: SelectionHookResult | null;
|
|
95
96
|
hoverSelectionHook: SelectionHookResult | null;
|
|
96
|
-
customHoverBehavior:
|
|
97
|
-
customClickBehavior:
|
|
97
|
+
customHoverBehavior: SemanticHoverBehavior;
|
|
98
|
+
customClickBehavior: SemanticClickBehavior;
|
|
98
99
|
/** Stable ID for this chart instance, used to suppress linked crosshair on source chart */
|
|
99
100
|
crosshairSourceId: string;
|
|
100
101
|
};
|
|
@@ -172,7 +173,7 @@ interface ChartModeInput {
|
|
|
172
173
|
categoryLabel?: string;
|
|
173
174
|
valueLabel?: string;
|
|
174
175
|
/** When truthy, enableHover is forced true regardless of mode (LinkedCharts needs hover) */
|
|
175
|
-
linkedHover?:
|
|
176
|
+
linkedHover?: LinkedHoverProp;
|
|
176
177
|
/** Optional mobile interaction policy surfaced through useChartMode for custom wrappers. */
|
|
177
178
|
mobileInteraction?: MobileInteractionProp;
|
|
178
179
|
/** Optional mobile semantic contract surfaced through useChartMode for custom wrappers. */
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AUTO-GENERATED from chartSpecs.ts by scripts/regenerate-schema.ts.
|
|
3
|
+
* Do not edit by hand; run `npm run docs:chart-specs:schema`.
|
|
4
|
+
*
|
|
5
|
+
* This compact registry is intentionally separate from validation metadata:
|
|
6
|
+
* config serialization only needs chart-name membership.
|
|
7
|
+
*/
|
|
8
|
+
export declare const KNOWN_CHART_COMPONENTS: readonly ["BarChart", "StackedBarChart", "GroupedBarChart", "SwarmPlot", "BoxPlot", "Histogram", "ViolinPlot", "RidgelinePlot", "DotPlot", "PieChart", "DonutChart", "GaugeChart", "FunnelChart", "SwimlaneChart", "LikertChart", "LineChart", "AreaChart", "DifferenceChart", "StackedAreaChart", "Scatterplot", "BubbleChart", "Heatmap", "QuadrantChart", "MultiAxisLineChart", "CandlestickChart", "ConnectedScatterplot", "ScatterplotMatrix", "MinimapChart", "ForceDirectedGraph", "SankeyDiagram", "ProcessSankey", "ChordDiagram", "TreeDiagram", "Treemap", "CirclePack", "OrbitDiagram", "ChoroplethMap", "ProportionalSymbolMap", "FlowMap", "DistanceCartogram", "RealtimeLineChart", "RealtimeHistogram", "TemporalHistogram", "RealtimeSwarmChart", "RealtimeWaterfallChart", "RealtimeHeatmap", "GaltonBoardChart", "EventDropChart", "PhysicsPileChart", "CollisionSwarmChart", "GauntletChart", "ProcessFlowChart", "PhysicalFlowChart", "BigNumber"];
|
|
9
|
+
export declare function isKnownChartComponent(componentName: string): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type RegressionPoint = [number, number];
|
|
2
|
+
export interface LeastSquaresResult {
|
|
3
|
+
points: RegressionPoint[];
|
|
4
|
+
/**
|
|
5
|
+
* Linear: `[slope, intercept]`. Polynomial: highest power first, matching
|
|
6
|
+
* the historical `regression` package result consumed by annotations.
|
|
7
|
+
*/
|
|
8
|
+
equation: number[];
|
|
9
|
+
}
|
|
10
|
+
/** Fit a two-parameter least-squares line with two-decimal output rounding. */
|
|
11
|
+
export declare function linearRegression(data: ReadonlyArray<readonly [number, number | null]>): LeastSquaresResult;
|
|
12
|
+
/**
|
|
13
|
+
* Fit an order-N polynomial using normal equations. Coefficients and predicted
|
|
14
|
+
* points use the former dependency's two-decimal rounding and equation order.
|
|
15
|
+
*/
|
|
16
|
+
export declare function polynomialRegression(data: ReadonlyArray<readonly [number, number | null]>, order?: number): LeastSquaresResult;
|
|
@@ -27,7 +27,8 @@ export interface PrimitiveStyleOverrides {
|
|
|
27
27
|
strokeWidth?: number;
|
|
28
28
|
opacity?: number;
|
|
29
29
|
}
|
|
30
|
-
type
|
|
30
|
+
type StyleArgument = Datum | string | number | boolean | Date | null | undefined;
|
|
31
|
+
type StyleFn<TArgs extends StyleArgument[]> = (...args: TArgs) => Datum;
|
|
31
32
|
/** Returns true when at least one override key has a non-undefined value. */
|
|
32
33
|
export declare function hasPrimitiveOverrides(overrides: PrimitiveStyleOverrides): boolean;
|
|
33
34
|
/**
|
|
@@ -39,5 +40,5 @@ export declare function hasPrimitiveOverrides(overrides: PrimitiveStyleOverrides
|
|
|
39
40
|
* keeps the memoization-stable identity path hot for the common case
|
|
40
41
|
* where a designer has set nothing.
|
|
41
42
|
*/
|
|
42
|
-
export declare function mergeShapeStyle<
|
|
43
|
+
export declare function mergeShapeStyle<TArgs extends StyleArgument[] = []>(styleFn: StyleFn<TArgs> | undefined, overrides: PrimitiveStyleOverrides): StyleFn<TArgs>;
|
|
43
44
|
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Datum } from "./datumTypes";
|
|
2
|
+
import type { KeyboardEvent as ReactKeyboardEvent } from "react";
|
|
3
|
+
import type { OnObservationCallback, ObservationInputType } from "../../store/ObservationStore";
|
|
4
|
+
/** Extra context supplied by Stream Frames to their existing behavior hooks. */
|
|
5
|
+
export interface SemanticInteractionContext {
|
|
6
|
+
type: "focus" | "activate";
|
|
7
|
+
inputType: ObservationInputType;
|
|
8
|
+
}
|
|
9
|
+
export type SemanticHoverBehavior<T = Datum> = (datum: T | null, context?: SemanticInteractionContext) => void;
|
|
10
|
+
export type SemanticClickBehavior<T = Datum> = (datum: T | null, context?: SemanticInteractionContext) => void;
|
|
11
|
+
export declare function observationInputType(pointerType?: string): "pointer" | "touch";
|
|
12
|
+
/**
|
|
13
|
+
* Stream Frame keyboard navigation lives on a focusable chart wrapper. Let
|
|
14
|
+
* native controls rendered inside that wrapper (notably widget annotations)
|
|
15
|
+
* handle their own keys before the chart consumes Enter, Space, or arrows.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isInteractiveKeyboardTarget(event: Pick<ReactKeyboardEvent, "target" | "currentTarget">): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Emit the legacy hover event and its semantic focus companion when present.
|
|
20
|
+
* Keeping both makes the semantic vocabulary additive for existing consumers.
|
|
21
|
+
*/
|
|
22
|
+
export declare function emitHoverObservations(options: {
|
|
23
|
+
onObservation?: OnObservationCallback;
|
|
24
|
+
datum: Datum | null;
|
|
25
|
+
x?: number;
|
|
26
|
+
y?: number;
|
|
27
|
+
chartType: string;
|
|
28
|
+
chartId?: string;
|
|
29
|
+
context?: SemanticInteractionContext;
|
|
30
|
+
timestamp?: number;
|
|
31
|
+
}): void;
|
|
32
|
+
/** Emit the legacy click event and its semantic activation companion. */
|
|
33
|
+
export declare function emitClickObservations(options: {
|
|
34
|
+
onObservation?: OnObservationCallback;
|
|
35
|
+
datum: Datum | null;
|
|
36
|
+
x?: number;
|
|
37
|
+
y?: number;
|
|
38
|
+
chartType: string;
|
|
39
|
+
chartId?: string;
|
|
40
|
+
context?: SemanticInteractionContext;
|
|
41
|
+
timestamp?: number;
|
|
42
|
+
}): void;
|
|
@@ -24,4 +24,4 @@
|
|
|
24
24
|
* mutation throws in strict mode rather than corrupting later reads.
|
|
25
25
|
*/
|
|
26
26
|
export declare const EMPTY_ARRAY: readonly unknown[];
|
|
27
|
-
export declare function filterSparseArray<T>(input: readonly T[] | undefined | null): T[];
|
|
27
|
+
export declare function filterSparseArray<T extends object>(input: readonly (T | null | undefined)[] | undefined | null): T[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { Datum } from "./datumTypes";
|
|
3
|
+
import type { SemanticClickBehavior, SemanticHoverBehavior } from "./semanticInteractions";
|
|
3
4
|
import { type TooltipProp } from "../../Tooltip/Tooltip";
|
|
4
5
|
import type { HoverData } from "../../realtime/types";
|
|
5
6
|
import type { HoverHighlightMode, LinkedHoverProp, SelectionConfig, ResolvedMobileInteractionConfig } from "./types";
|
|
@@ -86,8 +87,8 @@ export declare function buildCustomBehaviorProps(input: {
|
|
|
86
87
|
forceHoverBehavior?: boolean;
|
|
87
88
|
forceClickBehavior?: boolean;
|
|
88
89
|
mobileInteraction?: ResolvedMobileInteractionConfig;
|
|
89
|
-
customHoverBehavior:
|
|
90
|
-
customClickBehavior?:
|
|
90
|
+
customHoverBehavior: SemanticHoverBehavior;
|
|
91
|
+
customClickBehavior?: SemanticClickBehavior;
|
|
91
92
|
/**
|
|
92
93
|
* Whether `linkedHover` participates in the click predicate. Most
|
|
93
94
|
* XY / ordinal HOCs say yes — `linkedHover` cross-chart selection
|
|
@@ -98,8 +99,9 @@ export declare function buildCustomBehaviorProps(input: {
|
|
|
98
99
|
*/
|
|
99
100
|
linkedHoverInClickPredicate?: boolean;
|
|
100
101
|
}): {
|
|
101
|
-
customHoverBehavior?:
|
|
102
|
-
customClickBehavior?:
|
|
102
|
+
customHoverBehavior?: SemanticHoverBehavior;
|
|
103
|
+
customClickBehavior?: SemanticClickBehavior;
|
|
104
|
+
annotationObservationCallback?: OnObservationCallback;
|
|
103
105
|
hoverRadius?: number;
|
|
104
106
|
};
|
|
105
107
|
/**
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declarative, threshold-aware style rules for data marks.
|
|
3
|
+
*
|
|
4
|
+
* A `StyleRule[]` is an ordered list of `{ when, style }` pairs. Every rule
|
|
5
|
+
* whose `when` condition matches a datum contributes its `style`; styles are
|
|
6
|
+
* merged in list order so — for any single property — the **last applicable
|
|
7
|
+
* rule wins**. This is the CSS-cascade mental model: send as many rules as
|
|
8
|
+
* you like, and the last one that applies to a given property is the one you
|
|
9
|
+
* see. A datum that matches no rule keeps the chart's resolved base style.
|
|
10
|
+
*
|
|
11
|
+
* `when` is intentionally permissive: it can be a predicate function (full
|
|
12
|
+
* control), a declarative numeric/categorical threshold (no code), or simply
|
|
13
|
+
* omitted / `true` (an unconditional base layer). Threshold conditions read a
|
|
14
|
+
* numeric value from `field` (falling back to the chart-provided value, e.g.
|
|
15
|
+
* a bar's `valueAccessor`), so `{ when: { gt: 10 }, style: {...} }` "styles
|
|
16
|
+
* every bar taller than 10" with no accessor boilerplate.
|
|
17
|
+
*
|
|
18
|
+
* The engine is chart-agnostic — it operates on a raw datum plus a small
|
|
19
|
+
* context (`value`, `category`, `index`). Bar-family HOCs feed it through
|
|
20
|
+
* `useOrdinalPieceStyle`, but any renderer with a datum and a numeric value
|
|
21
|
+
* can reuse it.
|
|
22
|
+
*/
|
|
23
|
+
import type { Datum } from "./datumTypes";
|
|
24
|
+
import type { HatchFill } from "./hatchFill";
|
|
25
|
+
/** The style a rule applies. `fill` may be a solid color or a {@link HatchFill}. */
|
|
26
|
+
export interface StyleRuleStyle {
|
|
27
|
+
/** Solid color string, a CSS var, or a declarative hatch descriptor. */
|
|
28
|
+
fill?: string | HatchFill;
|
|
29
|
+
fillOpacity?: number;
|
|
30
|
+
stroke?: string;
|
|
31
|
+
strokeWidth?: number;
|
|
32
|
+
strokeDasharray?: string;
|
|
33
|
+
opacity?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A declarative numeric / categorical condition. All present operators must
|
|
37
|
+
* hold (logical AND). The compared value is chosen in this order:
|
|
38
|
+
* 1. `axis` — a resolved context channel (`"x"` / `"y"` / `"value"`), so a
|
|
39
|
+
* rule can target either axis of an XY chart regardless of the accessor
|
|
40
|
+
* field name (e.g. `{ axis: "y", gt: 10 }`).
|
|
41
|
+
* 2. `field` — a raw datum property (`datum[field]`).
|
|
42
|
+
* 3. otherwise the host-resolved context value (`ctx.value` — the bar value,
|
|
43
|
+
* the y value for XY, the node/feature/body value, etc.).
|
|
44
|
+
*/
|
|
45
|
+
export interface StyleRuleThreshold {
|
|
46
|
+
/**
|
|
47
|
+
* Compare against a resolved context channel rather than a raw field. Use to
|
|
48
|
+
* target an XY chart's `"x"` or `"y"` axis without knowing the accessor's
|
|
49
|
+
* field name. `"value"` is the same channel the field-less default uses.
|
|
50
|
+
*/
|
|
51
|
+
axis?: "x" | "y" | "value";
|
|
52
|
+
/** Datum field to compare. Defaults to the host-resolved context value. */
|
|
53
|
+
field?: string;
|
|
54
|
+
/** value > n */
|
|
55
|
+
gt?: number;
|
|
56
|
+
/** value >= n */
|
|
57
|
+
gte?: number;
|
|
58
|
+
/** value < n */
|
|
59
|
+
lt?: number;
|
|
60
|
+
/** value <= n */
|
|
61
|
+
lte?: number;
|
|
62
|
+
/** value === n (numeric or string equality) */
|
|
63
|
+
eq?: number | string;
|
|
64
|
+
/** value !== n */
|
|
65
|
+
ne?: number | string;
|
|
66
|
+
/** min <= value <= max (inclusive) */
|
|
67
|
+
within?: [number, number];
|
|
68
|
+
/** value < min OR value > max */
|
|
69
|
+
outside?: [number, number];
|
|
70
|
+
/** value is one of the listed values */
|
|
71
|
+
in?: Array<number | string>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Context passed to predicate / style functions and threshold resolution.
|
|
75
|
+
* Which channels are populated depends on the chart family:
|
|
76
|
+
* - ordinal bars: `value` (bar value), `category` (stack/group key)
|
|
77
|
+
* - XY: `value` (= `y`), `x`, `y`
|
|
78
|
+
* - network nodes: `value` (node size/value), `category` (group / colorBy)
|
|
79
|
+
* - geo features: `value` (feature value), `category`
|
|
80
|
+
* - physics particles: `value` (body value), `category` (colorBy group)
|
|
81
|
+
*/
|
|
82
|
+
export interface StyleRuleContext {
|
|
83
|
+
/** Primary numeric value the host resolved (bar value; XY y; node/feature/body value). */
|
|
84
|
+
value: number | undefined;
|
|
85
|
+
/** Resolved x value (XY family). */
|
|
86
|
+
x?: number;
|
|
87
|
+
/** Resolved y value (XY family; usually equals `value`). */
|
|
88
|
+
y?: number;
|
|
89
|
+
/** Resolved size value (bubble / symbol `sizeBy`, node size), when known. */
|
|
90
|
+
size?: number;
|
|
91
|
+
/** Category / series / stack / group key, when the host knows one. */
|
|
92
|
+
category?: string;
|
|
93
|
+
/** Positional index, when the host provides one. */
|
|
94
|
+
index?: number;
|
|
95
|
+
}
|
|
96
|
+
/** A `when` predicate: full programmatic control over matching. */
|
|
97
|
+
export type StyleRulePredicate = (datum: Datum, ctx: StyleRuleContext) => boolean;
|
|
98
|
+
/**
|
|
99
|
+
* One declarative style rule. `when` may be:
|
|
100
|
+
* - a **predicate** `(datum, ctx) => boolean`
|
|
101
|
+
* - a **threshold** object (`{ gt, lte, within, in, … }`)
|
|
102
|
+
* - `true` / omitted — always matches (an unconditional base layer)
|
|
103
|
+
* - `false` — never matches (temporarily disable a rule)
|
|
104
|
+
*/
|
|
105
|
+
export interface StyleRule {
|
|
106
|
+
/** Optional stable id — handy for legends, debugging, and docs. */
|
|
107
|
+
id?: string;
|
|
108
|
+
/** Match condition. Omitted / `true` ⇒ always applies. */
|
|
109
|
+
when?: StyleRulePredicate | StyleRuleThreshold | boolean;
|
|
110
|
+
/** Style to apply when matched. Object, or a per-datum function. */
|
|
111
|
+
style: StyleRuleStyle | ((datum: Datum, ctx: StyleRuleContext) => StyleRuleStyle);
|
|
112
|
+
/** Optional human label (legend / documentation only). */
|
|
113
|
+
label?: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Build a stable-ish resolver that reads a numeric value from a datum via a
|
|
117
|
+
* string field or accessor function — the value threshold rules compare
|
|
118
|
+
* against when their `field` is omitted. Memoize the result in the host
|
|
119
|
+
* component keyed on the accessor (string accessors are already stable).
|
|
120
|
+
*/
|
|
121
|
+
export declare function makeRuleValueResolver(accessor: string | ((d: Datum) => unknown) | undefined): (d: Datum) => number | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Build the XY `StyleRuleContext` resolver from x/y accessors: populates
|
|
124
|
+
* `value` (= y), `x`, and `y` so thresholds can target either axis via
|
|
125
|
+
* `{ axis: "x" }` / `{ axis: "y" }` regardless of the accessor field names.
|
|
126
|
+
* Shared by the XY client hooks and the XY server render configs. Memoize in
|
|
127
|
+
* the host keyed on the accessors.
|
|
128
|
+
*/
|
|
129
|
+
export declare function makeXYRuleContext(xAccessor: string | ((d: Datum) => unknown) | undefined, yAccessor: string | ((d: Datum) => unknown) | undefined): (d: Datum, category?: string) => StyleRuleContext;
|
|
130
|
+
/**
|
|
131
|
+
* Build the network-node `StyleRuleContext` resolver: `value` from a numeric
|
|
132
|
+
* field (defaults to the node's `value`) and `category` from the `colorBy`
|
|
133
|
+
* group. Rules resolve against the raw node object (unwrap `RealtimeNode.data`
|
|
134
|
+
* first). Shared by network client HOCs and the network server configs.
|
|
135
|
+
*/
|
|
136
|
+
export declare function makeNodeRuleContext(colorBy: string | ((d: Datum) => unknown) | undefined, valueAccessor?: string | ((d: Datum) => unknown)): (raw: Datum) => StyleRuleContext;
|
|
137
|
+
/**
|
|
138
|
+
* Evaluate a declarative threshold against a datum + context. Returns `false`
|
|
139
|
+
* when the compared value can't be resolved to a finite number (except for the
|
|
140
|
+
* purely categorical `eq`/`ne`/`in` operators, which also accept strings).
|
|
141
|
+
*/
|
|
142
|
+
export declare function matchesThreshold(threshold: StyleRuleThreshold, datum: Datum, ctx: StyleRuleContext): boolean;
|
|
143
|
+
/** Does a single rule's `when` condition match this datum? */
|
|
144
|
+
export declare function ruleMatches(rule: StyleRule, datum: Datum, ctx: StyleRuleContext): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Resolve an ordered rule list to a single merged style. Every matching
|
|
147
|
+
* rule's style is spread in list order, so for any given property the last
|
|
148
|
+
* applicable rule wins. Returns an empty object when nothing matches (the
|
|
149
|
+
* host chart's base style is then used unchanged).
|
|
150
|
+
*/
|
|
151
|
+
export declare function resolveStyleRules(datum: Datum, rules: ReadonlyArray<StyleRule> | undefined, ctx: StyleRuleContext): StyleRuleStyle;
|
|
152
|
+
/** A per-mark style function the pipelines accept (`fill` may be a HatchFill). */
|
|
153
|
+
type MarkStyleFn = (d: Datum, arg?: string) => StyleRuleStyle;
|
|
154
|
+
/**
|
|
155
|
+
* Client-side composition: wrap a base per-mark style function so declarative
|
|
156
|
+
* rules layer OVER its output (rules win per property), matching the ordinal
|
|
157
|
+
* `useOrdinalPieceStyle` behavior for every other family. The base style runs
|
|
158
|
+
* first (resolving the mark's base color); the merged rule style is spread on
|
|
159
|
+
* top. Returns the base function unchanged when there are no rules, so it's a
|
|
160
|
+
* zero-cost pass-through in the common case.
|
|
161
|
+
*
|
|
162
|
+
* `buildContext` populates the `StyleRuleContext` channels the family's rules
|
|
163
|
+
* read (`value`, `x`, `y`, `category`…). `unwrap` handles frames whose style
|
|
164
|
+
* callbacks receive a wrapper rather than the raw datum (e.g. network's
|
|
165
|
+
* `RealtimeNode`, whose user object lives on `.data`) — rules and
|
|
166
|
+
* `buildContext` see the unwrapped raw datum, while the base function still
|
|
167
|
+
* receives the original argument.
|
|
168
|
+
*/
|
|
169
|
+
export declare function composeStyleRules<A = string>(baseStyleFn: ((d: Datum, arg?: A) => Datum) | undefined, rules: ReadonlyArray<StyleRule> | undefined, buildContext: (raw: Datum, arg?: A) => StyleRuleContext, unwrap?: (d: Datum) => Datum): (d: Datum, arg?: A) => Datum;
|
|
170
|
+
/**
|
|
171
|
+
* Compose style rules into a per-mark style function. It resolves the merged
|
|
172
|
+
* rule style from a per-datum `StyleRuleContext` (built by `buildContext`),
|
|
173
|
+
* then overlays a user-supplied style function (which wins). Marks left
|
|
174
|
+
* unmatched return an empty style so the frame's own base-color resolver fills
|
|
175
|
+
* them.
|
|
176
|
+
*
|
|
177
|
+
* This is the family-agnostic primitive behind the server render path (which
|
|
178
|
+
* builds frame props directly instead of going through a HOC hook). Each
|
|
179
|
+
* family supplies the `buildContext` that populates the channels its threshold
|
|
180
|
+
* rules read — `value` for bars, `{ value, x, y }` for XY, node value/group
|
|
181
|
+
* for network, etc. — so all families share one rule-resolution core.
|
|
182
|
+
*
|
|
183
|
+
* @param arg the second style-fn argument (ordinal category / stack key). It is
|
|
184
|
+
* passed through to `buildContext` and the user style fn unchanged.
|
|
185
|
+
*/
|
|
186
|
+
export declare function makeStyleRuleStyleFn(rules: ReadonlyArray<StyleRule> | undefined, buildContext: (d: Datum, arg?: string) => StyleRuleContext, userStyleFn?: MarkStyleFn): MarkStyleFn | undefined;
|
|
187
|
+
/**
|
|
188
|
+
* Network-flavored server helper: resolves rules against the raw node (the
|
|
189
|
+
* server frame passes a `RealtimeNode` wrapper whose user object is on
|
|
190
|
+
* `.data`), with `{ value, category }` context from `makeNodeRuleContext`. A
|
|
191
|
+
* user `nodeStyle` overlays and wins. `undefined` when there are no rules.
|
|
192
|
+
*/
|
|
193
|
+
export declare function styleRulesToNodeStyle(rules: ReadonlyArray<StyleRule> | undefined, colorBy: string | ((d: Datum) => unknown) | undefined, valueAccessor: string | ((d: Datum) => unknown) | undefined, userNodeStyle?: (d: Datum, arg?: number) => Datum): ((d: Datum, arg?: number) => Datum) | undefined;
|
|
194
|
+
/**
|
|
195
|
+
* XY-flavored server helper: `{ value: y, x, y }` context from `makeXYRuleContext`.
|
|
196
|
+
* Feeds `pointStyle` / `lineStyle`. A user style overlays and wins.
|
|
197
|
+
*/
|
|
198
|
+
export declare function styleRulesToXYStyle(rules: ReadonlyArray<StyleRule> | undefined, xAccessor: string | ((d: Datum) => unknown) | undefined, yAccessor: string | ((d: Datum) => unknown) | undefined, userStyle?: MarkStyleFn): MarkStyleFn | undefined;
|
|
199
|
+
/**
|
|
200
|
+
* Ordinal-flavored {@link makeStyleRuleStyleFn}: the context is
|
|
201
|
+
* `{ value: valueAccessor(d), category }` — the bar/piece value plus the
|
|
202
|
+
* stack/group key. Kept as sugar for the ordinal server config.
|
|
203
|
+
*/
|
|
204
|
+
export declare function styleRulesToPieceStyle(rules: ReadonlyArray<StyleRule> | undefined, valueAccessor: string | ((d: Datum) => unknown) | undefined, userPieceStyle?: MarkStyleFn): MarkStyleFn | undefined;
|
|
205
|
+
export {};
|