@d3plus/core 4.5.0 → 4.6.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/README.md +3698 -1074
- package/es/index.js +3 -3
- package/es/index.js.map +1 -1
- package/es/internal.js +6 -1
- package/es/internal.js.map +1 -1
- package/es/src/charts/BarChart/index.js +8 -1
- package/es/src/charts/BarChart/index.js.map +1 -1
- package/es/src/charts/BoxWhisker/index.js +5 -0
- package/es/src/charts/BoxWhisker/index.js.map +1 -1
- package/es/src/charts/Chord/emit.js +55 -3
- package/es/src/charts/Chord/emit.js.map +1 -1
- package/es/src/charts/Chord/index.js +15 -0
- package/es/src/charts/Chord/index.js.map +1 -1
- package/es/src/charts/Geomap/applyLayout.js +17 -10
- package/es/src/charts/Geomap/applyLayout.js.map +1 -1
- package/es/src/charts/Geomap/index.js +5 -1
- package/es/src/charts/Geomap/index.js.map +1 -1
- package/es/src/charts/Histogram/binData.js +225 -0
- package/es/src/charts/Histogram/binData.js.map +1 -0
- package/es/src/charts/Histogram/index.js +271 -0
- package/es/src/charts/Histogram/index.js.map +1 -0
- package/es/src/charts/Network/applyLayout.js +52 -4
- package/es/src/charts/Network/applyLayout.js.map +1 -1
- package/es/src/charts/Network/emit.js +4 -4
- package/es/src/charts/Network/emit.js.map +1 -1
- package/es/src/charts/Network/index.js +6 -1
- package/es/src/charts/Network/index.js.map +1 -1
- package/es/src/charts/Pack/emit.js +37 -2
- package/es/src/charts/Pack/emit.js.map +1 -1
- package/es/src/charts/Pack/index.js +13 -0
- package/es/src/charts/Pack/index.js.map +1 -1
- package/es/src/charts/Pie/applyLayout.js +20 -2
- package/es/src/charts/Pie/applyLayout.js.map +1 -1
- package/es/src/charts/Pie/emit.js +274 -33
- package/es/src/charts/Pie/emit.js.map +1 -1
- package/es/src/charts/Pie/index.js +46 -1
- package/es/src/charts/Pie/index.js.map +1 -1
- package/es/src/charts/Plot/discreteSpan.js +42 -0
- package/es/src/charts/Plot/discreteSpan.js.map +1 -0
- package/es/src/charts/Plot/draw.js +3 -1
- package/es/src/charts/Plot/draw.js.map +1 -1
- package/es/src/charts/Plot/index.js +129 -14
- package/es/src/charts/Plot/index.js.map +1 -1
- package/es/src/charts/Plot/pipeline.js +47 -20
- package/es/src/charts/Plot/pipeline.js.map +1 -1
- package/es/src/charts/Plot/pipelineDomains.js +84 -8
- package/es/src/charts/Plot/pipelineDomains.js.map +1 -1
- package/es/src/charts/Plot/shapeDefaults.js +3 -3
- package/es/src/charts/Plot/shapeDefaults.js.map +1 -1
- package/es/src/charts/Plot/sharedHover.js +431 -0
- package/es/src/charts/Plot/sharedHover.js.map +1 -0
- package/es/src/charts/Plot/sharedHoverScene.js +230 -0
- package/es/src/charts/Plot/sharedHoverScene.js.map +1 -0
- package/es/src/charts/Plot/sharedTooltip.js +163 -0
- package/es/src/charts/Plot/sharedTooltip.js.map +1 -0
- package/es/src/charts/Plot/stackShareLabels.js +137 -0
- package/es/src/charts/Plot/stackShareLabels.js.map +1 -0
- package/es/src/charts/Plot/stackShareTooltip.js +31 -0
- package/es/src/charts/Plot/stackShareTooltip.js.map +1 -0
- package/es/src/charts/Plot/trendLines.js +367 -0
- package/es/src/charts/Plot/trendLines.js.map +1 -0
- package/es/src/charts/Plot/trendScene.js +220 -0
- package/es/src/charts/Plot/trendScene.js.map +1 -0
- package/es/src/charts/Plot/trendTooltip.js +160 -0
- package/es/src/charts/Plot/trendTooltip.js.map +1 -0
- package/es/src/charts/Priestley/emit.js +32 -3
- package/es/src/charts/Priestley/emit.js.map +1 -1
- package/es/src/charts/Radar/index.js +15 -2
- package/es/src/charts/Radar/index.js.map +1 -1
- package/es/src/charts/RadialMatrix/index.js +17 -1
- package/es/src/charts/RadialMatrix/index.js.map +1 -1
- package/es/src/charts/Rings/applyLayout.js +72 -116
- package/es/src/charts/Rings/applyLayout.js.map +1 -1
- package/es/src/charts/Rings/emit.js +2 -3
- package/es/src/charts/Rings/emit.js.map +1 -1
- package/es/src/charts/Rings/index.js +13 -2
- package/es/src/charts/Rings/index.js.map +1 -1
- package/es/src/charts/Rings/ringsSizing.js +189 -0
- package/es/src/charts/Rings/ringsSizing.js.map +1 -0
- package/es/src/charts/StackedArea/index.js +8 -1
- package/es/src/charts/StackedArea/index.js.map +1 -1
- package/es/src/charts/Tree/emit.js +2 -2
- package/es/src/charts/Tree/emit.js.map +1 -1
- package/es/src/charts/Tree/index.js +5 -3
- package/es/src/charts/Tree/index.js.map +1 -1
- package/es/src/charts/Treemap/emit.js +56 -3
- package/es/src/charts/Treemap/emit.js.map +1 -1
- package/es/src/charts/definition/ChartDefinition.js.map +1 -1
- package/es/src/charts/definition/makeChart.js +8 -1
- package/es/src/charts/definition/makeChart.js.map +1 -1
- package/es/src/charts/drawSteps/backControl.js +17 -2
- package/es/src/charts/drawSteps/backControl.js.map +1 -1
- package/es/src/charts/drawSteps/bottomRightControls.js +193 -0
- package/es/src/charts/drawSteps/bottomRightControls.js.map +1 -0
- package/es/src/charts/drawSteps/bottomRightControlsMarkup.js +161 -0
- package/es/src/charts/drawSteps/bottomRightControlsMarkup.js.map +1 -0
- package/es/src/charts/drawSteps/minimap.js +34 -9
- package/es/src/charts/drawSteps/minimap.js.map +1 -1
- package/es/src/charts/drawSteps/zoomControls.js +3 -0
- package/es/src/charts/drawSteps/zoomControls.js.map +1 -1
- package/es/src/charts/events/click.shape.js +24 -1
- package/es/src/charts/events/click.shape.js.map +1 -1
- package/es/src/charts/events/mouseenter.js +3 -0
- package/es/src/charts/events/mouseenter.js.map +1 -1
- package/es/src/charts/events/mouseleave.js +3 -0
- package/es/src/charts/events/mouseleave.js.map +1 -1
- package/es/src/charts/events/mousemove.shape.js +2 -0
- package/es/src/charts/events/mousemove.shape.js.map +1 -1
- package/es/src/charts/features/axes.js +4 -1
- package/es/src/charts/features/axes.js.map +1 -1
- package/es/src/charts/features/emitHelpers.js +24 -0
- package/es/src/charts/features/emitHelpers.js.map +1 -1
- package/es/src/charts/features/features.js +6 -2
- package/es/src/charts/features/features.js.map +1 -1
- package/es/src/charts/features/featuresLegend.js +13 -5
- package/es/src/charts/features/featuresLegend.js.map +1 -1
- package/es/src/charts/features/plotPaint.js +51 -24
- package/es/src/charts/features/plotPaint.js.map +1 -1
- package/es/src/charts/features/shapeEmit.js +20 -2
- package/es/src/charts/features/shapeEmit.js.map +1 -1
- package/es/src/charts/index.js +1 -0
- package/es/src/charts/index.js.map +1 -1
- package/es/src/charts/pipeline/drillMorph.js +159 -0
- package/es/src/charts/pipeline/drillMorph.js.map +1 -0
- package/es/src/charts/pipeline/runChartDraw.js +35 -1
- package/es/src/charts/pipeline/runChartDraw.js.map +1 -1
- package/es/src/charts/pipeline/runVizPipeline.js +16 -1
- package/es/src/charts/pipeline/runVizPipeline.js.map +1 -1
- package/es/src/charts/pipeline/vizDrawPure.js +20 -0
- package/es/src/charts/pipeline/vizDrawPure.js.map +1 -1
- package/es/src/charts/viz/Viz.js +64 -8
- package/es/src/charts/viz/Viz.js.map +1 -1
- package/es/src/charts/viz/VizBase.js +29 -1
- package/es/src/charts/viz/VizBase.js.map +1 -1
- package/es/src/charts/viz/VizBaseConfig.js +9 -1
- package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
- package/es/src/charts/viz/ordinalColor.js +2 -2
- package/es/src/charts/viz/ordinalColor.js.map +1 -1
- package/es/src/charts/viz/vizDefaults.js +27 -8
- package/es/src/charts/viz/vizDefaults.js.map +1 -1
- package/es/src/charts/viz/vizRender.js +54 -4
- package/es/src/charts/viz/vizRender.js.map +1 -1
- package/es/src/charts/viz/vizTypes.js.map +1 -1
- package/es/src/charts/viz/vizVisibility.js +145 -0
- package/es/src/charts/viz/vizVisibility.js.map +1 -0
- package/es/src/components/Axis/Axis.js +8 -8
- package/es/src/components/Axis/Axis.js.map +1 -1
- package/es/src/components/ColorScale/ColorScale.js +11 -11
- package/es/src/components/ColorScale/ColorScale.js.map +1 -1
- package/es/src/components/ColorScale/colorScaleScale.js +22 -10
- package/es/src/components/ColorScale/colorScaleScale.js.map +1 -1
- package/es/src/components/Legend/Legend.js +8 -5
- package/es/src/components/Legend/Legend.js.map +1 -1
- package/es/src/components/Legend/legendConfig.js +1 -1
- package/es/src/components/Legend/legendConfig.js.map +1 -1
- package/es/src/components/Legend/legendRender.js +29 -22
- package/es/src/components/Legend/legendRender.js.map +1 -1
- package/es/src/components/SizeLegend/SizeLegend.js +411 -0
- package/es/src/components/SizeLegend/SizeLegend.js.map +1 -0
- package/es/src/components/SizeLegend/sizeLegendLayout.js +285 -0
- package/es/src/components/SizeLegend/sizeLegendLayout.js.map +1 -0
- package/es/src/components/Timeline/timelineConfig.js +8 -4
- package/es/src/components/Timeline/timelineConfig.js.map +1 -1
- package/es/src/components/Timeline/timelineRender.js +1 -2
- package/es/src/components/Timeline/timelineRender.js.map +1 -1
- package/es/src/components/Tooltip.js +27 -7
- package/es/src/components/Tooltip.js.map +1 -1
- package/es/src/components/index.js +1 -0
- package/es/src/components/index.js.map +1 -1
- package/es/src/shapes/Box.js +4 -2
- package/es/src/shapes/Box.js.map +1 -1
- package/es/src/shapes/Shape.js +1 -1
- package/es/src/shapes/Shape.js.map +1 -1
- package/es/src/shapes/Whisker.js +3 -2
- package/es/src/shapes/Whisker.js.map +1 -1
- package/es/src/shapes/validateShapeConfig.js +141 -0
- package/es/src/shapes/validateShapeConfig.js.map +1 -0
- package/es/src/utils/BaseClass.js +134 -4
- package/es/src/utils/BaseClass.js.map +1 -1
- package/es/src/utils/D3plusConfig.js.map +1 -1
- package/es/src/utils/configDefault.js +17 -0
- package/es/src/utils/configDefault.js.map +1 -0
- package/es/src/utils/configPrep.js +2 -1
- package/es/src/utils/configPrep.js.map +1 -1
- package/es/src/utils/configWarnings.js +37 -0
- package/es/src/utils/configWarnings.js.map +1 -0
- package/es/src/utils/index.js +1 -0
- package/es/src/utils/index.js.map +1 -1
- package/package.json +11 -10
- package/types/index.d.ts +4 -4
- package/types/internal.d.ts +8 -1
- package/types/src/charts/BarChart/index.d.ts +2 -1
- package/types/src/charts/Geomap/applyLayout.d.ts +9 -1
- package/types/src/charts/Histogram/binData.d.ts +37 -0
- package/types/src/charts/Histogram/index.d.ts +14 -0
- package/types/src/charts/Network/applyLayout.d.ts +8 -0
- package/types/src/charts/Plot/discreteSpan.d.ts +9 -0
- package/types/src/charts/Plot/index.d.ts +39 -0
- package/types/src/charts/Plot/pipeline.d.ts +14 -0
- package/types/src/charts/Plot/sharedHover.d.ts +79 -0
- package/types/src/charts/Plot/sharedHoverScene.d.ts +11 -0
- package/types/src/charts/Plot/sharedTooltip.d.ts +26 -0
- package/types/src/charts/Plot/stackShareLabels.d.ts +21 -0
- package/types/src/charts/Plot/stackShareTooltip.d.ts +9 -0
- package/types/src/charts/Plot/trendLines.d.ts +70 -0
- package/types/src/charts/Plot/trendScene.d.ts +18 -0
- package/types/src/charts/Plot/trendTooltip.d.ts +19 -0
- package/types/src/charts/Rings/applyLayout.d.ts +9 -0
- package/types/src/charts/Rings/ringsSizing.d.ts +49 -0
- package/types/src/charts/StackedArea/index.d.ts +2 -1
- package/types/src/charts/definition/ChartDefinition.d.ts +30 -0
- package/types/src/charts/definition/makeChart.d.ts +2 -1
- package/types/src/charts/drawSteps/bottomRightControls.d.ts +26 -0
- package/types/src/charts/drawSteps/bottomRightControlsMarkup.d.ts +108 -0
- package/types/src/charts/features/emitHelpers.d.ts +8 -0
- package/types/src/charts/features/plotPaint.d.ts +25 -0
- package/types/src/charts/index.d.ts +1 -0
- package/types/src/charts/pipeline/drillMorph.d.ts +29 -0
- package/types/src/charts/pipeline/runVizPipeline.d.ts +8 -0
- package/types/src/charts/viz/Viz.d.ts +18 -1
- package/types/src/charts/viz/VizBase.d.ts +13 -0
- package/types/src/charts/viz/VizBaseConfig.d.ts +5 -1
- package/types/src/charts/viz/vizTypes.d.ts +147 -3
- package/types/src/charts/viz/vizVisibility.d.ts +34 -0
- package/types/src/components/Legend/legendRender.d.ts +8 -2
- package/types/src/components/SizeLegend/SizeLegend.d.ts +107 -0
- package/types/src/components/SizeLegend/sizeLegendLayout.d.ts +101 -0
- package/types/src/components/Tooltip.d.ts +18 -3
- package/types/src/components/index.d.ts +1 -0
- package/types/src/shapes/validateShapeConfig.d.ts +10 -0
- package/types/src/utils/BaseClass.d.ts +15 -1
- package/types/src/utils/D3plusConfig.d.ts +98 -0
- package/types/src/utils/configDefault.d.ts +11 -0
- package/types/src/utils/configWarnings.d.ts +28 -0
- package/types/src/utils/index.d.ts +2 -1
- package/umd/d3plus-core.full.js +7104 -2602
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +2860 -1583
- package/umd/d3plus-core.js +3682 -441
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +1656 -719
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/charts/definition/ChartDefinition.ts"],"sourcesContent":["/**\n `ChartDefinition` — charts as *values*, not classes.\n\n A chart in v4 is the def value `{name, fields?, ctx?, features, stages,\n layoutStage?, emit, chartTransform?, setup?, thresholdFunction?}`. Each\n chart's def lives next to its applyLayout + emit in `./<ChartName>/`;\n `makeChart(def, Base?)` produces the chart class from the def.\n*/\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport type {FeatureModule} from \"../features/features.js\";\nimport type {TransformStage, VizContext} from \"../pipeline/stages.js\";\nimport type {VizInstance} from \"../viz/vizTypes.js\";\n\ninterface ChartDefinitionBase {\n /** Stable name for tagging and class generation. */\n name: string;\n /** Chart-internal scratch seeded onto `viz.ctx.<key>` at construction. */\n ctx?: Record<string, unknown>;\n /**\n Scalar defaults seeded onto `viz._<key>` at construction. Defs that\n need instance slots keep them here; user-facing values otherwise go\n in `fields[].default` and chart-internal scratch in `ctx`.\n */\n defaults?: Record<string, unknown>;\n /** Fluent accessor declarations; `makeChart` installs each as `viz.<key>()`. */\n fields?: import(\"../../fluent.js\").ConfigField[];\n /** Chart-level features composed in; order is layout order. */\n features: FeatureModule[];\n /**\n Chart-specific layout stage run in `_draw` after the shared chart-shell\n prep (`vizPreDrawPure`). If absent, `makeChart` doesn't invoke\n `runChartDraw` — the chart relies on its parent's `_draw` only.\n */\n layoutStage?: TransformStage;\n /** Optional pure threshold algorithm (replaces `Viz._thresholdFunction`). */\n thresholdFunction?: (viz: VizInstance, data: unknown[]) => unknown[];\n /**\n Optional chart-specific `_chartTransform` builder. Receives the viz\n after the layout stage runs; returns the transform applied to the\n chart scene. Default: margin-origin translation.\n */\n chartTransform?: (viz: VizInstance) => import(\"@d3plus/render\").Transform | undefined;\n /**\n Optional fixed clip region for the chart-cells group (a window in absolute\n scene coordinates that the chart content is clipped to). Geomap uses this to\n contain projected geography within the map rectangle so it can't spill under\n the legend/timeline; the clip stays put while pan/zoom moves content beneath\n it. The chart-cells group is untransformed (`chartTransform` applies to a\n group inside it), so the clip is in surface coordinates. Zoomable charts\n without one are clipped to the chart area.\n */\n chartClip?: (viz: VizInstance) => import(\"@d3plus/render\").ClipShape | undefined;\n /**\n Imperative per-instance setup hook — runs once after `applyDefinition`\n seeds the chart. Use for event handler overrides and shadowed methods\n that don't fit the declarative `fields`/`ctx` surface.\n */\n setup?: (viz: VizInstance) => void;\n}\n\n/**\n A data-driven chart's emit: a pure function from a chart context (with\n optional laid-out `shapeData`) to the scene nodes for one frame.\n*/\nexport type ChartEmit = (ctx: VizContext & {shapeData?: DataPoint[]}) => SceneNode[];\n\n/** Data-driven chart: `emit(ctx)` produces the scene nodes. */\nexport interface DataDrivenChartDefinition extends ChartDefinitionBase {\n paintDriven?: false;\n emit: ChartEmit;\n}\n\n/**\n Paint-driven chart: `Plot._paint` populates `viz._chartScene` by calling\n `plotPaint`, which builds the scene from the paint context assembled in\n `drawPlot`. There is no `emit` step — `runChartDraw` refuses to drive\n paint-driven defs (see runChartDraw.ts), so the scene is produced entirely\n inside the Plot draw flow.\n*/\nexport interface PaintDrivenChartDefinition extends ChartDefinitionBase {\n paintDriven: true;\n}\n\n/** Discriminated union; use `isPaintDriven` to narrow. */\nexport type ChartDefinition =\n | DataDrivenChartDefinition\n | PaintDrivenChartDefinition;\n\n/** Type guard for the paint-driven variant. */\nexport function isPaintDriven(\n def: ChartDefinition,\n): def is PaintDrivenChartDefinition {\n return def.paintDriven === true;\n}\n"],"names":["isPaintDriven","def","paintDriven"],"mappings":"AAAA;;;;;;;AAOA,
|
|
1
|
+
{"version":3,"sources":["../../../../src/charts/definition/ChartDefinition.ts"],"sourcesContent":["/**\n `ChartDefinition` — charts as *values*, not classes.\n\n A chart in v4 is the def value `{name, fields?, ctx?, features, stages,\n layoutStage?, emit, chartTransform?, setup?, thresholdFunction?}`. Each\n chart's def lives next to its applyLayout + emit in `./<ChartName>/`;\n `makeChart(def, Base?)` produces the chart class from the def.\n*/\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport type {FeatureModule} from \"../features/features.js\";\nimport type {TransformStage, VizContext} from \"../pipeline/stages.js\";\nimport type {VizInstance} from \"../viz/vizTypes.js\";\nimport type {SizeLegendScale} from \"../../components/SizeLegend/sizeLegendLayout.js\";\n\ninterface ChartDefinitionBase {\n /** Stable name for tagging and class generation. */\n name: string;\n /** Chart-internal scratch seeded onto `viz.ctx.<key>` at construction. */\n ctx?: Record<string, unknown>;\n /**\n Scalar defaults seeded onto `viz._<key>` at construction. Defs that\n need instance slots keep them here; user-facing values otherwise go\n in `fields[].default` and chart-internal scratch in `ctx`.\n */\n defaults?: Record<string, unknown>;\n /** Fluent accessor declarations; `makeChart` installs each as `viz.<key>()`. */\n fields?: import(\"../../fluent.js\").ConfigField[];\n /** Chart-level features composed in; order is layout order. */\n features: FeatureModule[];\n /**\n Chart-specific layout stage run in `_draw` after the shared chart-shell\n prep (`vizPreDrawPure`). If absent, `makeChart` doesn't invoke\n `runChartDraw` — the chart relies on its parent's `_draw` only.\n */\n layoutStage?: TransformStage;\n /**\n Optional size-legend scale, called before layout so the bottom-right\n corner panel can reserve room: the value → pixel-radius scale the chart\n will draw with, for a chart area of `available` px (the area before the\n legend's own reservation, so any area-dependent radius only shrinks\n from here). Return null when nothing is sized. The chart's layout\n stores the scale it actually drew with on `viz._sizeLegendFinal`, which\n is what the legend paints.\n */\n sizeLegendScale?: (\n viz: VizInstance,\n available: {width: number; height: number},\n ) => SizeLegendScale | null;\n /** Optional pure threshold algorithm (replaces `Viz._thresholdFunction`). */\n thresholdFunction?: (viz: VizInstance, data: unknown[]) => unknown[];\n /**\n Optional chart-specific `_chartTransform` builder. Receives the viz\n after the layout stage runs; returns the transform applied to the\n chart scene. Default: margin-origin translation.\n */\n chartTransform?: (viz: VizInstance) => import(\"@d3plus/render\").Transform | undefined;\n /**\n Optional fixed clip region for the chart-cells group (a window in absolute\n scene coordinates that the chart content is clipped to). Geomap uses this to\n contain projected geography within the map rectangle so it can't spill under\n the legend/timeline; the clip stays put while pan/zoom moves content beneath\n it. The chart-cells group is untransformed (`chartTransform` applies to a\n group inside it), so the clip is in surface coordinates. Zoomable charts\n without one are clipped to the chart area.\n */\n chartClip?: (viz: VizInstance) => import(\"@d3plus/render\").ClipShape | undefined;\n /**\n Optional chart-specific \"local body rect\" — the box the drill-down morph\n transition (`enterFrom`/`exitTo`) measures its fractions against. Read\n directly off `def` by `runChartDraw` (same pattern as `chartClip`), after\n the layout stage runs. Default: the margin-adjusted chart area at local\n origin (0,0), i.e. `{x: 0, y: 0, ...chartBounds(viz)}` — correct for any\n chart whose emitted nodes sit inside the `chartTransform`-wrapped body\n group at that same local origin (Treemap; Pack overrides this, since its\n body is a diameter-sized square, not the full chart area).\n */\n chartBodyRect?: (viz: VizInstance) => {x: number; y: number; width: number; height: number};\n /**\n Imperative per-instance setup hook — runs once after `applyDefinition`\n seeds the chart. Use for event handler overrides and shadowed methods\n that don't fit the declarative `fields`/`ctx` surface.\n */\n setup?: (viz: VizInstance) => void;\n}\n\n/**\n A data-driven chart's emit: a pure function from a chart context (with\n optional laid-out `shapeData`) to the scene nodes for one frame.\n*/\nexport type ChartEmit = (ctx: VizContext & {shapeData?: DataPoint[]}) => SceneNode[];\n\n/** Data-driven chart: `emit(ctx)` produces the scene nodes. */\nexport interface DataDrivenChartDefinition extends ChartDefinitionBase {\n paintDriven?: false;\n emit: ChartEmit;\n}\n\n/**\n Paint-driven chart: `Plot._paint` populates `viz._chartScene` by calling\n `plotPaint`, which builds the scene from the paint context assembled in\n `drawPlot`. There is no `emit` step — `runChartDraw` refuses to drive\n paint-driven defs (see runChartDraw.ts), so the scene is produced entirely\n inside the Plot draw flow.\n*/\nexport interface PaintDrivenChartDefinition extends ChartDefinitionBase {\n paintDriven: true;\n}\n\n/** Discriminated union; use `isPaintDriven` to narrow. */\nexport type ChartDefinition =\n | DataDrivenChartDefinition\n | PaintDrivenChartDefinition;\n\n/** Type guard for the paint-driven variant. */\nexport function isPaintDriven(\n def: ChartDefinition,\n): def is PaintDrivenChartDefinition {\n return def.paintDriven === true;\n}\n"],"names":["isPaintDriven","def","paintDriven"],"mappings":"AAAA;;;;;;;AAOA,GA6GA,6CAA6C,GAC7C,OAAO,SAASA,cACdC,GAAoB;IAEpB,OAAOA,IAAIC,WAAW,KAAK;AAC7B"}
|
|
@@ -101,7 +101,8 @@ function _is_native_reflect_construct() {
|
|
|
101
101
|
The class is identical for every chart: its constructor runs
|
|
102
102
|
`applyDefinition(this, def)`, its `_draw` runs the shared Viz pipeline
|
|
103
103
|
then the chart's own layout stage via `runChartDraw`, and its
|
|
104
|
-
`_thresholdFunction`
|
|
104
|
+
`_thresholdFunction` / `_sizeLegendScale` delegate to
|
|
105
|
+
`def.thresholdFunction` / `def.sizeLegendScale` if present.
|
|
105
106
|
|
|
106
107
|
A chart's `index.ts` becomes literally `export default makeChart(def)`.
|
|
107
108
|
*/ import { applyDefinition } from "./applyDefinition.js";
|
|
@@ -135,6 +136,12 @@ import Viz from "../viz/Viz.js";
|
|
|
135
136
|
return this;
|
|
136
137
|
}
|
|
137
138
|
},
|
|
139
|
+
{
|
|
140
|
+
key: "_sizeLegendScale",
|
|
141
|
+
value: function _sizeLegendScale(available) {
|
|
142
|
+
return def.sizeLegendScale ? def.sizeLegendScale(this, available) : _get(_get_prototype_of(Chart.prototype), "_sizeLegendScale", this).call(this, available);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
138
145
|
{
|
|
139
146
|
key: "_thresholdFunction",
|
|
140
147
|
value: function _thresholdFunction(data) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/charts/definition/makeChart.ts"],"sourcesContent":["/**\n `makeChart(def)` — produce a Viz-extending chart class from a\n ChartDefinition value.\n\n The class is identical for every chart: its constructor runs\n `applyDefinition(this, def)`, its `_draw` runs the shared Viz pipeline\n then the chart's own layout stage via `runChartDraw`, and its\n `_thresholdFunction`
|
|
1
|
+
{"version":3,"sources":["../../../../src/charts/definition/makeChart.ts"],"sourcesContent":["/**\n `makeChart(def)` — produce a Viz-extending chart class from a\n ChartDefinition value.\n\n The class is identical for every chart: its constructor runs\n `applyDefinition(this, def)`, its `_draw` runs the shared Viz pipeline\n then the chart's own layout stage via `runChartDraw`, and its\n `_thresholdFunction` / `_sizeLegendScale` delegate to\n `def.thresholdFunction` / `def.sizeLegendScale` if present.\n\n A chart's `index.ts` becomes literally `export default makeChart(def)`.\n*/\n\nimport {applyDefinition} from \"./applyDefinition.js\";\nimport {runChartDraw} from \"../pipeline/runChartDraw.js\";\nimport Viz from \"../viz/Viz.js\";\nimport type {ChartDefinition} from \"./ChartDefinition.js\";\nimport type {VizInstance} from \"../viz/vizTypes.js\";\n\n// The generated chart class extends a runtime-chosen base and overrides\n// `_draw`/`_thresholdFunction` with looser signatures, which a concrete\n// `new () => VizInstance` constructor type can't express; `any` is the factory\n// escape hatch (call sites still get the real `Viz` API via the class itself).\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyViz = any;\ntype VizCtor = new () => AnyViz;\n\n/**\n `makeChart(def, Base?)` — produce a chart class from a def value.\n\n `Base` defaults to `Viz`; pass an existing chart class to inherit a\n specialization (e.g. `makeChart(donutDef, Pie)` for Donut).\n*/\nexport function makeChart(def: ChartDefinition, Base: VizCtor = Viz): VizCtor {\n class Chart extends (Base as VizCtor) {\n constructor() {\n super();\n applyDefinition(this as unknown as VizInstance, def);\n }\n\n _draw(callback?: () => void) {\n (super._draw as (...args: unknown[]) => unknown)(callback);\n if (def.layoutStage) {\n runChartDraw(this as unknown as VizInstance, def, def.layoutStage, def.chartTransform);\n }\n return this;\n }\n\n _sizeLegendScale(available: {width: number; height: number}) {\n return def.sizeLegendScale\n ? def.sizeLegendScale(this as unknown as VizInstance, available)\n : super._sizeLegendScale(available);\n }\n\n _thresholdFunction(data: unknown[]) {\n return def.thresholdFunction\n ? def.thresholdFunction(this as unknown as VizInstance, data)\n : data;\n }\n }\n Object.defineProperty(Chart, \"name\", {value: def.name});\n return Chart;\n}\n"],"names":["applyDefinition","runChartDraw","Viz","makeChart","def","Base","Chart","_draw","callback","layoutStage","chartTransform","_sizeLegendScale","available","sizeLegendScale","_thresholdFunction","data","thresholdFunction","Object","defineProperty","value","name"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;AAWA,GAEA,SAAQA,eAAe,QAAO,uBAAuB;AACrD,SAAQC,YAAY,QAAO,8BAA8B;AACzD,OAAOC,SAAS,gBAAgB;AAYhC;;;;;AAKA,GACA,OAAO,SAASC,UAAUC,GAAoB;QAAEC,OAAAA,iEAAgBH;IAC9D,IAAA,AAAMI,sBAAN;;kBAAMA;iBAAAA;oCAAAA;;oBAEF,kBAFEA;YAGFN,uBAAgDI;;;sBAH9CE;;gBAMJC,KAAAA;uBAAAA,SAAAA,MAAMC,QAAqB;oBACxB,uBAPCF,kBAOKC,SAAN,IAAK,aAA2CC;oBACjD,IAAIJ,IAAIK,WAAW,EAAE;wBACnBR,aAAa,IAAI,EAA4BG,KAAKA,IAAIK,WAAW,EAAEL,IAAIM,cAAc;oBACvF;oBACA,OAAO,IAAI;gBACb;;;gBAEAC,KAAAA;uBAAAA,SAAAA,iBAAiBC,SAA0C;oBACzD,OAAOR,IAAIS,eAAe,GACtBT,IAAIS,eAAe,CAAC,IAAI,EAA4BD,aACpD,uBAjBFN,kBAiBQK,oBAAN,IAAK,aAAkBC;gBAC7B;;;gBAEAE,KAAAA;uBAAAA,SAAAA,mBAAmBC,IAAe;oBAChC,OAAOX,IAAIY,iBAAiB,GACxBZ,IAAIY,iBAAiB,CAAC,IAAI,EAA4BD,QACtDA;gBACN;;;eAxBIT;MAAeD;IA0BrBY,OAAOC,cAAc,CAACZ,OAAO,QAAQ;QAACa,OAAOf,IAAIgB,IAAI;IAAA;IACrD,OAAOd;AACT"}
|
|
@@ -34,8 +34,23 @@ import { backControlStyleDefault } from "../viz/vizDefaults.js";
|
|
|
34
34
|
// A left-pointing arrow: a horizontal shaft + an open chevron head.
|
|
35
35
|
var BACK_ICON = "<svg ".concat(ICON_ATTRS, '><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>');
|
|
36
36
|
/** Pops the drill-down history (or steps up a level, when there's no history entry left) and re-renders. */ function goBack(viz) {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
var entry = viz._history.pop();
|
|
38
|
+
if (entry) {
|
|
39
|
+
// Arms the reappearing parent's reunion lookup (resolveDrillMorph), so
|
|
40
|
+
// the vanishing children shrink into its rect instead of just fading —
|
|
41
|
+
// the mirror of clickShape's forward capture. `body` is the CURRENT
|
|
42
|
+
// (about-to-be-OLD) body rect, captured now because the exiting
|
|
43
|
+
// siblings' own geometry is frozen in THIS frame, not the new one
|
|
44
|
+
// .render() is about to produce.
|
|
45
|
+
if (entry.groupId !== undefined && entry.groupDepth !== undefined) viz._pendingExitReunion = {
|
|
46
|
+
groupId: entry.groupId,
|
|
47
|
+
groupDepth: entry.groupDepth,
|
|
48
|
+
body: viz._bodyRect
|
|
49
|
+
};
|
|
50
|
+
viz.config(entry).render();
|
|
51
|
+
} else {
|
|
52
|
+
viz.depth(viz._drawDepth - 1).filter(false).render();
|
|
53
|
+
}
|
|
39
54
|
}
|
|
40
55
|
/** The back button's markup: a real `<button>` (icon + visible "Back" text), so host-page button styling applies through the cascade once `backControlClassName` auto-disables the inline default. */ export function backControlsHtml(viz) {
|
|
41
56
|
var extraClass = viz.schema.backControlClassName ? " ".concat(viz.schema.backControlClassName) : "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/charts/drawSteps/backControl.ts"],"sourcesContent":["/**\n The \"← Back\" control's contribution to the shared top-left controls\n panel (`topLeftControls.ts`) — visible only when the chart has\n drill-down history to pop. Styled like the zoom/search controls: a real\n `<button>` at the same 20px height, an SVG arrow icon (not a text\n glyph), and no default background/border/color — a plain\n browser-appearance button that lets native/host-page button chrome\n show through, restylable via `.backControlStyle()`/\n `.backControlClassName()` the same way zoom/search are.\n\n Previously `backFeature` rendered \"← Back\" as an SVG text scene node in\n its own margin-claiming row, with its click routed through\n `Viz._routeSceneEvent`'s `interactionGroup === \"back\"` special case —\n the only way to attach a click handler to a plain scene text node. As a\n real button inside the shared `htmlOverlay` panel, its click instead\n rides the same declarative delegated-events map every other top-left/\n zoom control uses, and it claims no margin of its own — like zoom, it\n floats over whatever's there, and content that needs to avoid it insets\n around the whole panel via `topLeftControlsInset`.\n\n @module\n*/\nimport type Viz from \"../viz/Viz.js\";\nimport type {Contribution} from \"./topLeftControlsMarkup.js\";\nimport {ICON_ATTRS} from \"./zoomControlsMarkup.js\";\nimport {paintControlButton, resolveControlStyle} from \"./controlButtonStyle.js\";\nimport {backControlStyleDefault} from \"../viz/vizDefaults.js\";\n\n/** The resolved base button style — also used as the cheap, non-DOM basis for `backContribution`'s `styleSignature` (see `Contribution.styleSignature`). */\nfunction resolvedBackButtonStyle(viz: Viz) {\n const className = Boolean(viz.schema.backControlClassName);\n return resolveControlStyle(viz.schema.backControlStyle, backControlStyleDefault, className);\n}\n\n/** Paints the back button's inline style. There's no active/hover override — unlike zoom/search it's not a toggle, so it relies on the browser's native `:hover`, like their own hover default (`false`) already does. */\nexport function paintBackButton(viz: Viz, btn: HTMLElement): void {\n paintControlButton(btn, {base: resolvedBackButtonStyle(viz)}, false, false);\n}\n\n// A left-pointing arrow: a horizontal shaft + an open chevron head.\nconst BACK_ICON = `<svg ${ICON_ATTRS}><line x1=\"19\" y1=\"12\" x2=\"5\" y2=\"12\"/><polyline points=\"12 19 5 12 12 5\"/></svg>`;\n\n/** Pops the drill-down history (or steps up a level, when there's no history entry left) and re-renders. */\nfunction goBack(viz: Viz): void {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/charts/drawSteps/backControl.ts"],"sourcesContent":["/**\n The \"← Back\" control's contribution to the shared top-left controls\n panel (`topLeftControls.ts`) — visible only when the chart has\n drill-down history to pop. Styled like the zoom/search controls: a real\n `<button>` at the same 20px height, an SVG arrow icon (not a text\n glyph), and no default background/border/color — a plain\n browser-appearance button that lets native/host-page button chrome\n show through, restylable via `.backControlStyle()`/\n `.backControlClassName()` the same way zoom/search are.\n\n Previously `backFeature` rendered \"← Back\" as an SVG text scene node in\n its own margin-claiming row, with its click routed through\n `Viz._routeSceneEvent`'s `interactionGroup === \"back\"` special case —\n the only way to attach a click handler to a plain scene text node. As a\n real button inside the shared `htmlOverlay` panel, its click instead\n rides the same declarative delegated-events map every other top-left/\n zoom control uses, and it claims no margin of its own — like zoom, it\n floats over whatever's there, and content that needs to avoid it insets\n around the whole panel via `topLeftControlsInset`.\n\n @module\n*/\nimport type Viz from \"../viz/Viz.js\";\nimport type {Contribution} from \"./topLeftControlsMarkup.js\";\nimport {ICON_ATTRS} from \"./zoomControlsMarkup.js\";\nimport {paintControlButton, resolveControlStyle} from \"./controlButtonStyle.js\";\nimport {backControlStyleDefault} from \"../viz/vizDefaults.js\";\n\n/** The resolved base button style — also used as the cheap, non-DOM basis for `backContribution`'s `styleSignature` (see `Contribution.styleSignature`). */\nfunction resolvedBackButtonStyle(viz: Viz) {\n const className = Boolean(viz.schema.backControlClassName);\n return resolveControlStyle(viz.schema.backControlStyle, backControlStyleDefault, className);\n}\n\n/** Paints the back button's inline style. There's no active/hover override — unlike zoom/search it's not a toggle, so it relies on the browser's native `:hover`, like their own hover default (`false`) already does. */\nexport function paintBackButton(viz: Viz, btn: HTMLElement): void {\n paintControlButton(btn, {base: resolvedBackButtonStyle(viz)}, false, false);\n}\n\n// A left-pointing arrow: a horizontal shaft + an open chevron head.\nconst BACK_ICON = `<svg ${ICON_ATTRS}><line x1=\"19\" y1=\"12\" x2=\"5\" y2=\"12\"/><polyline points=\"12 19 5 12 12 5\"/></svg>`;\n\n/** Pops the drill-down history (or steps up a level, when there's no history entry left) and re-renders. */\nfunction goBack(viz: Viz): void {\n const entry = viz._history.pop();\n if (entry) {\n // Arms the reappearing parent's reunion lookup (resolveDrillMorph), so\n // the vanishing children shrink into its rect instead of just fading —\n // the mirror of clickShape's forward capture. `body` is the CURRENT\n // (about-to-be-OLD) body rect, captured now because the exiting\n // siblings' own geometry is frozen in THIS frame, not the new one\n // .render() is about to produce.\n if (entry.groupId !== undefined && entry.groupDepth !== undefined)\n viz._pendingExitReunion = {groupId: entry.groupId, groupDepth: entry.groupDepth, body: viz._bodyRect};\n viz.config(entry).render();\n } else {\n viz.depth(viz._drawDepth - 1).filter(false).render();\n }\n}\n\n/** The back button's markup: a real `<button>` (icon + visible \"Back\" text), so host-page button styling applies through the cascade once `backControlClassName` auto-disables the inline default. */\nexport function backControlsHtml(viz: Viz): string {\n const extraClass = viz.schema.backControlClassName ? ` ${viz.schema.backControlClassName}` : \"\";\n const label = viz.schema.translate(\"Back\");\n return `<button type=\"button\" class=\"back-control${extraClass}\">${BACK_ICON}${label}</button>`;\n}\n\n/** Whether a chart shows the back button — history to pop, and not under SSR (mirrors `showsZoomControls`/`showsSearchControls`: a static export has no interaction to route a click to). */\nfunction showsBackControl(viz: Viz): boolean {\n return Boolean(viz._history && viz._history.length) && !viz._ssr;\n}\n\nexport function backContribution(viz: Viz): Contribution | null {\n if (!showsBackControl(viz)) return null;\n return {\n key: \"back\",\n html: backControlsHtml(viz),\n styleSignature: JSON.stringify(resolvedBackButtonStyle(viz)),\n events: {\n \".back-control\": {click: () => goBack(viz)},\n },\n onUpdate: (host: HTMLElement) => {\n const btn = host.querySelector<HTMLElement>(\".back-control\");\n if (!btn || btn.dataset.backBound) return;\n btn.dataset.backBound = \"1\";\n paintBackButton(viz, btn);\n },\n };\n}\n"],"names":["ICON_ATTRS","paintControlButton","resolveControlStyle","backControlStyleDefault","resolvedBackButtonStyle","viz","className","Boolean","schema","backControlClassName","backControlStyle","paintBackButton","btn","base","BACK_ICON","goBack","entry","_history","pop","groupId","undefined","groupDepth","_pendingExitReunion","body","_bodyRect","config","render","depth","_drawDepth","filter","backControlsHtml","extraClass","label","translate","showsBackControl","length","_ssr","backContribution","key","html","styleSignature","JSON","stringify","events","click","onUpdate","host","querySelector","dataset","backBound"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;AAqBA,GAGA,SAAQA,UAAU,QAAO,0BAA0B;AACnD,SAAQC,kBAAkB,EAAEC,mBAAmB,QAAO,0BAA0B;AAChF,SAAQC,uBAAuB,QAAO,wBAAwB;AAE9D,0JAA0J,GAC1J,SAASC,wBAAwBC,GAAQ;IACvC,IAAMC,YAAYC,QAAQF,IAAIG,MAAM,CAACC,oBAAoB;IACzD,OAAOP,oBAAoBG,IAAIG,MAAM,CAACE,gBAAgB,EAAEP,yBAAyBG;AACnF;AAEA,wNAAwN,GACxN,OAAO,SAASK,gBAAgBN,GAAQ,EAAEO,GAAgB;IACxDX,mBAAmBW,KAAK;QAACC,MAAMT,wBAAwBC;IAAI,GAAG,OAAO;AACvE;AAEA,oEAAoE;AACpE,IAAMS,YAAY,AAAC,QAAkB,OAAXd,YAAW;AAErC,0GAA0G,GAC1G,SAASe,OAAOV,GAAQ;IACtB,IAAMW,QAAQX,IAAIY,QAAQ,CAACC,GAAG;IAC9B,IAAIF,OAAO;QACT,uEAAuE;QACvE,uEAAuE;QACvE,oEAAoE;QACpE,gEAAgE;QAChE,kEAAkE;QAClE,iCAAiC;QACjC,IAAIA,MAAMG,OAAO,KAAKC,aAAaJ,MAAMK,UAAU,KAAKD,WACtDf,IAAIiB,mBAAmB,GAAG;YAACH,SAASH,MAAMG,OAAO;YAAEE,YAAYL,MAAMK,UAAU;YAAEE,MAAMlB,IAAImB,SAAS;QAAA;QACtGnB,IAAIoB,MAAM,CAACT,OAAOU,MAAM;IAC1B,OAAO;QACLrB,IAAIsB,KAAK,CAACtB,IAAIuB,UAAU,GAAG,GAAGC,MAAM,CAAC,OAAOH,MAAM;IACpD;AACF;AAEA,oMAAoM,GACpM,OAAO,SAASI,iBAAiBzB,GAAQ;IACvC,IAAM0B,aAAa1B,IAAIG,MAAM,CAACC,oBAAoB,GAAG,AAAC,IAAmC,OAAhCJ,IAAIG,MAAM,CAACC,oBAAoB,IAAK;IAC7F,IAAMuB,QAAQ3B,IAAIG,MAAM,CAACyB,SAAS,CAAC;IACnC,OAAO,AAAC,4CAA0DnB,OAAfiB,YAAW,MAAgBC,OAAZlB,WAAkB,OAANkB,OAAM;AACtF;AAEA,2LAA2L,GAC3L,SAASE,iBAAiB7B,GAAQ;IAChC,OAAOE,QAAQF,IAAIY,QAAQ,IAAIZ,IAAIY,QAAQ,CAACkB,MAAM,KAAK,CAAC9B,IAAI+B,IAAI;AAClE;AAEA,OAAO,SAASC,iBAAiBhC,GAAQ;IACvC,IAAI,CAAC6B,iBAAiB7B,MAAM,OAAO;IACnC,OAAO;QACLiC,KAAK;QACLC,MAAMT,iBAAiBzB;QACvBmC,gBAAgBC,KAAKC,SAAS,CAACtC,wBAAwBC;QACvDsC,QAAQ;YACN,iBAAiB;gBAACC,OAAO,SAAPA;2BAAa7B,OAAOV;;YAAI;QAC5C;QACAwC,UAAU,SAAVA,SAAWC;YACT,IAAMlC,MAAMkC,KAAKC,aAAa,CAAc;YAC5C,IAAI,CAACnC,OAAOA,IAAIoC,OAAO,CAACC,SAAS,EAAE;YACnCrC,IAAIoC,OAAO,CAACC,SAAS,GAAG;YACxBtC,gBAAgBN,KAAKO;QACvB;IACF;AACF"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _object_spread(target) {
|
|
15
|
+
for(var i = 1; i < arguments.length; i++){
|
|
16
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
17
|
+
var ownKeys = Object.keys(source);
|
|
18
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
19
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
ownKeys.forEach(function(key) {
|
|
24
|
+
_define_property(target, key, source[key]);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
29
|
+
function ownKeys(object, enumerableOnly) {
|
|
30
|
+
var keys = Object.keys(object);
|
|
31
|
+
if (Object.getOwnPropertySymbols) {
|
|
32
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
33
|
+
if (enumerableOnly) {
|
|
34
|
+
symbols = symbols.filter(function(sym) {
|
|
35
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
keys.push.apply(keys, symbols);
|
|
39
|
+
}
|
|
40
|
+
return keys;
|
|
41
|
+
}
|
|
42
|
+
function _object_spread_props(target, source) {
|
|
43
|
+
source = source != null ? source : {};
|
|
44
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
45
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
46
|
+
} else {
|
|
47
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
48
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
@name bottomRightControlsFeature
|
|
55
|
+
The bottom-right corner panel: chart chrome anchored in the corner below
|
|
56
|
+
the chart body, currently the size legend. Like the top-left panel it's
|
|
57
|
+
fed by independent contributor functions — a new corner item appends
|
|
58
|
+
its own to `BOTTOM_RIGHT_CONTRIBUTORS`.
|
|
59
|
+
|
|
60
|
+
Two steps, split around the chart's layout:
|
|
61
|
+
1. `reserveBottomRight` (called from `vizDrawPure`, before the legend
|
|
62
|
+
and colorScale lay out) measures every contribution from a
|
|
63
|
+
pre-layout estimate and stores the box on `viz._bottomRightBox`, so
|
|
64
|
+
bottom-band content insets around it and the chart body stays
|
|
65
|
+
clear of it.
|
|
66
|
+
2. `bottomRightControlsFeature` (post-draw, see `runVizPipeline`)
|
|
67
|
+
paints each contribution from its final, laid-out state into the
|
|
68
|
+
reserved box.
|
|
69
|
+
|
|
70
|
+
@module
|
|
71
|
+
*/ import { colorContrast } from "@d3plus/color";
|
|
72
|
+
import { backgroundColor } from "@d3plus/dom";
|
|
73
|
+
import { resolveSpec } from "../pipeline/resolveSpec.js";
|
|
74
|
+
import { zoomSizeLegendScale } from "../../components/SizeLegend/sizeLegendLayout.js";
|
|
75
|
+
import { buildBottomRightPanel, bottomRightControlsBox, measureBottomRight } from "./bottomRightControlsMarkup.js";
|
|
76
|
+
/** The text/stroke color that reads against the chart's background. */ function inkColor(viz) {
|
|
77
|
+
var node = viz._select && typeof viz._select.node === "function" ? viz._select.node() : null;
|
|
78
|
+
var bg = node ? backgroundColor(node) : "rgb(255, 255, 255)";
|
|
79
|
+
return colorContrast(bg, viz.schema.colorDefaults);
|
|
80
|
+
}
|
|
81
|
+
/** Configures the size legend for a scale and lays it out, returning its size. */ function layoutSizeLegend(viz, scale) {
|
|
82
|
+
var ink = inkColor(viz);
|
|
83
|
+
var legend = viz._sizeLegendClass;
|
|
84
|
+
legend.renderMode("compute").locale(viz.schema.locale).title(viz._sizeKey).labelConfig({
|
|
85
|
+
fontColor: ink,
|
|
86
|
+
fontFamily: viz.schema.fontFamily
|
|
87
|
+
}).titleConfig({
|
|
88
|
+
fontColor: ink,
|
|
89
|
+
fontFamily: viz.schema.fontFamily
|
|
90
|
+
}).lineConfig({
|
|
91
|
+
stroke: ink
|
|
92
|
+
}).shapeConfig({
|
|
93
|
+
fill: ink,
|
|
94
|
+
stroke: ink
|
|
95
|
+
}).config(viz.schema.sizeLegendConfig).scale(scale);
|
|
96
|
+
var _legend_layout = legend.layout(), width = _legend_layout.width, height = _legend_layout.height;
|
|
97
|
+
return {
|
|
98
|
+
width: width,
|
|
99
|
+
height: height
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
The size legend's contribution: sized from the chart's pre-layout scale
|
|
104
|
+
estimate, painted from the scale the chart's layout actually drew with.
|
|
105
|
+
*/ export function sizeLegendContribution(viz, available) {
|
|
106
|
+
if (!viz._sizeLegendClass || typeof viz._sizeLegendScale !== "function") return null;
|
|
107
|
+
var scale = viz._sizeLegendScale(available);
|
|
108
|
+
if (!scale) return null;
|
|
109
|
+
viz._sizeLegendClass._maxRadius = undefined;
|
|
110
|
+
var _layoutSizeLegend = layoutSizeLegend(viz, scale), width = _layoutSizeLegend.width, height = _layoutSizeLegend.height;
|
|
111
|
+
if (!width || !height) return null;
|
|
112
|
+
var size = {
|
|
113
|
+
width: width,
|
|
114
|
+
height: height,
|
|
115
|
+
availableWidth: available.width,
|
|
116
|
+
availableHeight: available.height
|
|
117
|
+
};
|
|
118
|
+
if (!viz.schema.sizeLegend.bind(viz)(resolveSpec(viz), scale, size)) return null;
|
|
119
|
+
return {
|
|
120
|
+
key: "sizeLegend",
|
|
121
|
+
width: width,
|
|
122
|
+
height: height,
|
|
123
|
+
paint: function paint(zoom) {
|
|
124
|
+
var final = viz._sizeLegendFinal;
|
|
125
|
+
if (!final) return null;
|
|
126
|
+
viz._sizeLegendClass._maxRadius = zoom === 1 ? undefined : final(final.domain()[1]);
|
|
127
|
+
var size = layoutSizeLegend(viz, zoomSizeLegendScale(final, zoom));
|
|
128
|
+
if (!size.width || !size.height) return null;
|
|
129
|
+
return _object_spread({
|
|
130
|
+
node: viz._sizeLegendClass.toScene()
|
|
131
|
+
}, size);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
Ordered contributors to the bottom-right panel, right to left.
|
|
137
|
+
*/ export var BOTTOM_RIGHT_CONTRIBUTORS = [
|
|
138
|
+
sizeLegendContribution
|
|
139
|
+
];
|
|
140
|
+
/**
|
|
141
|
+
Measures the panel for this draw and stores it on `viz._bottomRightBox`
|
|
142
|
+
(null when nothing contributes). `bottom` is how far above the chart's
|
|
143
|
+
bottom edge the panel sits (below it: the timeline); `available` is the
|
|
144
|
+
chart area left after the claims made so far. `sizeLegendPosition`
|
|
145
|
+
picks the margin it claims (see `BottomRightBox.side`).
|
|
146
|
+
*/ export function reserveBottomRight(viz, bottom, available) {
|
|
147
|
+
var items = [];
|
|
148
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
149
|
+
try {
|
|
150
|
+
for(var _iterator = BOTTOM_RIGHT_CONTRIBUTORS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
151
|
+
var fn = _step.value;
|
|
152
|
+
var c = fn(viz, available);
|
|
153
|
+
if (c) items.push(c);
|
|
154
|
+
}
|
|
155
|
+
} catch (err) {
|
|
156
|
+
_didIteratorError = true;
|
|
157
|
+
_iteratorError = err;
|
|
158
|
+
} finally{
|
|
159
|
+
try {
|
|
160
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
161
|
+
_iterator.return();
|
|
162
|
+
}
|
|
163
|
+
} finally{
|
|
164
|
+
if (_didIteratorError) {
|
|
165
|
+
throw _iteratorError;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
var side = viz.schema.sizeLegendPosition === "bottom" ? "bottom" : "right";
|
|
170
|
+
viz._bottomRightBox = items.length ? _object_spread_props(_object_spread({}, measureBottomRight(items)), {
|
|
171
|
+
bottom: bottom,
|
|
172
|
+
side: side,
|
|
173
|
+
items: items
|
|
174
|
+
}) : null;
|
|
175
|
+
}
|
|
176
|
+
export var bottomRightControlsFeature = {
|
|
177
|
+
name: "bottomRightControls",
|
|
178
|
+
configFields: [
|
|
179
|
+
"sizeLegend",
|
|
180
|
+
"sizeLegendConfig",
|
|
181
|
+
"sizeLegendPosition"
|
|
182
|
+
],
|
|
183
|
+
layout: function layout(param) {
|
|
184
|
+
var viz = param.viz;
|
|
185
|
+
var box = bottomRightControlsBox(viz);
|
|
186
|
+
return {
|
|
187
|
+
panel: box ? buildBottomRightPanel(viz, box) : null,
|
|
188
|
+
margin: {}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
//# sourceMappingURL=bottomRightControls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/charts/drawSteps/bottomRightControls.ts"],"sourcesContent":["/**\n @name bottomRightControlsFeature\n The bottom-right corner panel: chart chrome anchored in the corner below\n the chart body, currently the size legend. Like the top-left panel it's\n fed by independent contributor functions — a new corner item appends\n its own to `BOTTOM_RIGHT_CONTRIBUTORS`.\n\n Two steps, split around the chart's layout:\n 1. `reserveBottomRight` (called from `vizDrawPure`, before the legend\n and colorScale lay out) measures every contribution from a\n pre-layout estimate and stores the box on `viz._bottomRightBox`, so\n bottom-band content insets around it and the chart body stays\n clear of it.\n 2. `bottomRightControlsFeature` (post-draw, see `runVizPipeline`)\n paints each contribution from its final, laid-out state into the\n reserved box.\n\n @module\n*/\nimport {colorContrast} from \"@d3plus/color\";\nimport {backgroundColor} from \"@d3plus/dom\";\n\nimport type {FeatureModule} from \"../features/features.js\";\nimport {resolveSpec} from \"../pipeline/resolveSpec.js\";\nimport type {VizInstance} from \"../viz/vizTypes.js\";\nimport {zoomSizeLegendScale} from \"../../components/SizeLegend/sizeLegendLayout.js\";\nimport type {SizeLegendScale} from \"../../components/SizeLegend/sizeLegendLayout.js\";\nimport {buildBottomRightPanel, bottomRightControlsBox, measureBottomRight} from \"./bottomRightControlsMarkup.js\";\nimport type {BottomRightContribution} from \"./bottomRightControlsMarkup.js\";\n\n/** The chart area a contribution may size itself against, before layout. */\nexport interface BottomRightAvailable {\n width: number;\n height: number;\n}\n\n/** The text/stroke color that reads against the chart's background. */\nfunction inkColor(viz: VizInstance): string {\n const node = viz._select && typeof viz._select.node === \"function\" ? viz._select.node() : null;\n const bg = node ? backgroundColor(node) : \"rgb(255, 255, 255)\";\n return colorContrast(bg, viz.schema.colorDefaults);\n}\n\n/** Configures the size legend for a scale and lays it out, returning its size. */\nfunction layoutSizeLegend(viz: VizInstance, scale: SizeLegendScale): {width: number; height: number} {\n const ink = inkColor(viz);\n const legend = viz._sizeLegendClass!;\n legend\n .renderMode(\"compute\")\n .locale(viz.schema.locale)\n .title(viz._sizeKey)\n .labelConfig({fontColor: ink, fontFamily: viz.schema.fontFamily})\n .titleConfig({fontColor: ink, fontFamily: viz.schema.fontFamily})\n .lineConfig({stroke: ink})\n .shapeConfig({fill: ink, stroke: ink})\n .config(viz.schema.sizeLegendConfig)\n .scale(scale);\n const {width, height} = legend.layout();\n return {width, height};\n}\n\n/**\n The size legend's contribution: sized from the chart's pre-layout scale\n estimate, painted from the scale the chart's layout actually drew with.\n*/\nexport function sizeLegendContribution(\n viz: VizInstance,\n available: BottomRightAvailable,\n): BottomRightContribution | null {\n if (!viz._sizeLegendClass || typeof viz._sizeLegendScale !== \"function\") return null;\n const scale = viz._sizeLegendScale(available);\n if (!scale) return null;\n viz._sizeLegendClass._maxRadius = undefined;\n const {width, height} = layoutSizeLegend(viz, scale);\n if (!width || !height) return null;\n const size = {width, height, availableWidth: available.width, availableHeight: available.height};\n if (!viz.schema.sizeLegend.bind(viz)(resolveSpec(viz), scale, size)) return null;\n return {\n key: \"sizeLegend\",\n width,\n height,\n paint: zoom => {\n const final = viz._sizeLegendFinal;\n if (!final) return null;\n viz._sizeLegendClass!._maxRadius = zoom === 1 ? undefined : final(final.domain()[1]);\n const size = layoutSizeLegend(viz, zoomSizeLegendScale(final, zoom));\n if (!size.width || !size.height) return null;\n return {node: viz._sizeLegendClass!.toScene(), ...size};\n },\n };\n}\n\n/**\n Ordered contributors to the bottom-right panel, right to left.\n*/\nexport const BOTTOM_RIGHT_CONTRIBUTORS: Array<\n (viz: VizInstance, available: BottomRightAvailable) => BottomRightContribution | null\n> = [sizeLegendContribution];\n\n/**\n Measures the panel for this draw and stores it on `viz._bottomRightBox`\n (null when nothing contributes). `bottom` is how far above the chart's\n bottom edge the panel sits (below it: the timeline); `available` is the\n chart area left after the claims made so far. `sizeLegendPosition`\n picks the margin it claims (see `BottomRightBox.side`).\n*/\nexport function reserveBottomRight(\n viz: VizInstance,\n bottom: number,\n available: BottomRightAvailable,\n): void {\n const items: BottomRightContribution[] = [];\n for (const fn of BOTTOM_RIGHT_CONTRIBUTORS) {\n const c = fn(viz, available);\n if (c) items.push(c);\n }\n const side = viz.schema.sizeLegendPosition === \"bottom\" ? \"bottom\" : \"right\";\n viz._bottomRightBox = items.length ? {...measureBottomRight(items), bottom, side, items} : null;\n}\n\nexport const bottomRightControlsFeature: FeatureModule = {\n name: \"bottomRightControls\",\n configFields: [\"sizeLegend\", \"sizeLegendConfig\", \"sizeLegendPosition\"],\n layout: ({viz}) => {\n const box = bottomRightControlsBox(viz);\n return {panel: box ? buildBottomRightPanel(viz, box) : null, margin: {}};\n },\n};\n"],"names":["colorContrast","backgroundColor","resolveSpec","zoomSizeLegendScale","buildBottomRightPanel","bottomRightControlsBox","measureBottomRight","inkColor","viz","node","_select","bg","schema","colorDefaults","layoutSizeLegend","scale","ink","legend","_sizeLegendClass","renderMode","locale","title","_sizeKey","labelConfig","fontColor","fontFamily","titleConfig","lineConfig","stroke","shapeConfig","fill","config","sizeLegendConfig","layout","width","height","sizeLegendContribution","available","_sizeLegendScale","_maxRadius","undefined","size","availableWidth","availableHeight","sizeLegend","bind","key","paint","zoom","final","_sizeLegendFinal","domain","toScene","BOTTOM_RIGHT_CONTRIBUTORS","reserveBottomRight","bottom","items","fn","c","push","side","sizeLegendPosition","_bottomRightBox","length","bottomRightControlsFeature","name","configFields","box","panel","margin"],"mappings":"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"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Layout for the bottom-right corner panel — the bottom-corner counterpart
|
|
3
|
+
of the top-right zoom-control panel. Its items (the size legend, today)
|
|
4
|
+
are scene nodes rather than HTML, so the panel exports with the chart.
|
|
5
|
+
|
|
6
|
+
The panel is measured before the chart lays out (`reserveBottomRight`,
|
|
7
|
+
called from `vizDrawPure`), and the result is stored on
|
|
8
|
+
`viz._bottomRightBox` so content sharing the bottom band (a bottom
|
|
9
|
+
legend or colorScale) can inset around it via `bottomRightControlsInset`,
|
|
10
|
+
and content in the right column can stop short of it via
|
|
11
|
+
`bottomRightControlsDrop`. It paints after the chart lays out
|
|
12
|
+
(`bottomRightControlsFeature`), from each item's final state.
|
|
13
|
+
|
|
14
|
+
Kept separate from `bottomRightControls.ts` (the `FeatureModule` + the
|
|
15
|
+
contributor list) so the legend/colorScale features can import the inset
|
|
16
|
+
helpers without depending on the contributors.
|
|
17
|
+
|
|
18
|
+
@module
|
|
19
|
+
*/ function _array_like_to_array(arr, len) {
|
|
20
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
21
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
22
|
+
return arr2;
|
|
23
|
+
}
|
|
24
|
+
function _array_without_holes(arr) {
|
|
25
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
26
|
+
}
|
|
27
|
+
function _iterable_to_array(iter) {
|
|
28
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
29
|
+
}
|
|
30
|
+
function _non_iterable_spread() {
|
|
31
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
32
|
+
}
|
|
33
|
+
function _to_consumable_array(arr) {
|
|
34
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
35
|
+
}
|
|
36
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
37
|
+
if (!o) return;
|
|
38
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
39
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
40
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
41
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
42
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
43
|
+
}
|
|
44
|
+
/** Horizontal gap between items, and between the panel and content inset around it. */ export var BOTTOM_RIGHT_GAP = 6;
|
|
45
|
+
/** Lays contributions out in a row, right to left: the panel's total width and height. */ export function measureBottomRight(items) {
|
|
46
|
+
var _Math;
|
|
47
|
+
var width = items.reduce(function(w, item, i) {
|
|
48
|
+
return w + item.width + (i ? BOTTOM_RIGHT_GAP : 0);
|
|
49
|
+
}, 0);
|
|
50
|
+
var height = (_Math = Math).max.apply(_Math, [
|
|
51
|
+
0
|
|
52
|
+
].concat(_to_consumable_array(items.map(function(item) {
|
|
53
|
+
return item.height;
|
|
54
|
+
}))));
|
|
55
|
+
return {
|
|
56
|
+
width: width,
|
|
57
|
+
height: height
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** The panel reserved for this draw, or null when nothing is showing there. */ export function bottomRightControlsBox(viz) {
|
|
61
|
+
var box = viz._bottomRightBox;
|
|
62
|
+
return box && box.width && box.height ? box : null;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
How far content in the bottom band must pull in its right edge to clear
|
|
66
|
+
the panel: content whose bottom edge sits `bottom` px above the chart's
|
|
67
|
+
bottom edge and whose right edge sits `right` px in from the chart's
|
|
68
|
+
right edge. Zero when nothing is showing or the content starts above the
|
|
69
|
+
panel.
|
|
70
|
+
*/ export function bottomRightControlsInset(viz, bottom, right) {
|
|
71
|
+
var box = bottomRightControlsBox(viz);
|
|
72
|
+
// A right-side panel already widened the right margin bottom content lays out against.
|
|
73
|
+
if (!box || box.side === "right" || bottom >= box.bottom + box.height) return 0;
|
|
74
|
+
var inset = box.width - right;
|
|
75
|
+
return inset > 0 ? inset + BOTTOM_RIGHT_GAP : 0;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
How much content in the right column, whose bottom edge sits `bottom` px
|
|
79
|
+
above the chart's bottom edge, must shorten to end above the panel. Zero
|
|
80
|
+
when nothing is showing.
|
|
81
|
+
*/ export function bottomRightControlsDrop(viz, bottom) {
|
|
82
|
+
var box = bottomRightControlsBox(viz);
|
|
83
|
+
if (!box) return 0;
|
|
84
|
+
return Math.max(0, box.bottom + box.height - bottom);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
How a legend or colorScale at `position` clears the panel: a bottom one
|
|
88
|
+
pulls its right edge in by `inset`, a left/right one shortens by `drop`.
|
|
89
|
+
`bottom`/`right` are its edges' distances from the chart's bottom/right.
|
|
90
|
+
*/ export function bottomRightClearance(viz, position, bottom, right) {
|
|
91
|
+
return {
|
|
92
|
+
inset: position === "bottom" ? bottomRightControlsInset(viz, bottom, right) : 0,
|
|
93
|
+
drop: position === "left" || position === "right" ? bottomRightControlsDrop(viz, bottom) : 0
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
How much taller the bottom margin must grow so the chart body, ending
|
|
98
|
+
`bottom` px above the chart's bottom edge, stays clear of a bottom-side
|
|
99
|
+
panel. Zero for a right-side panel.
|
|
100
|
+
*/ export function bottomRightControlsShortfall(viz, bottom) {
|
|
101
|
+
var box = bottomRightControlsBox(viz);
|
|
102
|
+
return box && box.side === "bottom" ? Math.max(0, box.bottom + box.height - bottom) : 0;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
How much wider the right margin must grow so the chart body, ending
|
|
106
|
+
`right` px in from the chart's right edge, stays clear of a right-side
|
|
107
|
+
panel. Zero for a bottom-side panel.
|
|
108
|
+
*/ export function bottomRightControlsRightShortfall(viz, right) {
|
|
109
|
+
var box = bottomRightControlsBox(viz);
|
|
110
|
+
return box && box.side === "right" ? Math.max(0, box.width + BOTTOM_RIGHT_GAP - right) : 0;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
The panel's scene: each item painted from its final state, bottom-right
|
|
114
|
+
aligned in the slot it reserved. Null when nothing paints.
|
|
115
|
+
*/ export function buildBottomRightPanel(viz, box) {
|
|
116
|
+
var _ref;
|
|
117
|
+
var _viz__zoomTransform;
|
|
118
|
+
var zoom = (_ref = (_viz__zoomTransform = viz._zoomTransform) === null || _viz__zoomTransform === void 0 ? void 0 : _viz__zoomTransform.scale) !== null && _ref !== void 0 ? _ref : 1;
|
|
119
|
+
var children = [];
|
|
120
|
+
var right = viz.schema.width;
|
|
121
|
+
var baseline = viz.schema.height - box.bottom;
|
|
122
|
+
box.items.forEach(function(item) {
|
|
123
|
+
var painted = item.paint(zoom);
|
|
124
|
+
if (painted) {
|
|
125
|
+
children.push({
|
|
126
|
+
type: "group",
|
|
127
|
+
key: item.key,
|
|
128
|
+
transform: {
|
|
129
|
+
x: right - painted.width,
|
|
130
|
+
y: baseline - painted.height
|
|
131
|
+
},
|
|
132
|
+
children: [
|
|
133
|
+
painted.node
|
|
134
|
+
]
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
right -= item.width + BOTTOM_RIGHT_GAP;
|
|
138
|
+
});
|
|
139
|
+
if (!children.length) return null;
|
|
140
|
+
return {
|
|
141
|
+
type: "group",
|
|
142
|
+
key: "viz-bottomRight",
|
|
143
|
+
children: children
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
Repaints the panel in place for the current zoom — called on every zoom
|
|
148
|
+
event, which repaints the scene without re-running the pipeline.
|
|
149
|
+
*/ export function refreshBottomRightPanel(viz) {
|
|
150
|
+
var box = bottomRightControlsBox(viz);
|
|
151
|
+
if (!box || !viz._featurePanels) return;
|
|
152
|
+
var panels = viz._featurePanels.filter(function(p) {
|
|
153
|
+
return p.key !== "viz-bottomRight";
|
|
154
|
+
});
|
|
155
|
+
var panel = buildBottomRightPanel(viz, box);
|
|
156
|
+
viz._featurePanels = panel ? _to_consumable_array(panels).concat([
|
|
157
|
+
panel
|
|
158
|
+
]) : panels;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
//# sourceMappingURL=bottomRightControlsMarkup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/charts/drawSteps/bottomRightControlsMarkup.ts"],"sourcesContent":["/**\n Layout for the bottom-right corner panel — the bottom-corner counterpart\n of the top-right zoom-control panel. Its items (the size legend, today)\n are scene nodes rather than HTML, so the panel exports with the chart.\n\n The panel is measured before the chart lays out (`reserveBottomRight`,\n called from `vizDrawPure`), and the result is stored on\n `viz._bottomRightBox` so content sharing the bottom band (a bottom\n legend or colorScale) can inset around it via `bottomRightControlsInset`,\n and content in the right column can stop short of it via\n `bottomRightControlsDrop`. It paints after the chart lays out\n (`bottomRightControlsFeature`), from each item's final state.\n\n Kept separate from `bottomRightControls.ts` (the `FeatureModule` + the\n contributor list) so the legend/colorScale features can import the inset\n helpers without depending on the contributors.\n\n @module\n*/\n\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport type {VizInstance} from \"../viz/vizTypes.js\";\n\n/**\n One item's contribution to the bottom-right panel: its size as reserved\n before layout, and a `paint` that builds its scene after layout (its\n top-left at the origin) along with the size it actually drew at, which\n must not exceed the reservation. `zoom` is the scale the chart's picture\n is currently zoomed by (1 unzoomed; charts that zoom by rescaling axes,\n like Plot, always paint at 1).\n*/\nexport interface BottomRightContribution {\n key: string;\n width: number;\n height: number;\n paint: (zoom: number) => {node: SceneNode; width: number; height: number} | null;\n}\n\n/** The measured panel, as stored on `viz._bottomRightBox`. */\nexport interface BottomRightBox {\n width: number;\n height: number;\n /** Offset of the panel's bottom edge from the chart's bottom edge (the timeline sits below it). */\n bottom: number;\n /**\n The margin the panel claims: `\"right\"` widens the right margin so the\n chart body ends left of it (it shares the right column, below any\n right legend/colorScale); `\"bottom\"` deepens the bottom margin so the\n body ends above it (bottom legends/colorScales sit beside it).\n */\n side: \"right\" | \"bottom\";\n items: BottomRightContribution[];\n}\n\n/** Horizontal gap between items, and between the panel and content inset around it. */\nexport const BOTTOM_RIGHT_GAP = 6;\n\n/** Lays contributions out in a row, right to left: the panel's total width and height. */\nexport function measureBottomRight(items: BottomRightContribution[]): {width: number; height: number} {\n const width = items.reduce((w, item, i) => w + item.width + (i ? BOTTOM_RIGHT_GAP : 0), 0);\n const height = Math.max(0, ...items.map(item => item.height));\n return {width, height};\n}\n\n/** The panel reserved for this draw, or null when nothing is showing there. */\nexport function bottomRightControlsBox(viz: VizInstance): BottomRightBox | null {\n const box = viz._bottomRightBox;\n return box && box.width && box.height ? box : null;\n}\n\n/**\n How far content in the bottom band must pull in its right edge to clear\n the panel: content whose bottom edge sits `bottom` px above the chart's\n bottom edge and whose right edge sits `right` px in from the chart's\n right edge. Zero when nothing is showing or the content starts above the\n panel.\n*/\nexport function bottomRightControlsInset(viz: VizInstance, bottom: number, right: number): number {\n const box = bottomRightControlsBox(viz);\n // A right-side panel already widened the right margin bottom content lays out against.\n if (!box || box.side === \"right\" || bottom >= box.bottom + box.height) return 0;\n const inset = box.width - right;\n return inset > 0 ? inset + BOTTOM_RIGHT_GAP : 0;\n}\n\n/**\n How much content in the right column, whose bottom edge sits `bottom` px\n above the chart's bottom edge, must shorten to end above the panel. Zero\n when nothing is showing.\n*/\nexport function bottomRightControlsDrop(viz: VizInstance, bottom: number): number {\n const box = bottomRightControlsBox(viz);\n if (!box) return 0;\n return Math.max(0, box.bottom + box.height - bottom);\n}\n\n/**\n How a legend or colorScale at `position` clears the panel: a bottom one\n pulls its right edge in by `inset`, a left/right one shortens by `drop`.\n `bottom`/`right` are its edges' distances from the chart's bottom/right.\n*/\nexport function bottomRightClearance(\n viz: VizInstance,\n position: string | false,\n bottom: number,\n right: number,\n): {inset: number; drop: number} {\n return {\n inset: position === \"bottom\" ? bottomRightControlsInset(viz, bottom, right) : 0,\n drop: position === \"left\" || position === \"right\" ? bottomRightControlsDrop(viz, bottom) : 0,\n };\n}\n\n/**\n How much taller the bottom margin must grow so the chart body, ending\n `bottom` px above the chart's bottom edge, stays clear of a bottom-side\n panel. Zero for a right-side panel.\n*/\nexport function bottomRightControlsShortfall(viz: VizInstance, bottom: number): number {\n const box = bottomRightControlsBox(viz);\n return box && box.side === \"bottom\" ? Math.max(0, box.bottom + box.height - bottom) : 0;\n}\n\n/**\n How much wider the right margin must grow so the chart body, ending\n `right` px in from the chart's right edge, stays clear of a right-side\n panel. Zero for a bottom-side panel.\n*/\nexport function bottomRightControlsRightShortfall(viz: VizInstance, right: number): number {\n const box = bottomRightControlsBox(viz);\n return box && box.side === \"right\" ? Math.max(0, box.width + BOTTOM_RIGHT_GAP - right) : 0;\n}\n\n/**\n The panel's scene: each item painted from its final state, bottom-right\n aligned in the slot it reserved. Null when nothing paints.\n*/\nexport function buildBottomRightPanel(viz: VizInstance, box: BottomRightBox): SceneNode | null {\n const zoom = viz._zoomTransform?.scale ?? 1;\n const children: SceneNode[] = [];\n let right = viz.schema.width;\n const baseline = viz.schema.height - box.bottom;\n box.items.forEach(item => {\n const painted = item.paint(zoom);\n if (painted) {\n children.push({\n type: \"group\",\n key: item.key,\n transform: {x: right - painted.width, y: baseline - painted.height},\n children: [painted.node],\n });\n }\n right -= item.width + BOTTOM_RIGHT_GAP;\n });\n if (!children.length) return null;\n return {type: \"group\", key: \"viz-bottomRight\", children};\n}\n\n/**\n Repaints the panel in place for the current zoom — called on every zoom\n event, which repaints the scene without re-running the pipeline.\n*/\nexport function refreshBottomRightPanel(viz: VizInstance): void {\n const box = bottomRightControlsBox(viz);\n if (!box || !viz._featurePanels) return;\n const panels = viz._featurePanels.filter(p => p.key !== \"viz-bottomRight\");\n const panel = buildBottomRightPanel(viz, box);\n viz._featurePanels = panel ? [...panels, panel] : panels;\n}\n"],"names":["BOTTOM_RIGHT_GAP","measureBottomRight","items","Math","width","reduce","w","item","i","height","max","map","bottomRightControlsBox","viz","box","_bottomRightBox","bottomRightControlsInset","bottom","right","side","inset","bottomRightControlsDrop","bottomRightClearance","position","drop","bottomRightControlsShortfall","bottomRightControlsRightShortfall","buildBottomRightPanel","zoom","_zoomTransform","scale","children","schema","baseline","forEach","painted","paint","push","type","key","transform","x","y","node","length","refreshBottomRightPanel","_featurePanels","panels","filter","p","panel"],"mappings":"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"}
|
|
@@ -62,6 +62,24 @@ import { showsZoomControls, zoomControlsBox } from "./zoomControlsMarkup.js";
|
|
|
62
62
|
var node = (_zoomTarget = zoomTarget(viz)) === null || _zoomTarget === void 0 ? void 0 : _zoomTarget.node();
|
|
63
63
|
return node ? zoomTransform(node) : zoomIdentity;
|
|
64
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
Which screen dimensions the zoom actually scales. Every chart zooms its
|
|
67
|
+
picture uniformly, except a Plot, which rescales only its linear axes —
|
|
68
|
+
a bar chart with a discrete x axis zooms vertically alone, so the
|
|
69
|
+
viewport box keeps the minimap's full width.
|
|
70
|
+
@private
|
|
71
|
+
*/ function zoomedDims(viz) {
|
|
72
|
+
var _viz__plotZoomBase;
|
|
73
|
+
var scales = (_viz__plotZoomBase = viz._plotZoomBase) === null || _viz__plotZoomBase === void 0 ? void 0 : _viz__plotZoomBase.scales;
|
|
74
|
+
if (!scales) return {
|
|
75
|
+
x: true,
|
|
76
|
+
y: true
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
x: Boolean(scales.x || scales.x2),
|
|
80
|
+
y: Boolean(scales.y || scales.y2)
|
|
81
|
+
};
|
|
82
|
+
}
|
|
65
83
|
/** A keyboard nudge step, in minimap pixels — Shift takes a bigger step. */ var KEY_STEP = 10;
|
|
66
84
|
var KEY_STEP_SHIFT = 40;
|
|
67
85
|
var ARROW_KEYS = {
|
|
@@ -84,7 +102,10 @@ var ARROW_KEYS = {
|
|
|
84
102
|
};
|
|
85
103
|
/** Re-centers the chart, at scale `k`, on a content-space point — the shared math behind click-to-jump and wheel-zoom. @private */ function centerOn(viz, px, py, k, duration) {
|
|
86
104
|
var _viz__zoomBehavior_translateExtent = _sliced_to_array(viz._zoomBehavior.translateExtent(), 2), _viz__zoomBehavior_translateExtent_ = _sliced_to_array(_viz__zoomBehavior_translateExtent[0], 2), ax0 = _viz__zoomBehavior_translateExtent_[0], ay0 = _viz__zoomBehavior_translateExtent_[1], _viz__zoomBehavior_translateExtent_1 = _sliced_to_array(_viz__zoomBehavior_translateExtent[1], 2), ax1 = _viz__zoomBehavior_translateExtent_1[0], ay1 = _viz__zoomBehavior_translateExtent_1[1];
|
|
87
|
-
|
|
105
|
+
var dims = zoomedDims(viz), t = liveTransform(viz);
|
|
106
|
+
var x = dims.x ? (ax0 + ax1) / 2 - px * k : t.x;
|
|
107
|
+
var y = dims.y ? (ay0 + ay1) / 2 - py * k : t.y;
|
|
108
|
+
zoomTo(viz, k, x, y, duration);
|
|
88
109
|
}
|
|
89
110
|
/** Maps a pointer position local to the minimap's outer box into content-space. @private */ function contentPointFromLocal(viz, mmW, mmH, localX, localY) {
|
|
90
111
|
var _viz__zoomBehavior_translateExtent = _sliced_to_array(viz._zoomBehavior.translateExtent(), 2), _viz__zoomBehavior_translateExtent_ = _sliced_to_array(_viz__zoomBehavior_translateExtent[0], 2), ax0 = _viz__zoomBehavior_translateExtent_[0], ay0 = _viz__zoomBehavior_translateExtent_[1], _viz__zoomBehavior_translateExtent_1 = _sliced_to_array(_viz__zoomBehavior_translateExtent[1], 2), ax1 = _viz__zoomBehavior_translateExtent_1[0], ay1 = _viz__zoomBehavior_translateExtent_1[1];
|
|
@@ -132,11 +153,13 @@ var ARROW_KEYS = {
|
|
|
132
153
|
var _viz__zoomBehavior_translateExtent = _sliced_to_array(viz._zoomBehavior.translateExtent(), 2), _viz__zoomBehavior_translateExtent_ = _sliced_to_array(_viz__zoomBehavior_translateExtent[0], 2), ax0 = _viz__zoomBehavior_translateExtent_[0], ay0 = _viz__zoomBehavior_translateExtent_[1], _viz__zoomBehavior_translateExtent_1 = _sliced_to_array(_viz__zoomBehavior_translateExtent[1], 2), ax1 = _viz__zoomBehavior_translateExtent_1[0], ay1 = _viz__zoomBehavior_translateExtent_1[1];
|
|
133
154
|
var areaW = ax1 - ax0, areaH = ay1 - ay0;
|
|
134
155
|
var frac = Math.min(1, 1 / t.k);
|
|
156
|
+
var dims = zoomedDims(viz);
|
|
157
|
+
var fracW = dims.x ? frac : 1, fracH = dims.y ? frac : 1;
|
|
135
158
|
// Un-apply the current transform — the same algebra `zoomToBounds`
|
|
136
159
|
// uses to go from displayed bounds back to unzoomed surface space.
|
|
137
160
|
var contentX0 = (ax0 - t.x) / t.k, contentY0 = (ay0 - t.y) / t.k;
|
|
138
|
-
var fracX = Math.max(0, Math.min(1 -
|
|
139
|
-
var fracY = Math.max(0, Math.min(1 -
|
|
161
|
+
var fracX = Math.max(0, Math.min(1 - fracW, areaW ? (contentX0 - ax0) / areaW : 0));
|
|
162
|
+
var fracY = Math.max(0, Math.min(1 - fracH, areaH ? (contentY0 - ay0) / areaH : 0));
|
|
140
163
|
paintMinimapStyle(viewportEl, styles.viewport, state.dragging ? styles.viewportActive : {});
|
|
141
164
|
paintMinimapStyle(viewportEl, {
|
|
142
165
|
position: "absolute",
|
|
@@ -144,8 +167,8 @@ var ARROW_KEYS = {
|
|
|
144
167
|
"touch-action": "none",
|
|
145
168
|
left: "".concat(fracX * mmW, "px"),
|
|
146
169
|
top: "".concat(fracY * mmH, "px"),
|
|
147
|
-
width: "".concat(Math.max(1,
|
|
148
|
-
height: "".concat(Math.max(1,
|
|
170
|
+
width: "".concat(Math.max(1, fracW * mmW), "px"),
|
|
171
|
+
height: "".concat(Math.max(1, fracH * mmH), "px")
|
|
149
172
|
});
|
|
150
173
|
paintMinimapStyle(labelEl, styles.label);
|
|
151
174
|
paintMinimapStyle(labelEl, {
|
|
@@ -201,8 +224,9 @@ var ARROW_KEYS = {
|
|
|
201
224
|
if (!state.dragging || pe.pointerId !== state.dragPointerId) return;
|
|
202
225
|
var _viz__zoomBehavior_translateExtent = _sliced_to_array(viz._zoomBehavior.translateExtent(), 2), _viz__zoomBehavior_translateExtent_ = _sliced_to_array(_viz__zoomBehavior_translateExtent[0], 1), ax0 = _viz__zoomBehavior_translateExtent_[0], _viz__zoomBehavior_translateExtent_1 = _sliced_to_array(_viz__zoomBehavior_translateExtent[1], 1), ax1 = _viz__zoomBehavior_translateExtent_1[0];
|
|
203
226
|
var scaleFactor = (ax1 - ax0) / mmW;
|
|
204
|
-
var
|
|
205
|
-
var
|
|
227
|
+
var dims = zoomedDims(viz);
|
|
228
|
+
var dx = dims.x ? (pe.clientX - state.dragStart.x) * scaleFactor * state.dragStart.k : 0;
|
|
229
|
+
var dy = dims.y ? (pe.clientY - state.dragStart.y) * scaleFactor * state.dragStart.k : 0;
|
|
206
230
|
// duration 0 — 1:1 responsiveness, matching every other per-pixel
|
|
207
231
|
// pan/zoom tick (`zoomed()`'s own reasoning: a queued transition
|
|
208
232
|
// per pointermove would visibly lag).
|
|
@@ -222,8 +246,9 @@ var ARROW_KEYS = {
|
|
|
222
246
|
var scaleFactor = (ax1 - ax0) / mmW;
|
|
223
247
|
var step = ke.shiftKey ? KEY_STEP_SHIFT : KEY_STEP;
|
|
224
248
|
var t = liveTransform(viz);
|
|
225
|
-
var
|
|
226
|
-
var
|
|
249
|
+
var dims = zoomedDims(viz);
|
|
250
|
+
var dx = dims.x ? dir[0] * step * scaleFactor * t.k : 0;
|
|
251
|
+
var dy = dims.y ? dir[1] * step * scaleFactor * t.k : 0;
|
|
227
252
|
// A discrete step, not a per-pixel drag tick — animates like the
|
|
228
253
|
// zoom buttons' own clicks rather than jumping instantly.
|
|
229
254
|
zoomTo(viz, t.k, t.x - dx, t.y - dy, viz.schema.duration);
|