@d3plus/core 4.5.0 → 4.7.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 +3930 -2032
- package/es/index.js +3 -3
- package/es/index.js.map +1 -1
- package/es/internal.js +11 -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 +17 -0
- package/es/src/charts/Chord/index.js.map +1 -1
- package/es/src/charts/Geomap/applyLayout.js +20 -11
- package/es/src/charts/Geomap/applyLayout.js.map +1 -1
- package/es/src/charts/Geomap/index.js +8 -2
- 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/Matrix/emit.js +5 -4
- package/es/src/charts/Matrix/emit.js.map +1 -1
- 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 +10 -1
- package/es/src/charts/Network/index.js.map +1 -1
- package/es/src/charts/Pack/emit.js +42 -7
- package/es/src/charts/Pack/emit.js.map +1 -1
- package/es/src/charts/Pack/index.js +15 -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 +275 -35
- package/es/src/charts/Pie/emit.js.map +1 -1
- package/es/src/charts/Pie/index.js +48 -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 +143 -14
- package/es/src/charts/Plot/index.js.map +1 -1
- package/es/src/charts/Plot/insetRegion.js +21 -0
- package/es/src/charts/Plot/insetRegion.js.map +1 -0
- 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 +532 -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 +183 -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 +469 -0
- package/es/src/charts/Plot/trendLines.js.map +1 -0
- package/es/src/charts/Plot/trendProjection.js +120 -0
- package/es/src/charts/Plot/trendProjection.js.map +1 -0
- package/es/src/charts/Plot/trendScene.js +234 -0
- package/es/src/charts/Plot/trendScene.js.map +1 -0
- package/es/src/charts/Plot/trendTooltip.js +222 -0
- package/es/src/charts/Plot/trendTooltip.js.map +1 -0
- package/es/src/charts/Priestley/emit.js +34 -6
- 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/emit.js +4 -4
- package/es/src/charts/RadialMatrix/emit.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 +18 -3
- 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/Sankey/index.js +2 -0
- package/es/src/charts/Sankey/index.js.map +1 -1
- 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 +7 -3
- package/es/src/charts/Tree/index.js.map +1 -1
- package/es/src/charts/Treemap/emit.js +58 -6
- 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 +14 -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 +196 -0
- package/es/src/charts/drawSteps/bottomRightControls.js.map +1 -0
- package/es/src/charts/drawSteps/bottomRightControlsMarkup.js +292 -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/searchControlsMarkup.js +15 -38
- package/es/src/charts/drawSteps/searchControlsMarkup.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.legend.js +10 -5
- package/es/src/charts/events/click.legend.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 +10 -1
- 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 +43 -5
- package/es/src/charts/features/emitHelpers.js.map +1 -1
- package/es/src/charts/features/features.js +3 -104
- package/es/src/charts/features/features.js.map +1 -1
- package/es/src/charts/features/featuresColorScale.js +161 -0
- package/es/src/charts/features/featuresColorScale.js.map +1 -0
- package/es/src/charts/features/featuresLegend.js +155 -34
- package/es/src/charts/features/featuresLegend.js.map +1 -1
- package/es/src/charts/features/insetState.js +174 -0
- package/es/src/charts/features/insetState.js.map +1 -0
- package/es/src/charts/features/plotPaint.js +51 -24
- package/es/src/charts/features/plotPaint.js.map +1 -1
- package/es/src/charts/features/sceneBounds.js +271 -0
- package/es/src/charts/features/sceneBounds.js.map +1 -0
- package/es/src/charts/features/shapeEmit.js +20 -2
- package/es/src/charts/features/shapeEmit.js.map +1 -1
- package/es/src/charts/features/tooltipSwatch.js +73 -0
- package/es/src/charts/features/tooltipSwatch.js.map +1 -0
- 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/insetPlacement.js +406 -0
- package/es/src/charts/pipeline/insetPlacement.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 +22 -3
- 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 +82 -11
- 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 +25 -21
- package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
- package/es/src/charts/viz/interactionOpacity.js +21 -13
- package/es/src/charts/viz/interactionOpacity.js.map +1 -1
- package/es/src/charts/viz/linkGroup.js +386 -0
- package/es/src/charts/viz/linkGroup.js.map +1 -0
- package/es/src/charts/viz/ordinalColor.js +2 -2
- package/es/src/charts/viz/ordinalColor.js.map +1 -1
- package/es/src/charts/viz/sceneRows.js +33 -0
- package/es/src/charts/viz/sceneRows.js.map +1 -0
- package/es/src/charts/viz/vizDefaults.js +39 -15
- 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/Axis/AxisBottom.js +1 -1
- package/es/src/components/Axis/AxisBottom.js.map +1 -1
- package/es/src/components/Axis/AxisLeft.js +1 -1
- package/es/src/components/Axis/AxisLeft.js.map +1 -1
- package/es/src/components/Axis/AxisRight.js +1 -1
- package/es/src/components/Axis/AxisRight.js.map +1 -1
- package/es/src/components/Axis/AxisTop.js +1 -1
- package/es/src/components/Axis/AxisTop.js.map +1 -1
- package/es/src/components/Axis/axisLayoutLabels.js +13 -1
- package/es/src/components/Axis/axisLayoutLabels.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 +3 -2
- package/es/src/components/Legend/legendConfig.js.map +1 -1
- package/es/src/components/Legend/legendRender.js +70 -26
- 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/TextBox.js +1 -1
- package/es/src/components/TextBox.js.map +1 -1
- 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/Bar.js +1 -1
- package/es/src/shapes/Bar.js.map +1 -1
- package/es/src/shapes/Box.js +5 -3
- package/es/src/shapes/Box.js.map +1 -1
- package/es/src/shapes/Rect.js +1 -1
- package/es/src/shapes/Rect.js.map +1 -1
- package/es/src/shapes/Shape.js +10 -37
- package/es/src/shapes/Shape.js.map +1 -1
- package/es/src/shapes/Whisker.js +4 -3
- package/es/src/shapes/Whisker.js.map +1 -1
- package/es/src/shapes/textureKey.js +104 -0
- package/es/src/shapes/textureKey.js.map +1 -0
- 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 +12 -10
- package/types/index.d.ts +5 -4
- package/types/internal.d.ts +15 -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 +47 -0
- package/types/src/charts/Plot/insetRegion.d.ts +4 -0
- package/types/src/charts/Plot/pipeline.d.ts +14 -0
- package/types/src/charts/Plot/sharedHover.d.ts +84 -0
- package/types/src/charts/Plot/sharedHoverScene.d.ts +11 -0
- package/types/src/charts/Plot/sharedTooltip.d.ts +36 -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 +90 -0
- package/types/src/charts/Plot/trendProjection.d.ts +28 -0
- package/types/src/charts/Plot/trendScene.d.ts +19 -0
- package/types/src/charts/Plot/trendTooltip.d.ts +30 -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 +39 -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 +110 -0
- package/types/src/charts/drawSteps/searchControlsMarkup.d.ts +7 -5
- package/types/src/charts/features/emitHelpers.d.ts +18 -4
- package/types/src/charts/features/features.d.ts +1 -8
- package/types/src/charts/features/featuresColorScale.d.ts +24 -0
- package/types/src/charts/features/featuresLegend.d.ts +15 -0
- package/types/src/charts/features/insetState.d.ts +95 -0
- package/types/src/charts/features/plotPaint.d.ts +25 -0
- package/types/src/charts/features/sceneBounds.d.ts +18 -0
- package/types/src/charts/features/tooltipSwatch.d.ts +31 -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/insetPlacement.d.ts +45 -0
- package/types/src/charts/pipeline/runVizPipeline.d.ts +10 -1
- package/types/src/charts/viz/Viz.d.ts +27 -2
- package/types/src/charts/viz/VizBase.d.ts +13 -0
- package/types/src/charts/viz/VizBaseConfig.d.ts +11 -11
- package/types/src/charts/viz/linkGroup.d.ts +96 -0
- package/types/src/charts/viz/sceneRows.d.ts +13 -0
- package/types/src/charts/viz/vizTypes.d.ts +164 -3
- package/types/src/charts/viz/vizVisibility.d.ts +34 -0
- package/types/src/components/Axis/AxisBottom.d.ts +1 -1
- package/types/src/components/Axis/AxisLeft.d.ts +1 -1
- package/types/src/components/Axis/AxisRight.d.ts +1 -1
- package/types/src/components/Axis/AxisTop.d.ts +1 -1
- package/types/src/components/ColorScale/ColorScale.d.ts +4 -4
- package/types/src/components/Legend/legendRender.d.ts +9 -3
- package/types/src/components/SizeLegend/SizeLegend.d.ts +107 -0
- package/types/src/components/SizeLegend/sizeLegendLayout.d.ts +101 -0
- package/types/src/components/TextBox.d.ts +1 -1
- package/types/src/components/Tooltip.d.ts +18 -3
- package/types/src/components/index.d.ts +1 -0
- package/types/src/shapes/Bar.d.ts +1 -1
- package/types/src/shapes/Box.d.ts +1 -1
- package/types/src/shapes/Rect.d.ts +1 -1
- package/types/src/shapes/Whisker.d.ts +1 -1
- package/types/src/shapes/textureKey.d.ts +9 -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 +139 -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 +9325 -3024
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +3348 -1727
- package/umd/d3plus-core.js +5412 -831
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +2199 -948
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/charts/Treemap/emit.ts"],"sourcesContent":["/**\n `treemapEmit` — scene nodes for a laid-out Treemap: one rect per cell\n plus the title + share-% text labels for each cell, both as flat data.\n*/\n\nimport {colorContrast} from \"@d3plus/color\";\nimport {formatAbbreviate} from \"@d3plus/format\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport constant from \"../../utils/constant.js\";\nimport {emitLabels} from \"../../shapes/emitLabels.js\";\nimport type {ChartEmit} from \"../definition/ChartDefinition.js\";\nimport type {TreemapShapeNode} from \"./applyLayout.js\";\n\nfunction resolveAccessor<T>(\n val: unknown,\n d: DataPoint,\n i: number | undefined,\n): T | undefined {\n if (typeof val === \"function\") {\n return (val as (d: DataPoint, i: number | undefined) => T)(d, i);\n }\n return val as T | undefined;\n}\n\nexport const treemapEmit: ChartEmit = ({viz, shapeData}) => {\n const nodes = (shapeData ?? []) as TreemapShapeNode[];\n if (!nodes.length) return [];\n\n const locale = viz.schema.locale;\n const drawLabel = viz._drawLabel;\n const sc = (viz
|
|
1
|
+
{"version":3,"sources":["../../../../src/charts/Treemap/emit.ts"],"sourcesContent":["/**\n `treemapEmit` — scene nodes for a laid-out Treemap: one rect per cell\n plus the title + share-% text labels for each cell, both as flat data.\n*/\n\nimport {colorContrast} from \"@d3plus/color\";\nimport {formatAbbreviate} from \"@d3plus/format\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport constant from \"../../utils/constant.js\";\nimport {emitLabels} from \"../../shapes/emitLabels.js\";\nimport {userLabelConfig, textureFill, shapeConfigFor} from \"../features/emitHelpers.js\";\nimport type {ChartEmit} from \"../definition/ChartDefinition.js\";\nimport type {TreemapShapeNode} from \"./applyLayout.js\";\n\nfunction resolveAccessor<T>(\n val: unknown,\n d: DataPoint,\n i: number | undefined,\n): T | undefined {\n if (typeof val === \"function\") {\n return (val as (d: DataPoint, i: number | undefined) => T)(d, i);\n }\n return val as T | undefined;\n}\n\nexport const treemapEmit: ChartEmit = ({viz, shapeData}) => {\n const nodes = (shapeData ?? []) as TreemapShapeNode[];\n if (!nodes.length) return [];\n\n const locale = viz.schema.locale;\n const drawLabel = viz._drawLabel;\n const sc = shapeConfigFor(viz, \"Rect\");\n\n const rectNodes: SceneNode[] = nodes.map(d => {\n const fill = resolveAccessor<string>(sc.fill, d.data, d.i);\n const stroke = resolveAccessor<string | undefined>(sc.stroke, d.data, d.i);\n const opacity = resolveAccessor<number>(sc.opacity, d.data, d.i);\n const strokeWidth = resolveAccessor<number>(sc.strokeWidth, d.data, d.i);\n return {\n type: \"rect\",\n key: `treemap-${d.id}`,\n x: d.x0,\n y: d.y0,\n width: d.x1 - d.x0,\n height: d.y1 - d.y0,\n datum: d.data,\n paint: {\n fill: textureFill(sc, d.data, d.i, fill),\n stroke:\n typeof stroke === \"string\" || stroke == null\n ? stroke\n : String(stroke),\n opacity,\n strokeWidth,\n },\n aria: {\n label: `${drawLabel(d.data, d.i ?? 0)}, ${(viz.schema.sum as (d: DataPoint) => number)(d.data)}, ${formatAbbreviate(d.share * 100, locale)}%`,\n },\n } as SceneNode;\n });\n\n const labelNodes = emitLabels({\n data: nodes as unknown as DataPoint[],\n label: d => {\n const node = d as unknown as TreemapShapeNode;\n return [\n drawLabel(node.data, node.i ?? 0),\n `${formatAbbreviate(node.share * 100, locale)}%`,\n ];\n },\n x: d => {\n const node = d as unknown as TreemapShapeNode;\n return node.x0 + (node.x1 - node.x0) / 2;\n },\n y: d => {\n const node = d as unknown as TreemapShapeNode;\n return node.y0 + (node.y1 - node.y0) / 2;\n },\n aes: d => {\n const node = d as unknown as TreemapShapeNode;\n return {width: node.x1 - node.x0, height: node.y1 - node.y0};\n },\n rotate: constant(0),\n id: d => (d as unknown as TreemapShapeNode).id,\n labelBounds: (_d, _i, aes) => {\n const fontMax = 32;\n const fontMin = 8;\n const padding = 5;\n const {width: w, height: h} = aes as {width: number; height: number};\n let sh = Math.min(fontMax, (h - padding * 2) * 0.5);\n if (sh < fontMin) sh = 0;\n return [\n {width: w, height: h - sh, x: -w / 2, y: -h / 2},\n {width: w, height: sh + padding * 2, x: -w / 2, y: h / 2 - sh - padding * 2},\n ];\n },\n labelConfig: {\n fontMax: 32,\n textAnchor: (d: DataPoint & {l?: number}) =>\n d && d.l === 0 ? \"start\" : \"middle\",\n verticalAlign: (d: DataPoint & {l?: number}) =>\n d && d.l === 0 ? \"top\" : \"bottom\",\n fontColor: (d: DataPoint & {data?: DataPoint; i?: number}) => {\n const src = (d && d.data ? d.data : d) as DataPoint & {i?: number};\n const fillVal = resolveAccessor<string>(sc.fill, src, src.i);\n return typeof fillVal === \"string\" ? colorContrast(fillVal, viz.schema.colorDefaults) : undefined;\n },\n ...userLabelConfig(viz, \"Rect\"),\n },\n });\n\n // Marks each label as eligible for the drill-down morph (isFlipEligible),\n // so it moves along with its cell instead of just fading in in place —\n // distinct from every other text a chart emits (title/subtitle/legend),\n // which is never stamped this way and so never flip-morphs.\n for (const n of labelNodes) (n as {shapeType?: string}).shapeType = \"Label\";\n\n return [...rectNodes, ...labelNodes];\n};\n"],"names":["colorContrast","formatAbbreviate","constant","emitLabels","userLabelConfig","textureFill","shapeConfigFor","resolveAccessor","val","d","i","treemapEmit","viz","shapeData","nodes","length","locale","schema","drawLabel","_drawLabel","sc","rectNodes","map","fill","data","stroke","opacity","strokeWidth","type","key","id","x","x0","y","y0","width","x1","height","y1","datum","paint","String","aria","label","sum","share","labelNodes","node","aes","rotate","labelBounds","_d","_i","fontMax","fontMin","padding","w","h","sh","Math","min","labelConfig","textAnchor","l","verticalAlign","fontColor","src","fillVal","colorDefaults","undefined","n","shapeType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;AAGA,GAEA,SAAQA,aAAa,QAAO,gBAAgB;AAC5C,SAAQC,gBAAgB,QAAO,iBAAiB;AAKhD,OAAOC,cAAc,0BAA0B;AAC/C,SAAQC,UAAU,QAAO,6BAA6B;AACtD,SAAQC,eAAe,EAAEC,WAAW,EAAEC,cAAc,QAAO,6BAA6B;AAIxF,SAASC,gBACPC,GAAY,EACZC,CAAY,EACZC,CAAqB;IAErB,IAAI,OAAOF,QAAQ,YAAY;QAC7B,OAAO,AAACA,IAAmDC,GAAGC;IAChE;IACA,OAAOF;AACT;AAEA,OAAO,IAAMG,cAAyB;QAAEC,YAAAA,KAAKC,kBAAAA;IAC3C,IAAMC,QAASD,sBAAAA,uBAAAA,YAAa,EAAE;IAC9B,IAAI,CAACC,MAAMC,MAAM,EAAE,OAAO,EAAE;IAE5B,IAAMC,SAASJ,IAAIK,MAAM,CAACD,MAAM;IAChC,IAAME,YAAYN,IAAIO,UAAU;IAChC,IAAMC,KAAKd,eAAeM,KAAK;IAE/B,IAAMS,YAAyBP,MAAMQ,GAAG,CAACb,SAAAA;YAuBPA;QAtBhC,IAAMc,OAAOhB,gBAAwBa,GAAGG,IAAI,EAAEd,EAAEe,IAAI,EAAEf,EAAEC,CAAC;QACzD,IAAMe,SAASlB,gBAAoCa,GAAGK,MAAM,EAAEhB,EAAEe,IAAI,EAAEf,EAAEC,CAAC;QACzE,IAAMgB,UAAUnB,gBAAwBa,GAAGM,OAAO,EAAEjB,EAAEe,IAAI,EAAEf,EAAEC,CAAC;QAC/D,IAAMiB,cAAcpB,gBAAwBa,G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e,IAAI,GAAGf;gBACpC,IAAM0D,UAAU5D,gBAAwBa,GAAGG,IAAI,EAAE2C,KAAKA,IAAIxD,CAAC;gBAC3D,OAAO,OAAOyD,YAAY,WAAWnE,cAAcmE,SAASvD,IAAIK,MAAM,CAACmD,aAAa,IAAIC;YAC1F;WACGjE,gBAAgBQ,KAAK;IAE5B;QAMK,kCAAA,2BAAA;;QAJL,0EAA0E;QAC1E,uEAAuE;QACvE,wEAAwE;QACxE,4DAA4D;QAC5D,QAAK,YAAWkC,+BAAX,SAAA,6BAAA,QAAA,yBAAA;YAAA,IAAMwB,IAAN;YAAwBA,EAA2BC,SAAS,GAAG;;;QAA/D;QAAA;;;iBAAA,6BAAA;gBAAA;;;gBAAA;sBAAA;;;;IAEL,OAAO,AAAC,qBAAGlD,kBAAW,qBAAGyB;AAC3B,EAAE"}
|
|
@@ -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 {InsetRegion} from \"../features/insetState.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 /**\n Optional region for drawing chart chrome (the size legend, legend, or\n colorScale) inside the chart's negative space, called after layout:\n the area chrome may occupy plus the boxes of the chart's marks, in\n surface coordinates (see `sceneInsetRegion`). Return null when the\n chart has no room to offer.\n */\n insetRegion?: (viz: VizInstance) => InsetRegion | 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,GAsHA,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` / `_insetRegion` delegate to
|
|
105
|
+
`def.thresholdFunction` / `def.sizeLegendScale` / `def.insetRegion` 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,18 @@ 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
|
+
},
|
|
145
|
+
{
|
|
146
|
+
key: "_insetRegion",
|
|
147
|
+
value: function _insetRegion() {
|
|
148
|
+
return def.insetRegion ? def.insetRegion(this) : _get(_get_prototype_of(Chart.prototype), "_insetRegion", this).call(this);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
138
151
|
{
|
|
139
152
|
key: "_thresholdFunction",
|
|
140
153
|
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` / `_insetRegion` delegate to\n `def.thresholdFunction` / `def.sizeLegendScale` / `def.insetRegion` 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 _insetRegion() {\n return def.insetRegion\n ? def.insetRegion(this as unknown as VizInstance)\n : super._insetRegion();\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","_insetRegion","insetRegion","_thresholdFunction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T"}
|
|
@@ -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,196 @@
|
|
|
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 { isInsetPending } from "../features/insetState.js";
|
|
74
|
+
import { resolveSpec } from "../pipeline/resolveSpec.js";
|
|
75
|
+
import { zoomSizeLegendScale } from "../../components/SizeLegend/sizeLegendLayout.js";
|
|
76
|
+
import { buildBottomRightPanel, bottomRightControlsBox, measureBottomRight } from "./bottomRightControlsMarkup.js";
|
|
77
|
+
/** The text/stroke color that reads against the chart's background. */ function inkColor(viz) {
|
|
78
|
+
var node = viz._select && typeof viz._select.node === "function" ? viz._select.node() : null;
|
|
79
|
+
var bg = node ? backgroundColor(node) : "rgb(255, 255, 255)";
|
|
80
|
+
return colorContrast(bg, viz.schema.colorDefaults);
|
|
81
|
+
}
|
|
82
|
+
/** Configures the size legend for a scale and lays it out, returning its size. */ function layoutSizeLegend(viz, scale) {
|
|
83
|
+
var ink = inkColor(viz);
|
|
84
|
+
var legend = viz._sizeLegendClass;
|
|
85
|
+
legend.renderMode("compute").locale(viz.schema.locale).title(viz._sizeKey).labelConfig({
|
|
86
|
+
fontColor: ink,
|
|
87
|
+
fontFamily: viz.schema.fontFamily
|
|
88
|
+
}).titleConfig({
|
|
89
|
+
fontColor: ink,
|
|
90
|
+
fontFamily: viz.schema.fontFamily
|
|
91
|
+
}).lineConfig({
|
|
92
|
+
stroke: ink
|
|
93
|
+
}).shapeConfig({
|
|
94
|
+
fill: ink,
|
|
95
|
+
stroke: ink
|
|
96
|
+
}).config(viz.schema.sizeLegendConfig).scale(scale);
|
|
97
|
+
var _legend_layout = legend.layout(), width = _legend_layout.width, height = _legend_layout.height;
|
|
98
|
+
return {
|
|
99
|
+
width: width,
|
|
100
|
+
height: height
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
The size legend's contribution: sized from the chart's pre-layout scale
|
|
105
|
+
estimate, painted from the scale the chart's layout actually drew with.
|
|
106
|
+
*/ export function sizeLegendContribution(viz, available) {
|
|
107
|
+
if (!viz._sizeLegendClass || typeof viz._sizeLegendScale !== "function") return null;
|
|
108
|
+
var scale = viz._sizeLegendScale(available);
|
|
109
|
+
if (!scale) return null;
|
|
110
|
+
viz._sizeLegendClass._maxRadius = undefined;
|
|
111
|
+
var _layoutSizeLegend = layoutSizeLegend(viz, scale), width = _layoutSizeLegend.width, height = _layoutSizeLegend.height;
|
|
112
|
+
if (!width || !height) return null;
|
|
113
|
+
var size = {
|
|
114
|
+
width: width,
|
|
115
|
+
height: height,
|
|
116
|
+
availableWidth: available.width,
|
|
117
|
+
availableHeight: available.height
|
|
118
|
+
};
|
|
119
|
+
if (!viz.schema.sizeLegend.bind(viz)(resolveSpec(viz), scale, size)) return null;
|
|
120
|
+
return {
|
|
121
|
+
key: "sizeLegend",
|
|
122
|
+
width: width,
|
|
123
|
+
height: height,
|
|
124
|
+
paint: function paint(zoom) {
|
|
125
|
+
var final = viz._sizeLegendFinal;
|
|
126
|
+
if (!final) return null;
|
|
127
|
+
viz._sizeLegendClass._maxRadius = zoom === 1 ? undefined : final(final.domain()[1]);
|
|
128
|
+
var size = layoutSizeLegend(viz, zoomSizeLegendScale(final, zoom));
|
|
129
|
+
if (!size.width || !size.height) return null;
|
|
130
|
+
return _object_spread({
|
|
131
|
+
node: viz._sizeLegendClass.toScene()
|
|
132
|
+
}, size);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
Ordered contributors to the bottom-right panel, right to left.
|
|
138
|
+
*/ export var BOTTOM_RIGHT_CONTRIBUTORS = [
|
|
139
|
+
sizeLegendContribution
|
|
140
|
+
];
|
|
141
|
+
/**
|
|
142
|
+
Measures the panel for this draw and stores it on `viz._bottomRightBox`
|
|
143
|
+
(null when nothing contributes). `bottom` is how far above the chart's
|
|
144
|
+
bottom edge the panel sits (below it: the timeline); `available` is the
|
|
145
|
+
chart area left after the claims made so far. `sizeLegendPosition`
|
|
146
|
+
picks the margin it claims (see `BottomRightBox.side`).
|
|
147
|
+
*/ export function reserveBottomRight(viz, bottom, available) {
|
|
148
|
+
var items = [];
|
|
149
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
150
|
+
try {
|
|
151
|
+
for(var _iterator = BOTTOM_RIGHT_CONTRIBUTORS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
152
|
+
var fn = _step.value;
|
|
153
|
+
var c = fn(viz, available);
|
|
154
|
+
if (c) items.push(c);
|
|
155
|
+
}
|
|
156
|
+
} catch (err) {
|
|
157
|
+
_didIteratorError = true;
|
|
158
|
+
_iteratorError = err;
|
|
159
|
+
} finally{
|
|
160
|
+
try {
|
|
161
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
162
|
+
_iterator.return();
|
|
163
|
+
}
|
|
164
|
+
} finally{
|
|
165
|
+
if (_didIteratorError) {
|
|
166
|
+
throw _iteratorError;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
var side = viz.schema.sizeLegendPosition === "bottom" ? "bottom" : "right";
|
|
171
|
+
var inset = isInsetPending(viz, "sizeLegend");
|
|
172
|
+
viz._bottomRightBox = items.length ? _object_spread_props(_object_spread({}, measureBottomRight(items)), {
|
|
173
|
+
bottom: bottom,
|
|
174
|
+
side: side,
|
|
175
|
+
inset: inset,
|
|
176
|
+
items: items
|
|
177
|
+
}) : null;
|
|
178
|
+
}
|
|
179
|
+
export var bottomRightControlsFeature = {
|
|
180
|
+
name: "bottomRightControls",
|
|
181
|
+
configFields: [
|
|
182
|
+
"sizeLegend",
|
|
183
|
+
"sizeLegendConfig",
|
|
184
|
+
"sizeLegendPosition"
|
|
185
|
+
],
|
|
186
|
+
layout: function layout(param) {
|
|
187
|
+
var viz = param.viz;
|
|
188
|
+
var box = bottomRightControlsBox(viz);
|
|
189
|
+
return {
|
|
190
|
+
panel: box ? buildBottomRightPanel(viz, box) : null,
|
|
191
|
+
margin: {}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
//# 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 {isInsetPending} from \"../features/insetState.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 const inset = isInsetPending(viz, \"sizeLegend\");\n viz._bottomRightBox = items.length ? {...measureBottomRight(items), bottom, side, inset, 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","isInsetPending","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","inset","_bottomRightBox","length","bottomRightControlsFeature","name","configFields","box","panel","margin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;AAkBA,GACA,SAAQA,aAAa,QAAO,gBAAgB;AAC5C,SAAQC,eAAe,QAAO,cAAc;AAG5C,SAAQC,cAAc,QAAO,4BAA4B;AACzD,SAAQC,WAAW,QAAO,6BAA6B;AAEvD,SAAQC,mBAAmB,QAAO,kDAAkD;AAEpF,SAAQC,qBAAqB,EAAEC,sBAAsB,EAAEC,kBAAkB,QAAO,iCAAiC;AASjH,qEAAqE,GACrE,SAASC,SAASC,GAAgB;IAChC,IAAMC,OAAOD,IAAIE,OAAO,IAAI,OAAOF,IAAIE,OAAO,CAACD,IAAI,KAAK,aAAaD,IAAIE,OAAO,CAACD,IAAI,KAAK;IAC1F,IAAME,KAAKF,OAAOT,gBAAgBS,QAAQ;IAC1C,OAAOV,cAAcY,IAAIH,IAAII,MAAM,CAACC,aAAa;AACnD;AAEA,gFAAgF,GAChF,SAASC,iBAAiBN,GAAgB,EAAEO,KAAsB;IAChE,IAAMC,MAAMT,SAASC;IACrB,IAAMS,SAAST,IAAIU,gBAAgB;IACnCD,OACGE,UAAU,CAAC,WACXC,MAAM,CAACZ,IAAII,MAAM,CAACQ,MAAM,EACxBC,KAAK,CAACb,IAAIc,QAAQ,EAClBC,WAAW,CAAC;QAACC,WAAWR;QAAKS,YAAYjB,IAAII,MAAM,CAACa,UAAU;IAAA,GAC9DC,WAAW,CAAC;QAACF,WAAWR;QAAKS,YAAYjB,IAAII,MAAM,CAACa,UAAU;IAAA,GAC9DE,UAAU,CAAC;QAACC,QAA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