@genome-spy/core 0.67.0 → 0.69.0
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/dist/bundle/index.es.js +15884 -13130
- package/dist/bundle/index.js +130 -149
- package/dist/schema.json +6498 -6191
- package/dist/src/data/collector.d.ts +20 -0
- package/dist/src/data/collector.d.ts.map +1 -1
- package/dist/src/data/collector.js +148 -0
- package/dist/src/data/dataFlow.d.ts +6 -0
- package/dist/src/data/dataFlow.d.ts.map +1 -1
- package/dist/src/data/dataFlow.js +20 -0
- package/dist/src/data/flowInit.d.ts.map +1 -1
- package/dist/src/data/flowInit.js +2 -3
- package/dist/src/data/flowNode.d.ts +33 -10
- package/dist/src/data/flowNode.d.ts.map +1 -1
- package/dist/src/data/flowNode.js +84 -13
- package/dist/src/data/flowTestUtils.d.ts +2 -2
- package/dist/src/data/flowTestUtils.d.ts.map +1 -1
- package/dist/src/data/flowTestUtils.js +5 -4
- package/dist/src/data/keyIndex.d.ts +18 -0
- package/dist/src/data/keyIndex.d.ts.map +1 -0
- package/dist/src/data/keyIndex.js +241 -0
- package/dist/src/data/keyIndex.test.d.ts +2 -0
- package/dist/src/data/keyIndex.test.d.ts.map +1 -0
- package/dist/src/data/sources/dataSource.d.ts.map +1 -1
- package/dist/src/data/sources/dataSource.js +7 -3
- package/dist/src/data/sources/dataSourceFactory.d.ts +14 -12
- package/dist/src/data/sources/dataSourceFactory.d.ts.map +1 -1
- package/dist/src/data/sources/dataSourceFactory.js +52 -16
- package/dist/src/data/sources/lazy/bigBedSource.d.ts.map +1 -1
- package/dist/src/data/sources/lazy/bigBedSource.js +11 -10
- package/dist/src/data/sources/lazy/bigWigSource.d.ts.map +1 -1
- package/dist/src/data/sources/lazy/bigWigSource.js +11 -10
- package/dist/src/data/sources/lazy/mockLazySource.d.ts +29 -0
- package/dist/src/data/sources/lazy/mockLazySource.d.ts.map +1 -0
- package/dist/src/data/sources/lazy/mockLazySource.js +44 -0
- package/dist/src/data/sources/lazy/singleAxisLazySource.d.ts +22 -1
- package/dist/src/data/sources/lazy/singleAxisLazySource.d.ts.map +1 -1
- package/dist/src/data/sources/lazy/singleAxisLazySource.js +34 -2
- package/dist/src/data/sources/lazy/singleAxisWindowedSource.d.ts.map +1 -1
- package/dist/src/data/sources/lazy/singleAxisWindowedSource.js +16 -1
- package/dist/src/data/sources/lazy/tabixSource.d.ts +0 -1
- package/dist/src/data/sources/lazy/tabixSource.d.ts.map +1 -1
- package/dist/src/data/sources/lazy/tabixSource.js +56 -16
- package/dist/src/data/sources/sequenceSource.d.ts.map +1 -1
- package/dist/src/data/sources/sequenceSource.js +5 -3
- package/dist/src/data/sources/urlSource.d.ts.map +1 -1
- package/dist/src/data/sources/urlSource.js +7 -3
- package/dist/src/data/transforms/filter.d.ts +4 -4
- package/dist/src/data/transforms/filter.d.ts.map +1 -1
- package/dist/src/data/transforms/filter.js +13 -7
- package/dist/src/data/transforms/filterScoredLabels.d.ts.map +1 -1
- package/dist/src/data/transforms/filterScoredLabels.js +11 -6
- package/dist/src/data/transforms/filterScoredLabels.test.d.ts +2 -0
- package/dist/src/data/transforms/filterScoredLabels.test.d.ts.map +1 -0
- package/dist/src/data/transforms/formula.d.ts +4 -4
- package/dist/src/data/transforms/formula.d.ts.map +1 -1
- package/dist/src/data/transforms/formula.js +12 -6
- package/dist/src/data/transforms/measureText.d.ts +2 -2
- package/dist/src/data/transforms/measureText.d.ts.map +1 -1
- package/dist/src/data/transforms/measureText.js +16 -12
- package/dist/src/data/transforms/stack.d.ts.map +1 -1
- package/dist/src/data/transforms/stack.js +1 -0
- package/dist/src/data/transforms/transform.d.ts +2 -2
- package/dist/src/data/transforms/transform.d.ts.map +1 -1
- package/dist/src/data/transforms/transform.js +3 -3
- package/dist/src/encoder/accessor.d.ts +51 -4
- package/dist/src/encoder/accessor.d.ts.map +1 -1
- package/dist/src/encoder/accessor.js +174 -10
- package/dist/src/encoder/encoder.d.ts +11 -2
- package/dist/src/encoder/encoder.d.ts.map +1 -1
- package/dist/src/encoder/encoder.js +29 -9
- package/dist/src/encoder/metadataChannels.d.ts +15 -0
- package/dist/src/encoder/metadataChannels.d.ts.map +1 -0
- package/dist/src/encoder/metadataChannels.js +65 -0
- package/dist/src/encoder/metadataChannels.test.d.ts +2 -0
- package/dist/src/encoder/metadataChannels.test.d.ts.map +1 -0
- package/dist/src/genome/genome.d.ts +8 -0
- package/dist/src/genome/genome.d.ts.map +1 -1
- package/dist/src/genome/genome.js +16 -1
- package/dist/src/genome/scaleLocus.d.ts.map +1 -1
- package/dist/src/genome/scaleLocus.js +14 -1
- package/dist/src/genomeSpy/containerUi.d.ts +0 -1
- package/dist/src/genomeSpy/containerUi.d.ts.map +1 -1
- package/dist/src/genomeSpy/containerUi.js +0 -14
- package/dist/src/genomeSpy/inputBindingManager.js +1 -1
- package/dist/src/genomeSpy/interactionController.d.ts.map +1 -1
- package/dist/src/genomeSpy/interactionController.js +7 -1
- package/dist/src/genomeSpy/loadingIndicatorManager.d.ts +3 -7
- package/dist/src/genomeSpy/loadingIndicatorManager.d.ts.map +1 -1
- package/dist/src/genomeSpy/loadingIndicatorManager.js +68 -20
- package/dist/src/genomeSpy/loadingStatusRegistry.d.ts +52 -0
- package/dist/src/genomeSpy/loadingStatusRegistry.d.ts.map +1 -0
- package/dist/src/genomeSpy/loadingStatusRegistry.js +86 -0
- package/dist/src/genomeSpy/viewContextFactory.d.ts.map +1 -1
- package/dist/src/genomeSpy/viewContextFactory.js +0 -1
- package/dist/src/genomeSpy/viewDataInit.d.ts.map +1 -1
- package/dist/src/genomeSpy/viewDataInit.js +56 -11
- package/dist/src/genomeSpy.d.ts +0 -2
- package/dist/src/genomeSpy.d.ts.map +1 -1
- package/dist/src/genomeSpy.js +47 -27
- package/dist/src/gl/glslScaleGenerator.js +1 -1
- package/dist/src/marks/mark.d.ts.map +1 -1
- package/dist/src/marks/mark.js +40 -41
- package/dist/src/marks/markUtils.js +1 -1
- package/dist/src/marks/point.d.ts.map +1 -1
- package/dist/src/marks/point.js +4 -6
- package/dist/src/paramRuntime/expressionCompiler.d.ts +7 -0
- package/dist/src/paramRuntime/expressionCompiler.d.ts.map +1 -0
- package/dist/src/paramRuntime/expressionCompiler.js +10 -0
- package/dist/src/paramRuntime/expressionRef.d.ts +20 -0
- package/dist/src/paramRuntime/expressionRef.d.ts.map +1 -0
- package/dist/src/paramRuntime/expressionRef.js +95 -0
- package/dist/src/paramRuntime/expressionRef.test.d.ts +2 -0
- package/dist/src/paramRuntime/expressionRef.test.d.ts.map +1 -0
- package/dist/src/paramRuntime/graphRuntime.d.ts +176 -0
- package/dist/src/paramRuntime/graphRuntime.d.ts.map +1 -0
- package/dist/src/paramRuntime/graphRuntime.js +628 -0
- package/dist/src/paramRuntime/graphRuntime.test.d.ts +2 -0
- package/dist/src/paramRuntime/graphRuntime.test.d.ts.map +1 -0
- package/dist/src/paramRuntime/index.d.ts +9 -0
- package/dist/src/paramRuntime/index.d.ts.map +1 -0
- package/dist/src/paramRuntime/index.js +8 -0
- package/dist/src/paramRuntime/lifecycleRegistry.d.ts +27 -0
- package/dist/src/paramRuntime/lifecycleRegistry.d.ts.map +1 -0
- package/dist/src/paramRuntime/lifecycleRegistry.js +54 -0
- package/dist/src/paramRuntime/paramRuntime.d.ts +165 -0
- package/dist/src/paramRuntime/paramRuntime.d.ts.map +1 -0
- package/dist/src/paramRuntime/paramRuntime.js +222 -0
- package/dist/src/paramRuntime/paramRuntime.test.d.ts +2 -0
- package/dist/src/paramRuntime/paramRuntime.test.d.ts.map +1 -0
- package/dist/src/paramRuntime/paramStore.d.ts +68 -0
- package/dist/src/paramRuntime/paramStore.d.ts.map +1 -0
- package/dist/src/paramRuntime/paramStore.js +148 -0
- package/dist/src/paramRuntime/paramStore.test.d.ts +2 -0
- package/dist/src/paramRuntime/paramStore.test.d.ts.map +1 -0
- package/dist/src/paramRuntime/paramUtils.d.ts +86 -0
- package/dist/src/paramRuntime/paramUtils.d.ts.map +1 -0
- package/dist/src/paramRuntime/paramUtils.js +272 -0
- package/dist/src/paramRuntime/selectionStore.d.ts +6 -0
- package/dist/src/paramRuntime/selectionStore.d.ts.map +1 -0
- package/dist/src/paramRuntime/selectionStore.js +13 -0
- package/dist/src/paramRuntime/types.d.ts +16 -0
- package/dist/src/paramRuntime/types.d.ts.map +1 -0
- package/dist/src/paramRuntime/types.js +25 -0
- package/dist/src/paramRuntime/viewParamRuntime.d.ts +164 -0
- package/dist/src/paramRuntime/viewParamRuntime.d.ts.map +1 -0
- package/dist/src/paramRuntime/viewParamRuntime.js +443 -0
- package/dist/src/scale/scale.d.ts +6 -1
- package/dist/src/scale/scale.d.ts.map +1 -1
- package/dist/src/scale/scale.js +83 -23
- package/dist/src/scales/axisResolution.d.ts.map +1 -1
- package/dist/src/scales/axisResolution.js +10 -0
- package/dist/src/scales/{scaleDomainAggregator.d.ts → domainPlanner.d.ts} +6 -3
- package/dist/src/scales/domainPlanner.d.ts.map +1 -0
- package/dist/src/scales/{scaleDomainAggregator.js → domainPlanner.js} +128 -10
- package/dist/src/scales/domainPlanner.test.d.ts +2 -0
- package/dist/src/scales/domainPlanner.test.d.ts.map +1 -0
- package/dist/src/scales/scaleInstanceManager.d.ts +6 -3
- package/dist/src/scales/scaleInstanceManager.d.ts.map +1 -1
- package/dist/src/scales/scaleInstanceManager.js +17 -11
- package/dist/src/scales/scaleInteractionController.d.ts +6 -0
- package/dist/src/scales/scaleInteractionController.d.ts.map +1 -1
- package/dist/src/scales/scaleInteractionController.js +41 -3
- package/dist/src/scales/scaleResolution.d.ts +20 -17
- package/dist/src/scales/scaleResolution.d.ts.map +1 -1
- package/dist/src/scales/scaleResolution.js +188 -71
- package/dist/src/scales/scaleResolution.test.d.ts.map +1 -1
- package/dist/src/selection/selection.d.ts +21 -0
- package/dist/src/selection/selection.d.ts.map +1 -1
- package/dist/src/selection/selection.js +83 -1
- package/dist/src/spec/channel.d.ts +52 -15
- package/dist/src/spec/coreSchemaRoot.d.ts +53 -0
- package/dist/src/spec/data.d.ts +4 -0
- package/dist/src/spec/parameter.d.ts +16 -11
- package/dist/src/spec/root.d.ts +1 -1
- package/dist/src/spec/testing.d.ts +12 -0
- package/dist/src/spec/testing.d.ts.map +1 -0
- package/dist/src/spec/testing.js +20 -0
- package/dist/src/spec/view.d.ts +157 -41
- package/dist/src/styles/genome-spy.css +3 -31
- package/dist/src/styles/genome-spy.css.d.ts +1 -1
- package/dist/src/styles/genome-spy.css.d.ts.map +1 -1
- package/dist/src/styles/genome-spy.css.js +0 -29
- package/dist/src/tooltip/dataTooltipHandler.d.ts +1 -1
- package/dist/src/tooltip/dataTooltipHandler.js +23 -32
- package/dist/src/tooltip/dataTooltipHandler.test.d.ts +2 -0
- package/dist/src/tooltip/dataTooltipHandler.test.d.ts.map +1 -0
- package/dist/src/tooltip/flattenDatumRows.d.ts +13 -0
- package/dist/src/tooltip/flattenDatumRows.d.ts.map +1 -0
- package/dist/src/tooltip/flattenDatumRows.js +47 -0
- package/dist/src/tooltip/flattenDatumRows.test.d.ts +2 -0
- package/dist/src/tooltip/flattenDatumRows.test.d.ts.map +1 -0
- package/dist/src/tooltip/refseqGeneTooltipHandler.d.ts +1 -1
- package/dist/src/tooltip/refseqGeneTooltipHandler.js +7 -1
- package/dist/src/tooltip/tooltipContext.d.ts +13 -0
- package/dist/src/tooltip/tooltipContext.d.ts.map +1 -0
- package/dist/src/tooltip/tooltipContext.js +543 -0
- package/dist/src/tooltip/tooltipContext.test.d.ts +2 -0
- package/dist/src/tooltip/tooltipContext.test.d.ts.map +1 -0
- package/dist/src/tooltip/tooltipHandler.d.ts +40 -1
- package/dist/src/tooltip/tooltipHandler.d.ts.map +1 -1
- package/dist/src/tooltip/tooltipHandler.ts +62 -1
- package/dist/src/types/encoder.d.ts +38 -3
- package/dist/src/types/rendering.d.ts +4 -3
- package/dist/src/types/viewContext.d.ts +0 -14
- package/dist/src/utils/inputBinding.d.ts +10 -2
- package/dist/src/utils/inputBinding.d.ts.map +1 -1
- package/dist/src/utils/inputBinding.js +12 -3
- package/dist/src/utils/throttle.d.ts +4 -1
- package/dist/src/utils/throttle.d.ts.map +1 -1
- package/dist/src/utils/throttle.js +54 -23
- package/dist/src/utils/throttle.test.d.ts +2 -0
- package/dist/src/utils/throttle.test.d.ts.map +1 -0
- package/dist/src/utils/transition.d.ts +21 -0
- package/dist/src/utils/transition.d.ts.map +1 -1
- package/dist/src/utils/transition.js +28 -0
- package/dist/src/utils/ui/tooltip.d.ts.map +1 -1
- package/dist/src/utils/ui/tooltip.js +7 -1
- package/dist/src/utils/ui/tooltip.test.d.ts +2 -0
- package/dist/src/utils/ui/tooltip.test.d.ts.map +1 -0
- package/dist/src/view/axisGridView.d.ts.map +1 -1
- package/dist/src/view/axisGridView.js +22 -5
- package/dist/src/view/axisView.d.ts.map +1 -1
- package/dist/src/view/axisView.js +20 -5
- package/dist/src/view/concatView.js +3 -3
- package/dist/src/view/containerMutationHelper.js +1 -1
- package/dist/src/view/containerView.d.ts +9 -5
- package/dist/src/view/containerView.d.ts.map +1 -1
- package/dist/src/view/containerView.js +34 -9
- package/dist/src/view/dataReadiness.d.ts +46 -0
- package/dist/src/view/dataReadiness.d.ts.map +1 -0
- package/dist/src/view/dataReadiness.js +267 -0
- package/dist/src/view/dataReadiness.test.d.ts +2 -0
- package/dist/src/view/dataReadiness.test.d.ts.map +1 -0
- package/dist/src/view/facetView.d.ts.map +1 -1
- package/dist/src/view/facetView.js +7 -5
- package/dist/src/view/flowBuilder.d.ts.map +1 -1
- package/dist/src/view/flowBuilder.js +17 -4
- package/dist/src/view/gridView/gridChild.d.ts.map +1 -1
- package/dist/src/view/gridView/gridChild.js +16 -3
- package/dist/src/view/gridView/gridView.d.ts.map +1 -1
- package/dist/src/view/gridView/gridView.js +119 -2
- package/dist/src/view/gridView/scrollbar.d.ts.map +1 -1
- package/dist/src/view/gridView/scrollbar.js +3 -0
- package/dist/src/view/gridView/selectionRect.d.ts +6 -10
- package/dist/src/view/gridView/selectionRect.d.ts.map +1 -1
- package/dist/src/view/gridView/selectionRect.js +22 -24
- package/dist/src/view/gridView/separatorView.d.ts +51 -0
- package/dist/src/view/gridView/separatorView.d.ts.map +1 -0
- package/dist/src/view/gridView/separatorView.js +275 -0
- package/dist/src/view/layerView.d.ts.map +1 -1
- package/dist/src/view/layerView.js +7 -5
- package/dist/src/view/layout/flexLayout.d.ts +0 -30
- package/dist/src/view/layout/flexLayout.d.ts.map +1 -1
- package/dist/src/view/layout/flexLayout.js +0 -86
- package/dist/src/view/multiscale.d.ts +35 -0
- package/dist/src/view/multiscale.d.ts.map +1 -0
- package/dist/src/view/multiscale.js +233 -0
- package/dist/src/view/multiscale.test.d.ts +2 -0
- package/dist/src/view/multiscale.test.d.ts.map +1 -0
- package/dist/src/view/testUtils.d.ts.map +1 -1
- package/dist/src/view/testUtils.js +6 -1
- package/dist/src/view/unitView.d.ts +8 -13
- package/dist/src/view/unitView.d.ts.map +1 -1
- package/dist/src/view/unitView.js +120 -45
- package/dist/src/view/view.d.ts +27 -18
- package/dist/src/view/view.d.ts.map +1 -1
- package/dist/src/view/view.js +298 -37
- package/dist/src/view/viewFactory.d.ts +0 -12
- package/dist/src/view/viewFactory.d.ts.map +1 -1
- package/dist/src/view/viewFactory.js +55 -25
- package/dist/src/view/viewParamRuntime.test.d.ts +2 -0
- package/dist/src/view/viewParamRuntime.test.d.ts.map +1 -0
- package/dist/src/view/viewSelectors.d.ts +148 -0
- package/dist/src/view/viewSelectors.d.ts.map +1 -0
- package/dist/src/view/viewSelectors.js +776 -0
- package/dist/src/view/viewSelectors.test.d.ts +2 -0
- package/dist/src/view/viewSelectors.test.d.ts.map +1 -0
- package/dist/src/view/viewUtils.d.ts +0 -8
- package/dist/src/view/viewUtils.d.ts.map +1 -1
- package/dist/src/view/viewUtils.js +1 -21
- package/package.json +4 -4
- package/dist/src/scales/scaleDomainAggregator.d.ts.map +0 -1
- package/dist/src/scales/scaleDomainAggregator.test.d.ts +0 -2
- package/dist/src/scales/scaleDomainAggregator.test.d.ts.map +0 -1
- package/dist/src/spec/sampleView.d.ts +0 -197
- package/dist/src/view/paramMediator.d.ts +0 -149
- package/dist/src/view/paramMediator.d.ts.map +0 -1
- package/dist/src/view/paramMediator.js +0 -478
- package/dist/src/view/paramMediator.test.d.ts +0 -2
- package/dist/src/view/paramMediator.test.d.ts.map +0 -1
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
import { isString } from "vega-util";
|
|
2
|
+
import ParamRuntime from "./paramRuntime.js";
|
|
3
|
+
import {
|
|
4
|
+
getDefaultParamValue,
|
|
5
|
+
isSelectionParameter,
|
|
6
|
+
validateParameterName,
|
|
7
|
+
} from "./paramUtils.js";
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
activateExprRefProps,
|
|
11
|
+
getDefaultParamValue,
|
|
12
|
+
isExprRef,
|
|
13
|
+
isSelectionParameter,
|
|
14
|
+
isVariableParameter,
|
|
15
|
+
makeConstantExprRef,
|
|
16
|
+
validateParameterName,
|
|
17
|
+
withoutExprRef,
|
|
18
|
+
} from "./paramUtils.js";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A class that manages parameters and expressions.
|
|
22
|
+
* Supports nesting and scoped parameters through a shared runtime graph.
|
|
23
|
+
* The architecture follows signal-graph ideas (explicit dependencies, batched
|
|
24
|
+
* propagation, deterministic scheduling) while keeping GenomeSpy-specific
|
|
25
|
+
* parameter and expression semantics.
|
|
26
|
+
*
|
|
27
|
+
* @typedef {import("../utils/expression.js").ExpressionFunction & { subscribe: (listener: () => void) => () => void, invalidate: () => void, identifier: () => string}} ExprRefFunction
|
|
28
|
+
*/
|
|
29
|
+
export default class ViewParamRuntime {
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {import("../spec/parameter.js").Parameter} Parameter
|
|
32
|
+
* @typedef {(value: any) => void} ParameterSetter
|
|
33
|
+
*
|
|
34
|
+
* @typedef {object} WatchExpressionOptions
|
|
35
|
+
* @prop {boolean} [scopeOwned=true]
|
|
36
|
+
* Whether the subscription lifecycle is owned by this runtime scope.
|
|
37
|
+
* When true, the listener is unsubscribed automatically during
|
|
38
|
+
* `dispose()` via scope disposal. Set to false when another owner
|
|
39
|
+
* (for example a `View` disposer registry) controls teardown.
|
|
40
|
+
* @prop {(disposer: () => void) => void} [registerDisposer]
|
|
41
|
+
* Optional external disposer registration hook. When provided, the
|
|
42
|
+
* unsubscribe callback is passed to this hook in addition to any
|
|
43
|
+
* scope-owned registration.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/** @type {ParamRuntime} */
|
|
47
|
+
#runtime;
|
|
48
|
+
|
|
49
|
+
/** @type {string} */
|
|
50
|
+
#scopeId;
|
|
51
|
+
|
|
52
|
+
/** @type {Map<string, (value: any) => void>} */
|
|
53
|
+
#allocatedSetters = new Map();
|
|
54
|
+
|
|
55
|
+
/** @type {Map<string, import("./types.js").ParamRef<any>>} */
|
|
56
|
+
#localRefs = new Map();
|
|
57
|
+
|
|
58
|
+
/** @type {Map<string, Parameter>} */
|
|
59
|
+
#paramConfigs = new Map();
|
|
60
|
+
|
|
61
|
+
/** @type {() => ViewParamRuntime} */
|
|
62
|
+
#parentFinder;
|
|
63
|
+
|
|
64
|
+
#disposed = false;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param {() => ViewParamRuntime} [parentFinder]
|
|
68
|
+
* An optional function that returns the parent runtime.
|
|
69
|
+
* N.B. The function must always return the same runtime for the same parent,
|
|
70
|
+
* i.e., the changing the structure of the hierarchy is NOT supported.
|
|
71
|
+
*/
|
|
72
|
+
constructor(parentFinder) {
|
|
73
|
+
this.#parentFinder = parentFinder ?? (() => undefined);
|
|
74
|
+
|
|
75
|
+
const parent = this.#parentFinder();
|
|
76
|
+
if (parent) {
|
|
77
|
+
this.#runtime = parent.#runtime;
|
|
78
|
+
this.#scopeId = this.#runtime.createScope(parent.#scopeId);
|
|
79
|
+
} else {
|
|
80
|
+
this.#runtime = new ParamRuntime();
|
|
81
|
+
this.#scopeId = this.#runtime.createScope();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Registers a parameter definition into this runtime scope.
|
|
87
|
+
*
|
|
88
|
+
* Returns a writable setter for writable parameters (`value`, `select`,
|
|
89
|
+
* `push: "outer"`). For derived (`expr`) parameters, the returned setter
|
|
90
|
+
* throws.
|
|
91
|
+
*
|
|
92
|
+
* A parameter name can be registered only once per runtime scope.
|
|
93
|
+
*
|
|
94
|
+
* @param {Parameter} param
|
|
95
|
+
* @returns {ParameterSetter}
|
|
96
|
+
*/
|
|
97
|
+
registerParam(param) {
|
|
98
|
+
const name = param.name;
|
|
99
|
+
validateParameterName(name);
|
|
100
|
+
|
|
101
|
+
if (this.#paramConfigs.has(name)) {
|
|
102
|
+
throw new Error(
|
|
103
|
+
'Parameter "' + name + '" already registered in this scope.'
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if ("value" in param && "expr" in param) {
|
|
108
|
+
throw new Error(
|
|
109
|
+
`The parameter "${name}" must not have both value and expr properties!`
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** @type {ParameterSetter} */
|
|
114
|
+
let setter;
|
|
115
|
+
let defaultValue;
|
|
116
|
+
|
|
117
|
+
if (param.push == "outer") {
|
|
118
|
+
const outerRuntime = this.findRuntimeForParam(name);
|
|
119
|
+
if (!outerRuntime) {
|
|
120
|
+
throw new Error(
|
|
121
|
+
`Parameter "${name}" not found in outer scope!`
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const outerProps = outerRuntime.paramConfigs.get(name);
|
|
126
|
+
if (!outerProps) {
|
|
127
|
+
throw new Error(
|
|
128
|
+
`Outer parameter "${name}" exists as a value but has no registered config.`
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
if ("expr" in outerProps || "select" in outerProps) {
|
|
132
|
+
throw new Error(
|
|
133
|
+
`The outer parameter "${name}" must not have expr or select properties!`
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
setter = (
|
|
137
|
+
/** @type {any} */
|
|
138
|
+
value
|
|
139
|
+
) => {
|
|
140
|
+
outerRuntime.setValue(name, value);
|
|
141
|
+
};
|
|
142
|
+
// The following will become a bit fragile if the view hierarchy is going to
|
|
143
|
+
// support mutation (i.e. adding/removing children) in future.
|
|
144
|
+
this.#allocatedSetters.set(name, setter);
|
|
145
|
+
} else if ("value" in param) {
|
|
146
|
+
defaultValue = getDefaultParamValue(param, this);
|
|
147
|
+
setter = this.#registerBaseSetter(name, defaultValue);
|
|
148
|
+
} else if ("expr" in param) {
|
|
149
|
+
const ref = this.#runtime.registerDerived(
|
|
150
|
+
this.#scopeId,
|
|
151
|
+
name,
|
|
152
|
+
param.expr
|
|
153
|
+
);
|
|
154
|
+
this.#localRefs.set(name, ref);
|
|
155
|
+
setter = () => {
|
|
156
|
+
throw new Error('Cannot set derived parameter "' + name + '".');
|
|
157
|
+
};
|
|
158
|
+
} else {
|
|
159
|
+
defaultValue = getDefaultParamValue(param, this);
|
|
160
|
+
setter = this.#registerBaseSetter(name, defaultValue);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if ("select" in param) {
|
|
164
|
+
defaultValue ??= getDefaultParamValue(param, this);
|
|
165
|
+
if (!this.#allocatedSetters.has(name)) {
|
|
166
|
+
const ref = this.#runtime.registerSelection(
|
|
167
|
+
this.#scopeId,
|
|
168
|
+
name,
|
|
169
|
+
defaultValue
|
|
170
|
+
);
|
|
171
|
+
this.#localRefs.set(name, ref);
|
|
172
|
+
this.#allocatedSetters.set(name, (value) => {
|
|
173
|
+
ref.set(value);
|
|
174
|
+
this.#runtime.flushNow();
|
|
175
|
+
});
|
|
176
|
+
setter = this.#allocatedSetters.get(name);
|
|
177
|
+
}
|
|
178
|
+
// Set initial value so that production rules in shaders can be generated, etc.
|
|
179
|
+
setter(defaultValue);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
this.#paramConfigs.set(name, param);
|
|
183
|
+
|
|
184
|
+
return setter;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
*
|
|
189
|
+
* @param {string} paramName
|
|
190
|
+
* @param {T} initialValue
|
|
191
|
+
* @param {boolean} [passive] If true, the setter will not notify listeners when the value changes.
|
|
192
|
+
* @returns {(value: T) => void}
|
|
193
|
+
* @template T
|
|
194
|
+
*/
|
|
195
|
+
allocateSetter(paramName, initialValue, passive = false) {
|
|
196
|
+
validateParameterName(paramName);
|
|
197
|
+
|
|
198
|
+
if (this.#allocatedSetters.has(paramName)) {
|
|
199
|
+
throw new Error(
|
|
200
|
+
"Setter already allocated for parameter: " + paramName
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const ref = this.#runtime.registerBase(
|
|
205
|
+
this.#scopeId,
|
|
206
|
+
paramName,
|
|
207
|
+
initialValue,
|
|
208
|
+
{
|
|
209
|
+
notify: !passive,
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
this.#localRefs.set(paramName, ref);
|
|
213
|
+
const setter = (
|
|
214
|
+
/** @type {T} */
|
|
215
|
+
value
|
|
216
|
+
) => {
|
|
217
|
+
ref.set(value);
|
|
218
|
+
this.#runtime.flushNow();
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
this.#allocatedSetters.set(paramName, setter);
|
|
222
|
+
|
|
223
|
+
return setter;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Sets a writable parameter value in this runtime scope.
|
|
228
|
+
*
|
|
229
|
+
* Only parameters with locally registered writable setters are supported.
|
|
230
|
+
* This method does not resolve through ancestors.
|
|
231
|
+
*
|
|
232
|
+
* @param {string} paramName
|
|
233
|
+
* @param {any} value
|
|
234
|
+
*/
|
|
235
|
+
setValue(paramName, value) {
|
|
236
|
+
validateParameterName(paramName);
|
|
237
|
+
const setter = this.#allocatedSetters.get(paramName);
|
|
238
|
+
if (!setter) {
|
|
239
|
+
throw new Error(
|
|
240
|
+
"Writable parameter not found in this scope: " + paramName
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
setter(value);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Get the value of a parameter from this runtime.
|
|
248
|
+
* @param {string} paramName
|
|
249
|
+
*/
|
|
250
|
+
getValue(paramName) {
|
|
251
|
+
return this.#localRefs.get(paramName)?.get();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Subscribe to changes of a parameter's value. The listener is called only
|
|
256
|
+
* when the stored value changes. For expression parameters, the listener is
|
|
257
|
+
* called when upstream changes re-evaluate to a different value.
|
|
258
|
+
*
|
|
259
|
+
* @param {string} paramName
|
|
260
|
+
* @param {() => void} listener
|
|
261
|
+
* @returns {() => void}
|
|
262
|
+
*/
|
|
263
|
+
subscribe(paramName, listener) {
|
|
264
|
+
validateParameterName(paramName);
|
|
265
|
+
const runtime = this.findRuntimeForParam(paramName);
|
|
266
|
+
if (!runtime) {
|
|
267
|
+
throw new Error("Parameter not found: " + paramName);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const ref = runtime.#localRefs.get(paramName);
|
|
271
|
+
if (!ref) {
|
|
272
|
+
throw new Error(
|
|
273
|
+
"Parameter found without local reference: " + paramName
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return ref.subscribe(listener);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Get the value of a parameter from this runtime or its ancestors.
|
|
282
|
+
* @param {string} paramName
|
|
283
|
+
*/
|
|
284
|
+
findValue(paramName) {
|
|
285
|
+
const runtime = this.findRuntimeForParam(paramName);
|
|
286
|
+
return runtime?.getValue(paramName);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Returns configs for all parameters that have been registered using `registerParam`.
|
|
291
|
+
*/
|
|
292
|
+
get paramConfigs() {
|
|
293
|
+
return /** @type {ReadonlyMap<string, Parameter>} */ (
|
|
294
|
+
this.#paramConfigs
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
*
|
|
300
|
+
* @param {string} paramName
|
|
301
|
+
* @returns {ViewParamRuntime}
|
|
302
|
+
*/
|
|
303
|
+
findRuntimeForParam(paramName) {
|
|
304
|
+
if (this.#localRefs.has(paramName)) {
|
|
305
|
+
return this;
|
|
306
|
+
} else {
|
|
307
|
+
return this.#parentFinder()?.findRuntimeForParam(paramName);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// Setter lifecycle is scope-owned: setters are dropped when the runtime scope
|
|
312
|
+
// is disposed. A standalone deallocation API is intentionally not exposed.
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Parse expr and return a function that returns the value of the parameter.
|
|
316
|
+
*
|
|
317
|
+
* @param {string} expr
|
|
318
|
+
*/
|
|
319
|
+
createExpression(expr) {
|
|
320
|
+
return this.#runtime.createExpression(this.#scopeId, expr);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Creates an expression and subscribes a listener that is automatically
|
|
325
|
+
* removed according to `options` lifecycle ownership.
|
|
326
|
+
*
|
|
327
|
+
* Lifecycle semantics:
|
|
328
|
+
* 1. `scopeOwned: true` (default): unsubscribe is bound to runtime scope
|
|
329
|
+
* disposal (`ViewParamRuntime.dispose()`).
|
|
330
|
+
* 2. `scopeOwned: false`: caller must own teardown, typically via
|
|
331
|
+
* `registerDisposer` or by storing and calling the returned unsubscribe.
|
|
332
|
+
* 3. `registerDisposer` can be used regardless of `scopeOwned` to bind the
|
|
333
|
+
* same unsubscribe to another lifecycle owner.
|
|
334
|
+
*
|
|
335
|
+
* @param {string} expr
|
|
336
|
+
* @param {() => void} listener
|
|
337
|
+
* @param {WatchExpressionOptions} [options]
|
|
338
|
+
* @returns {ExprRefFunction}
|
|
339
|
+
*/
|
|
340
|
+
watchExpression(expr, listener, options = {}) {
|
|
341
|
+
const fn = this.createExpression(expr);
|
|
342
|
+
const dispose = fn.subscribe(listener);
|
|
343
|
+
|
|
344
|
+
if (options.scopeOwned ?? true) {
|
|
345
|
+
this.#runtime.addScopeDisposer(this.#scopeId, dispose);
|
|
346
|
+
}
|
|
347
|
+
options.registerDisposer?.(dispose);
|
|
348
|
+
|
|
349
|
+
return fn;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* @template T
|
|
354
|
+
* @param {string} name
|
|
355
|
+
* @param {T} defaultValue
|
|
356
|
+
* @returns {(value: T) => void}
|
|
357
|
+
*/
|
|
358
|
+
#registerBaseSetter(name, defaultValue) {
|
|
359
|
+
const ref = this.#runtime.registerBase(
|
|
360
|
+
this.#scopeId,
|
|
361
|
+
name,
|
|
362
|
+
defaultValue
|
|
363
|
+
);
|
|
364
|
+
this.#localRefs.set(name, ref);
|
|
365
|
+
const setter = (
|
|
366
|
+
/** @type {T} */
|
|
367
|
+
value
|
|
368
|
+
) => {
|
|
369
|
+
ref.set(value);
|
|
370
|
+
this.#runtime.flushNow();
|
|
371
|
+
};
|
|
372
|
+
this.#allocatedSetters.set(name, setter);
|
|
373
|
+
return setter;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* A convenience method for evaluating an expression.
|
|
378
|
+
*
|
|
379
|
+
* @param {string} expr
|
|
380
|
+
*/
|
|
381
|
+
evaluateAndGet(expr) {
|
|
382
|
+
const fn = this.createExpression(expr);
|
|
383
|
+
return fn();
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* @template T
|
|
388
|
+
* @param {() => T} fn
|
|
389
|
+
* @returns {T}
|
|
390
|
+
*/
|
|
391
|
+
runInTransaction(fn) {
|
|
392
|
+
return this.#runtime.runInTransaction(fn);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
flushNow() {
|
|
396
|
+
this.#runtime.flushNow();
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Sync barrier only: resolves when DAG propagation/effects have flushed.
|
|
401
|
+
* Must not be broadened to temporal/animation convergence semantics.
|
|
402
|
+
*
|
|
403
|
+
* @param {{ signal?: AbortSignal, timeoutMs?: number }} [options]
|
|
404
|
+
*/
|
|
405
|
+
whenPropagated(options) {
|
|
406
|
+
return this.#runtime.whenPropagated(options);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
dispose() {
|
|
410
|
+
if (this.#disposed) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
this.#disposed = true;
|
|
415
|
+
this.#runtime.disposeScope(this.#scopeId);
|
|
416
|
+
this.#allocatedSetters.clear();
|
|
417
|
+
this.#localRefs.clear();
|
|
418
|
+
this.#paramConfigs.clear();
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Returns true if this runtime has any parameters that are point selections.
|
|
423
|
+
* Point selections necessitate the use of uniqueIds in the data.
|
|
424
|
+
*
|
|
425
|
+
* @returns {boolean}
|
|
426
|
+
*/
|
|
427
|
+
hasPointSelections() {
|
|
428
|
+
for (const param of this.#paramConfigs.values()) {
|
|
429
|
+
if (isSelectionParameter(param)) {
|
|
430
|
+
const select = param.select;
|
|
431
|
+
if (isString(select)) {
|
|
432
|
+
if (select == "point") {
|
|
433
|
+
return true;
|
|
434
|
+
}
|
|
435
|
+
} else if (select.type == "point") {
|
|
436
|
+
return true;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
@@ -6,5 +6,10 @@ export function configureScale(_: any, scale: any, logger: any): void;
|
|
|
6
6
|
* @returns {import("../encoder/encoder.js").VegaScale}
|
|
7
7
|
*/
|
|
8
8
|
export default function createScale(_: import("../spec/scale.js").Scale, logger: any): import("../encoder/encoder.js").VegaScale;
|
|
9
|
-
export function configureDomain(scale: any, _: any, logger: any):
|
|
9
|
+
export function configureDomain(scale: any, _: any, logger: any): {
|
|
10
|
+
domain: any;
|
|
11
|
+
count: any;
|
|
12
|
+
ordinalUnknown: any;
|
|
13
|
+
applyOrdinalUnknown: boolean;
|
|
14
|
+
};
|
|
10
15
|
//# sourceMappingURL=scale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scale.d.ts","sourceRoot":"","sources":["../../../src/scale/scale.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scale.d.ts","sourceRoot":"","sources":["../../../src/scale/scale.js"],"names":[],"mappings":"AAgIA,sEAuBC;AAED;;;;;GAKG;AACH,uCAJW,OAAO,kBAAkB,EAAE,KAAK,UAChC,GAAC,GACC,OAAO,uBAAuB,EAAE,SAAS,CAoBrD;AA4CD;;;;;EAuGC"}
|
package/dist/src/scale/scale.js
CHANGED
|
@@ -11,8 +11,20 @@
|
|
|
11
11
|
/* eslint-disable */
|
|
12
12
|
// @ts-nocheck
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
/*
|
|
15
|
+
* Rewrite rationale (non-perf):
|
|
16
|
+
* - This module mixes spec-level policy, vega-scale helpers, and D3 scale
|
|
17
|
+
* mutability. The combination works but is clunky to maintain and hard to
|
|
18
|
+
* integrate with higher-level orchestration like ScaleResolution.
|
|
19
|
+
* - Side-effectful configuration and implicit defaults make the data flow
|
|
20
|
+
* difficult to reason about and to test in isolation.
|
|
21
|
+
*
|
|
22
|
+
* Why not rewrite yet:
|
|
23
|
+
* - Behavior is subtle and well-tested; a rewrite is risky without a clear
|
|
24
|
+
* contract for the pure inputs/outputs and their callers.
|
|
25
|
+
* - It depends on D3 scale semantics (copy, unknown, interpolate, etc.), so any
|
|
26
|
+
* refactor must preserve those semantics explicitly.
|
|
27
|
+
*/
|
|
16
28
|
|
|
17
29
|
import { tickCount } from "./ticks.js";
|
|
18
30
|
import {
|
|
@@ -128,11 +140,15 @@ export function configureScale(_, scale, logger) {
|
|
|
128
140
|
}
|
|
129
141
|
}
|
|
130
142
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
)
|
|
143
|
+
const domainConfig = configureDomain(scale, _, logger);
|
|
144
|
+
if (domainConfig.domain) {
|
|
145
|
+
scale.domain(domainConfig.domain);
|
|
146
|
+
}
|
|
147
|
+
if (domainConfig.applyOrdinalUnknown) {
|
|
148
|
+
scale.unknown(domainConfig.ordinalUnknown);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
configureRange(scale, _, configureBins(scale, _, domainConfig.count));
|
|
136
152
|
}
|
|
137
153
|
|
|
138
154
|
/**
|
|
@@ -191,24 +207,62 @@ function isContinuousColor(_) {
|
|
|
191
207
|
);
|
|
192
208
|
}
|
|
193
209
|
|
|
210
|
+
function copyScaleForDomain(scale) {
|
|
211
|
+
if (!scale.copy) {
|
|
212
|
+
return scale;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const copy = scale.copy();
|
|
216
|
+
if (copy.type == null && scale.type != null) {
|
|
217
|
+
copy.type = scale.type;
|
|
218
|
+
}
|
|
219
|
+
return copy;
|
|
220
|
+
}
|
|
221
|
+
|
|
194
222
|
export function configureDomain(scale, _, logger) {
|
|
195
223
|
if (!scale.domain) {
|
|
196
|
-
return
|
|
224
|
+
return {
|
|
225
|
+
domain: null,
|
|
226
|
+
count: 0,
|
|
227
|
+
ordinalUnknown: undefined,
|
|
228
|
+
applyOrdinalUnknown: false,
|
|
229
|
+
};
|
|
197
230
|
}
|
|
198
231
|
|
|
199
232
|
logger = ensureLogger(logger);
|
|
200
233
|
|
|
234
|
+
const workingScale = copyScaleForDomain(scale);
|
|
235
|
+
|
|
201
236
|
// check raw domain, if provided use that and exit early
|
|
202
|
-
var raw = rawDomain(
|
|
203
|
-
if (raw > -1)
|
|
237
|
+
var raw = rawDomain(workingScale, _.domainRaw, logger);
|
|
238
|
+
if (raw > -1) {
|
|
239
|
+
return {
|
|
240
|
+
domain: workingScale.domain(),
|
|
241
|
+
count: raw,
|
|
242
|
+
ordinalUnknown:
|
|
243
|
+
workingScale.type === Ordinal
|
|
244
|
+
? _.domainImplicit
|
|
245
|
+
? scaleImplicit
|
|
246
|
+
: undefined
|
|
247
|
+
: undefined,
|
|
248
|
+
applyOrdinalUnknown: false,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
204
251
|
|
|
205
252
|
var domain = _.domain,
|
|
206
|
-
type =
|
|
207
|
-
zero = _.zero || (_.zero === undefined && includeZero(
|
|
253
|
+
type = workingScale.type,
|
|
254
|
+
zero = _.zero || (_.zero === undefined && includeZero(workingScale)),
|
|
208
255
|
n,
|
|
209
256
|
mid;
|
|
210
257
|
|
|
211
|
-
if (!domain)
|
|
258
|
+
if (!domain) {
|
|
259
|
+
return {
|
|
260
|
+
domain: null,
|
|
261
|
+
count: 0,
|
|
262
|
+
ordinalUnknown: undefined,
|
|
263
|
+
applyOrdinalUnknown: false,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
212
266
|
|
|
213
267
|
// adjust continuous domain for minimum pixel padding
|
|
214
268
|
if (includePad(type) && _.padding && domain[0] !== peek(domain)) {
|
|
@@ -247,21 +301,27 @@ export function configureDomain(scale, _, logger) {
|
|
|
247
301
|
}
|
|
248
302
|
|
|
249
303
|
// set the scale domain
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
// if ordinal scale domain is defined, prevent implicit
|
|
253
|
-
// domain construction as side-effect of scale lookup
|
|
254
|
-
if (type === Ordinal) {
|
|
255
|
-
scale.unknown(_.domainImplicit ? scaleImplicit : undefined);
|
|
256
|
-
}
|
|
304
|
+
workingScale.domain(domainCheck(type, domain, logger));
|
|
257
305
|
|
|
258
306
|
// perform 'nice' adjustment as requested
|
|
259
|
-
if (_.nice &&
|
|
260
|
-
|
|
307
|
+
if (_.nice && workingScale.nice) {
|
|
308
|
+
workingScale.nice(
|
|
309
|
+
(_.nice !== true && tickCount(workingScale, _.nice)) || null
|
|
310
|
+
);
|
|
261
311
|
}
|
|
262
312
|
|
|
263
313
|
// return the cardinality of the domain
|
|
264
|
-
return
|
|
314
|
+
return {
|
|
315
|
+
domain: workingScale.domain(),
|
|
316
|
+
count: domain.length,
|
|
317
|
+
ordinalUnknown:
|
|
318
|
+
type === Ordinal
|
|
319
|
+
? _.domainImplicit
|
|
320
|
+
? scaleImplicit
|
|
321
|
+
: undefined
|
|
322
|
+
: undefined,
|
|
323
|
+
applyOrdinalUnknown: type === Ordinal,
|
|
324
|
+
};
|
|
265
325
|
}
|
|
266
326
|
|
|
267
327
|
function rawDomain(scale, raw, logger) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axisResolution.d.ts","sourceRoot":"","sources":["../../../src/scales/axisResolution.js"],"names":[],"mappings":"AAcA;;;;;;;GAOG;AACH;IASI;;OAEG;IACH,qBAFW,OAAO,oBAAoB,EAAE,wBAAwB,EAI/D;IADG,+DAAsB;IAG1B,2BAGC;IAiCD;;;OAGG;IACH,uBAHW,oBAAoB,GAClB,MAAM,OAAO,CAQzB;IAED;;;OAGG;IACH,qBAHW,oBAAoB,GAClB,OAAO,CAQnB;IAED,qDAuBC;IAED,
|
|
1
|
+
{"version":3,"file":"axisResolution.d.ts","sourceRoot":"","sources":["../../../src/scales/axisResolution.js"],"names":[],"mappings":"AAcA;;;;;;;GAOG;AACH;IASI;;OAEG;IACH,qBAFW,OAAO,oBAAoB,EAAE,wBAAwB,EAI/D;IADG,+DAAsB;IAG1B,2BAGC;IAiCD;;;OAGG;IACH,uBAHW,oBAAoB,GAClB,MAAM,OAAO,CAQzB;IAED;;;OAGG;IACH,qBAHW,oBAAoB,GAClB,OAAO,CAQnB;IAED,qDAuBC;IAED,mBAmEC;;CACJ;iCAhL6D,CAAC,SAAlD,OAAQ,oBAAoB,EAAE,iBAAkB;UAGnD,OAAO,qBAAqB,EAAE,OAAO;aACrC,CAAC;gBACD,OAAO,oBAAoB,EAAE,mBAAmB"}
|
|
@@ -137,6 +137,9 @@ export default class AxisResolution {
|
|
|
137
137
|
|
|
138
138
|
return {
|
|
139
139
|
member,
|
|
140
|
+
axisTitle:
|
|
141
|
+
// TODO: Proper type guard
|
|
142
|
+
"axis" in channelDef ? channelDef.axis?.title : undefined,
|
|
140
143
|
explicitTitle: coalesce(
|
|
141
144
|
// TODO: Proper type guard
|
|
142
145
|
"axis" in channelDef ? channelDef.axis?.title : undefined,
|
|
@@ -150,6 +153,13 @@ export default class AxisResolution {
|
|
|
150
153
|
};
|
|
151
154
|
|
|
152
155
|
const titles = Array.from(this.#members).map(computeTitle);
|
|
156
|
+
const explicitAxisTitle = titles
|
|
157
|
+
.map((title) => title.axisTitle)
|
|
158
|
+
.find((title) => title !== undefined);
|
|
159
|
+
|
|
160
|
+
if (explicitAxisTitle !== undefined) {
|
|
161
|
+
return explicitAxisTitle;
|
|
162
|
+
}
|
|
153
163
|
|
|
154
164
|
// Skip implicit secondary channel titles if the primary channel has an explicit title
|
|
155
165
|
const filteredTitles = titles.filter((title) => {
|
|
@@ -4,16 +4,18 @@
|
|
|
4
4
|
* @typedef {import("../spec/scale.js").ScalarDomain} ScalarDomain
|
|
5
5
|
* @typedef {import("./scaleResolution.js").ScaleResolutionMember} ScaleResolutionMember
|
|
6
6
|
*/
|
|
7
|
-
export default class
|
|
7
|
+
export default class DomainPlanner {
|
|
8
8
|
/**
|
|
9
9
|
* @param {object} options
|
|
10
10
|
* @param {() => Set<ScaleResolutionMember>} options.getMembers
|
|
11
|
+
* @param {() => Set<ScaleResolutionMember>} [options.getDataMembers]
|
|
11
12
|
* @param {() => import("../spec/channel.js").Type} options.getType
|
|
12
13
|
* @param {() => number[]} options.getLocusExtent
|
|
13
14
|
* @param {(interval: ScalarDomain | ComplexDomain) => number[]} options.fromComplexInterval
|
|
14
15
|
*/
|
|
15
|
-
constructor({ getMembers, getType, getLocusExtent, fromComplexInterval }: {
|
|
16
|
+
constructor({ getMembers, getDataMembers, getType, getLocusExtent, fromComplexInterval, }: {
|
|
16
17
|
getMembers: () => Set<ScaleResolutionMember>;
|
|
18
|
+
getDataMembers?: () => Set<ScaleResolutionMember>;
|
|
17
19
|
getType: () => import("../spec/channel.js").Type;
|
|
18
20
|
getLocusExtent: () => number[];
|
|
19
21
|
fromComplexInterval: (interval: ScalarDomain | ComplexDomain) => number[];
|
|
@@ -23,6 +25,7 @@ export default class ScaleDomainAggregator {
|
|
|
23
25
|
*/
|
|
24
26
|
get initialDomainSnapshot(): any[];
|
|
25
27
|
hasConfiguredDomain(): boolean;
|
|
28
|
+
invalidateConfiguredDomain(): void;
|
|
26
29
|
/**
|
|
27
30
|
* Returns the configured domain or a data-derived/default domain.
|
|
28
31
|
*
|
|
@@ -54,4 +57,4 @@ export type DomainArray = import("../utils/domainArray.js").DomainArray;
|
|
|
54
57
|
export type ComplexDomain = import("../spec/scale.js").ComplexDomain;
|
|
55
58
|
export type ScalarDomain = import("../spec/scale.js").ScalarDomain;
|
|
56
59
|
export type ScaleResolutionMember = import("./scaleResolution.js").ScaleResolutionMember;
|
|
57
|
-
//# sourceMappingURL=
|
|
60
|
+
//# sourceMappingURL=domainPlanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domainPlanner.d.ts","sourceRoot":"","sources":["../../../src/scales/domainPlanner.js"],"names":[],"mappings":"AAOA;;;;;GAKG;AAEH;IA2BI;;;;;;;OAOG;IACH,2FANG;QAAkD,UAAU,EAApD,MAAM,GAAG,CAAC,qBAAqB,CAAC;QACW,cAAc,GAAzD,MAAM,GAAG,CAAC,qBAAqB,CAAC;QACiB,OAAO,EAAxD,MAAM,OAAO,oBAAoB,EAAE,IAAI;QACf,cAAc,EAAtC,MAAM,MAAM,EAAE;QACgD,mBAAmB,EAAjF,CAAC,QAAQ,EAAE,YAAY,GAAG,aAAa,KAAK,MAAM,EAAE;KAC9D,EAaA;IAED;;OAEG;IACH,6BAFa,GAAG,EAAE,CAIjB;IAED,+BAEC;IAED,mCAEC;IAED;;;;;OAKG;IACH,iDAHW,OAAO,GACL,GAAG,EAAE,CAYjB;IAED;;;;OAIG;IACH,uBAFY,WAAW,CActB;IAED;;;;OAIG;IACH,iBAFY,WAAW,GAAG,SAAS,CAQlC;IAED;;;;OAIG;IACH,4BAJW,OAAO,qBAAqB,EAAE,SAAS,wBACvC,OAAO,GACL,OAAO,CAgBnB;;CAkCJ;0BA7KY,OAAO,yBAAyB,EAAE,WAAW;4BAC7C,OAAO,kBAAkB,EAAE,aAAa;2BACxC,OAAO,kBAAkB,EAAE,YAAY;oCACvC,OAAO,sBAAsB,EAAE,qBAAqB"}
|