@d3plus/core 4.9.0 → 4.11.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/es/index.js +1 -1
- package/es/internal.js +170 -9
- package/es/src/charts/Alluvial/aggregate.js +145 -0
- package/es/src/charts/Alluvial/applyLayout.js +125 -0
- package/es/src/charts/Alluvial/dimensions.js +56 -0
- package/es/src/charts/Alluvial/emit.js +73 -0
- package/es/src/charts/Alluvial/hover.js +101 -0
- package/es/src/charts/Alluvial/index.js +170 -0
- package/es/src/charts/Alluvial/layout.js +137 -0
- package/es/src/charts/Alluvial/meta.js +57 -0
- package/es/src/charts/Alluvial/titles.js +81 -0
- package/es/src/charts/ArcDiagram/applyLayout.js +386 -0
- package/es/src/charts/ArcDiagram/arcGeometry.js +275 -0
- package/es/src/charts/ArcDiagram/arcLabels.js +171 -0
- package/es/src/charts/ArcDiagram/arcLoops.js +78 -0
- package/es/src/charts/ArcDiagram/emit.js +178 -0
- package/es/src/charts/ArcDiagram/events.js +144 -0
- package/es/src/charts/ArcDiagram/index.js +215 -0
- package/es/src/charts/BarChart/index.js +14 -2
- package/es/src/charts/BoxWhisker/index.js +95 -4
- package/es/src/charts/BoxWhisker/outliers.js +68 -0
- package/es/src/charts/BoxWhisker/summary.js +83 -0
- package/es/src/charts/BoxWhisker/tooltip.js +122 -0
- package/es/src/charts/BubbleChart/emit.js +31 -0
- package/es/src/charts/BubbleChart/index.js +54 -0
- package/es/src/charts/Bullet/index.js +2 -1
- package/es/src/charts/BumpChart/index.js +5 -0
- package/es/src/charts/Calendar/emit.js +1 -1
- package/es/src/charts/Calendar/index.js +5 -3
- package/es/src/charts/Candlestick/aggregate.js +11 -1
- package/es/src/charts/Candlestick/buffer.js +6 -4
- package/es/src/charts/Candlestick/index.js +7 -6
- package/es/src/charts/Chord/applyLayout.js +56 -69
- package/es/src/charts/Chord/emit.js +55 -24
- package/es/src/charts/Chord/index.js +17 -12
- package/es/src/charts/Chord/labels.js +105 -0
- package/es/src/charts/Donut/index.js +5 -11
- package/es/src/charts/Dumbbell/index.js +2 -4
- package/es/src/charts/Funnel/index.js +2 -1
- package/es/src/charts/Gantt/applyLayout.js +162 -0
- package/es/src/charts/Gantt/emit.js +142 -0
- package/es/src/charts/Gantt/ganttDecor.js +207 -0
- package/es/src/charts/Gantt/ganttGeometry.js +107 -0
- package/es/src/charts/Gantt/ganttLabels.js +85 -0
- package/es/src/charts/Gantt/ganttRows.js +111 -0
- package/es/src/charts/Gantt/ganttTooltip.js +136 -0
- package/es/src/charts/Gantt/index.js +219 -0
- package/es/src/charts/Gauge/index.js +2 -1
- package/es/src/charts/Geomap/applyLayout.js +90 -49
- package/es/src/charts/Geomap/basemapTheme.js +3 -48
- package/es/src/charts/Geomap/emit.js +19 -2
- package/es/src/charts/Geomap/flowEmit.js +132 -0
- package/es/src/charts/Geomap/flowEvents.js +86 -0
- package/es/src/charts/Geomap/flowFields.js +91 -0
- package/es/src/charts/Geomap/flowGeometry.js +225 -0
- package/es/src/charts/Geomap/flowLinks.js +239 -0
- package/es/src/charts/Geomap/geoCache.js +180 -0
- package/es/src/charts/Geomap/globeKeys.js +131 -0
- package/es/src/charts/Geomap/globeRotate.js +208 -0
- package/es/src/charts/Geomap/index.js +60 -19
- package/es/src/charts/Geomap/pointLabels.js +107 -0
- package/es/src/charts/Hexbin/binning.js +103 -0
- package/es/src/charts/Hexbin/buffer.js +33 -0
- package/es/src/charts/Hexbin/contourLabels.js +234 -0
- package/es/src/charts/Hexbin/contours.js +48 -0
- package/es/src/charts/Hexbin/emit.js +142 -0
- package/es/src/charts/Hexbin/index.js +204 -0
- package/es/src/charts/Hexbin/layers.js +212 -0
- package/es/src/charts/Hexbin/settings.js +86 -0
- package/es/src/charts/Hexbin/tooltip.js +77 -0
- package/es/src/charts/Histogram/binData.js +31 -4
- package/es/src/charts/Histogram/index.js +37 -16
- package/es/src/charts/Histogram/labels.js +18 -0
- package/es/src/charts/Icicle/index.js +3 -3
- package/es/src/charts/LinePlot/index.js +7 -0
- package/es/src/charts/Marimekko/index.js +7 -4
- package/es/src/charts/Matrix/index.js +3 -2
- package/es/src/charts/Network/applyLayout.js +138 -94
- package/es/src/charts/Network/bundle.js +81 -0
- package/es/src/charts/Network/clusterLabels.js +423 -0
- package/es/src/charts/Network/clusters.js +290 -0
- package/es/src/charts/Network/emit.js +253 -70
- package/es/src/charts/Network/graph.js +117 -0
- package/es/src/charts/Network/graphFluent.js +79 -0
- package/es/src/charts/Network/index.js +93 -108
- package/es/src/charts/Network/minNodeDistance.js +64 -0
- package/es/src/charts/Network/polygonRows.js +44 -0
- package/es/src/charts/Pack/index.js +7 -2
- package/es/src/charts/Pie/applyLayout.js +86 -27
- package/es/src/charts/Pie/arcFit.js +152 -0
- package/es/src/charts/Pie/curvedLabels.js +134 -0
- package/es/src/charts/Pie/emit.js +43 -96
- package/es/src/charts/Pie/index.js +66 -32
- package/es/src/charts/Pie/labelRoom.js +154 -0
- package/es/src/charts/Pie/outsideLabels.js +224 -0
- package/es/src/charts/Pie/outsideNodes.js +267 -0
- package/es/src/charts/Pie/pieLabels.js +137 -0
- package/es/src/charts/Pie/sectorBox.js +223 -0
- package/es/src/charts/Pie/straightLabels.js +96 -0
- package/es/src/charts/Pie/straightLayout.js +215 -0
- package/es/src/charts/Plot/alongLegend.js +76 -0
- package/es/src/charts/Plot/areaLabelsAlong.js +333 -0
- package/es/src/charts/Plot/axisHover.js +180 -0
- package/es/src/charts/Plot/axisHoverAnchors.js +174 -0
- package/es/src/charts/Plot/axisHoverScene.js +203 -0
- package/es/src/charts/Plot/axisValues.js +43 -0
- package/es/src/charts/Plot/barHitArea.js +81 -0
- package/es/src/charts/Plot/barLabelFit.js +123 -0
- package/es/src/charts/Plot/barWidth.js +61 -13
- package/es/src/charts/Plot/circleLabels.js +98 -0
- package/es/src/charts/Plot/confidenceConfig.js +2 -2
- package/es/src/charts/Plot/connectGaps.js +237 -0
- package/es/src/charts/Plot/connectGapsScene.js +188 -0
- package/es/src/charts/Plot/draw.js +14 -4
- package/es/src/charts/Plot/fillBetween.js +2 -1
- package/es/src/charts/Plot/forecastScene.js +3 -4
- package/es/src/charts/Plot/index.js +42 -15
- package/es/src/charts/Plot/labelPlacement.js +10 -2
- package/es/src/charts/Plot/lineLabelEmit.js +82 -0
- package/es/src/charts/Plot/lineLabelSides.js +51 -0
- package/es/src/charts/Plot/lineLabelSpread.js +65 -0
- package/es/src/charts/Plot/lineLabelsAlong.js +282 -0
- package/es/src/charts/Plot/openDomainEnds.js +2 -5
- package/es/src/charts/Plot/pipeline.js +71 -22
- package/es/src/charts/Plot/pipelineAxisLayout.js +42 -8
- package/es/src/charts/Plot/pipelineDomains.js +23 -6
- package/es/src/charts/Plot/pipelineLineLabels.js +145 -53
- package/es/src/charts/Plot/pipelineScales.js +40 -8
- package/es/src/charts/Plot/plotFacet.js +12 -1
- package/es/src/charts/Plot/plotInit.js +49 -5
- package/es/src/charts/Plot/plotRangeBreaks.js +85 -0
- package/es/src/charts/Plot/plotZoom.js +15 -6
- package/es/src/charts/Plot/referenceDomains.js +133 -0
- package/es/src/charts/Plot/shapeDefaults.js +14 -9
- package/es/src/charts/Plot/sharedHoverScene.js +50 -31
- package/es/src/charts/Plot/sharedTooltip.js +19 -7
- package/es/src/charts/Plot/stackHelpers.js +13 -1
- package/es/src/charts/Plot/stackLegendOrder.js +176 -0
- package/es/src/charts/Plot/stackShareTooltip.js +9 -4
- package/es/src/charts/Plot/stackThreshold.js +154 -0
- package/es/src/charts/Plot/trendLabels.js +183 -0
- package/es/src/charts/Plot/trendLines.js +1 -0
- package/es/src/charts/Plot/trendScene.js +6 -3
- package/es/src/charts/Plot/trendTooltip.js +5 -1
- package/es/src/charts/PolarArea/index.js +5 -4
- package/es/src/charts/Priestley/applyLayout.js +14 -20
- package/es/src/charts/Priestley/index.js +4 -34
- package/es/src/charts/Priestley/timeAxis.js +100 -0
- package/es/src/charts/Pyramid/index.js +4 -2
- package/es/src/charts/Radar/axisDecorations.js +49 -12
- package/es/src/charts/Radar/curvedLabels.js +187 -0
- package/es/src/charts/Radar/index.js +5 -5
- package/es/src/charts/RadialBar/curvedLabels.js +111 -0
- package/es/src/charts/RadialBar/emit.js +4 -1
- package/es/src/charts/RadialBar/index.js +18 -10
- package/es/src/charts/RadialBar/trackLayout.js +43 -13
- package/es/src/charts/RadialMatrix/index.js +6 -9
- package/es/src/charts/Rings/applyLayout.js +41 -24
- package/es/src/charts/Rings/emit.js +174 -58
- package/es/src/charts/Rings/index.js +65 -30
- package/es/src/charts/Rings/ringsGraph.js +28 -9
- package/es/src/charts/Rings/ringsLoops.js +73 -0
- package/es/src/charts/Rings/ringsParallel.js +166 -0
- package/es/src/charts/Sankey/applyLayout.js +116 -39
- package/es/src/charts/Sankey/circularLayout.js +208 -0
- package/es/src/charts/Sankey/circularLinks.js +301 -0
- package/es/src/charts/Sankey/emit.js +164 -94
- package/es/src/charts/Sankey/index.js +75 -77
- package/es/src/charts/Sankey/labels.js +80 -0
- package/es/src/charts/Sankey/ribbons.js +88 -0
- package/es/src/charts/Sankey/sankeyCycles.js +117 -0
- package/es/src/charts/Sankey/sankeyLayout.js +8 -3
- package/es/src/charts/Sankey/sankeyLinks.js +47 -0
- package/es/src/charts/Scatter/index.js +25 -0
- package/es/src/charts/SlopeChart/index.js +116 -0
- package/es/src/charts/SlopeChart/slope.js +95 -0
- package/es/src/charts/Streamgraph/index.js +51 -0
- package/es/src/charts/Sunburst/curvedLabels.js +74 -0
- package/es/src/charts/Sunburst/emit.js +74 -63
- package/es/src/charts/Sunburst/index.js +3 -3
- package/es/src/charts/Tree/index.js +2 -6
- package/es/src/charts/Treemap/applyLayout.js +14 -1
- package/es/src/charts/Treemap/emit.js +8 -2
- package/es/src/charts/Treemap/emitGroupHeaders.js +104 -0
- package/es/src/charts/Treemap/groupHeaders.js +95 -0
- package/es/src/charts/Treemap/index.js +17 -7
- package/es/src/charts/Treemap/thresholdFunction.js +11 -9
- package/es/src/charts/Violin/inner.js +3 -5
- package/es/src/charts/Waffle/index.js +4 -2
- package/es/src/charts/Waffle/tooltip.js +6 -2
- package/es/src/charts/Waterfall/index.js +4 -2
- package/es/src/charts/definition/makeChart.js +20 -5
- package/es/src/charts/drawSteps/backControl.js +17 -5
- package/es/src/charts/drawSteps/gestureHover.js +79 -0
- package/es/src/charts/drawSteps/minimap.js +6 -5
- package/es/src/charts/drawSteps/minimapMarkup.js +25 -9
- package/es/src/charts/drawSteps/saveChart.js +176 -0
- package/es/src/charts/drawSteps/saveControl.js +148 -0
- package/es/src/charts/drawSteps/saveControlMarkup.js +104 -0
- package/es/src/charts/drawSteps/searchControls.js +2 -1
- package/es/src/charts/drawSteps/searchControlsMarkup.js +11 -2
- package/es/src/charts/drawSteps/tableViewMarkup.js +18 -11
- package/es/src/charts/drawSteps/topLeftControls.js +3 -1
- package/es/src/charts/drawSteps/topLeftControlsMarkup.js +1 -1
- package/es/src/charts/drawSteps/zoomControls.js +21 -5
- package/es/src/charts/events/click.legend.js +7 -2
- package/es/src/charts/events/click.shape.js +38 -2
- package/es/src/charts/events/mouseenter.js +9 -0
- package/es/src/charts/events/mousemove.legend.js +3 -0
- package/es/src/charts/events/mousemove.shape.js +12 -4
- package/es/src/charts/facet/drawFacets.js +14 -5
- package/es/src/charts/facet/facetConfig.js +2 -2
- package/es/src/charts/facet/facetData.js +2 -2
- package/es/src/charts/features/annotationFrame.js +179 -0
- package/es/src/charts/features/annotationText.js +83 -0
- package/es/src/charts/features/annotationTypes.js +10 -0
- package/es/src/charts/features/attributionFeature.js +6 -11
- package/es/src/charts/features/axes.js +9 -7
- package/es/src/charts/features/axesFinal.js +26 -4
- package/es/src/charts/features/axesMeasure.js +61 -6
- package/es/src/charts/features/calloutLayout.js +121 -0
- package/es/src/charts/features/calloutScene.js +155 -0
- package/es/src/charts/features/chartGeometry.js +1 -1
- package/es/src/charts/features/circleLabelPlacement.js +297 -0
- package/es/src/charts/features/circleLabels.js +207 -0
- package/es/src/charts/features/colorScaleBucket.js +19 -1
- package/es/src/charts/features/colorScaleHover.js +70 -0
- package/es/src/charts/features/colorScaleValue.js +97 -0
- package/es/src/charts/features/curvedArrows.js +158 -0
- package/es/src/charts/features/edgeArrows.js +160 -4
- package/es/src/charts/features/edgeBundling.js +442 -0
- package/es/src/charts/features/edgeBundlingSmooth.js +117 -0
- package/es/src/charts/features/ensureZoomDom.js +32 -8
- package/es/src/charts/features/features.js +45 -15
- package/es/src/charts/features/featuresColorScale.js +62 -8
- package/es/src/charts/features/featuresLegend.js +21 -32
- package/es/src/charts/features/legendKeys.js +64 -0
- package/es/src/charts/features/lineLabels.js +55 -46
- package/es/src/charts/features/linkBundle.js +19 -0
- package/es/src/charts/features/linkColor.js +72 -0
- package/es/src/charts/features/linkFields.js +86 -0
- package/es/src/charts/features/linkFocus.js +118 -0
- package/es/src/charts/features/linkInteraction.js +312 -0
- package/es/src/charts/features/linkKeys.js +20 -0
- package/es/src/charts/features/linkLabelGeometry.js +209 -0
- package/es/src/charts/features/linkLabelPath.js +162 -0
- package/es/src/charts/features/linkLabels.js +340 -0
- package/es/src/charts/features/linkWidths.js +32 -0
- package/es/src/charts/features/pathLabelGeometry.js +232 -0
- package/es/src/charts/features/pathLabels.js +50 -0
- package/es/src/charts/features/plotAnnotations.js +68 -17
- package/es/src/charts/features/plotPaint.js +42 -15
- package/es/src/charts/features/polyline.js +129 -0
- package/es/src/charts/features/referenceAnnotations.js +403 -0
- package/es/src/charts/features/referenceLabelPlacement.js +106 -0
- package/es/src/charts/features/ringLabelNodes.js +93 -0
- package/es/src/charts/features/ringLabels.js +222 -0
- package/es/src/charts/features/sceneBounds.js +26 -6
- package/es/src/charts/features/selfLoops.js +306 -0
- package/es/src/charts/features/shapeEmit.js +67 -30
- package/es/src/charts/features/shareKey.js +15 -0
- package/es/src/charts/features/sharedFields.js +15 -2
- package/es/src/charts/features/textHalo.js +29 -0
- package/es/src/charts/features/thresholdMembers.js +71 -0
- package/es/src/charts/helpers/densityChart.js +3 -1
- package/es/src/charts/helpers/valueTitle.js +6 -3
- package/es/src/charts/index.js +8 -0
- package/es/src/charts/partition/chartFields.js +6 -5
- package/es/src/charts/partition/hierarchy.js +2 -0
- package/es/src/charts/partition/interaction.js +9 -5
- package/es/src/charts/partition/zoom.js +7 -6
- package/es/src/charts/pipeline/insetPlacement.js +14 -6
- package/es/src/charts/pipeline/preDrawData.js +77 -13
- package/es/src/charts/pipeline/runVizPipeline.js +5 -0
- package/es/src/charts/pipeline/vizDraw.js +40 -29
- package/es/src/charts/pipeline/vizPreDraw.js +29 -18
- package/es/src/charts/plotBuffers/discreteBuffer.js +7 -4
- package/es/src/charts/polar/config.js +2 -3
- package/es/src/charts/viz/Viz.js +82 -44
- package/es/src/charts/viz/VizBase.js +47 -19
- package/es/src/charts/viz/backgroundInk.js +13 -7
- package/es/src/charts/viz/dataPoller.js +52 -0
- package/es/src/charts/viz/focusRing.js +104 -0
- package/es/src/charts/viz/focusTargets.js +208 -0
- package/es/src/charts/viz/groupRow.js +35 -0
- package/es/src/charts/viz/history.js +74 -0
- package/es/src/charts/viz/interactionOpacity.js +19 -5
- package/es/src/charts/viz/keyboardNav.js +297 -0
- package/es/src/charts/viz/keyboardNavHost.js +95 -0
- package/es/src/charts/viz/loaderFormat.js +114 -0
- package/es/src/charts/viz/missingFields.js +123 -0
- package/es/src/charts/viz/mountTarget.js +9 -0
- package/es/src/charts/viz/nearestHover.js +183 -0
- package/es/src/charts/viz/nearestHoverSurface.js +92 -0
- package/es/src/charts/viz/ordinalColor.js +14 -12
- package/es/src/charts/viz/pageTheme.js +83 -0
- package/es/src/charts/viz/pointTooltipAnchor.js +59 -0
- package/es/src/charts/viz/pointVoronoi.js +124 -0
- package/es/src/charts/viz/reducedMotion.js +27 -0
- package/es/src/charts/viz/reportHandlerError.js +10 -0
- package/es/src/charts/viz/shapeClassTargets.js +18 -2
- package/es/src/charts/viz/simpleHover.js +2 -0
- package/es/src/charts/viz/vizClassName.js +31 -0
- package/es/src/charts/viz/vizDataPolling.js +172 -0
- package/es/src/charts/viz/vizDefaults.js +81 -23
- package/es/src/charts/viz/vizFields.js +53 -2
- package/es/src/charts/viz/vizRender.js +49 -28
- package/es/src/charts/viz/vizTheme.js +96 -0
- package/es/src/charts/viz/vizVisibility.js +14 -0
- package/es/src/components/Axis/Axis.js +34 -0
- package/es/src/components/Axis/AxisBottom.js +1 -0
- package/es/src/components/Axis/AxisLeft.js +1 -0
- package/es/src/components/Axis/AxisRight.js +1 -0
- package/es/src/components/Axis/AxisTop.js +1 -0
- package/es/src/components/Axis/axisBreak.js +4 -1
- package/es/src/components/Axis/axisDefaults.js +8 -10
- package/es/src/components/Axis/axisLabelAngle.js +175 -0
- package/es/src/components/Axis/axisLabelThinning.js +13 -4
- package/es/src/components/Axis/axisLayout.js +86 -19
- package/es/src/components/Axis/axisLayoutLabels.js +66 -13
- package/es/src/components/Axis/axisLayoutScale.js +10 -1
- package/es/src/components/Axis/axisRangeBreaks.js +77 -0
- package/es/src/components/Axis/axisRender.js +38 -9
- package/es/src/components/Axis/axisRounding.js +15 -4
- package/es/src/components/Axis/axisSlantWrap.js +39 -0
- package/es/src/components/Axis/brokenTimeScale.js +196 -0
- package/es/src/components/Axis/powTicks.js +73 -0
- package/es/src/components/Axis/rangeBreaks.js +201 -0
- package/es/src/components/Axis/timeValues.js +19 -4
- package/es/src/components/ColorScale/ColorScale.js +42 -36
- package/es/src/components/ColorScale/bucketBounds.js +64 -0
- package/es/src/components/ColorScale/colorScaleHoverMark.js +327 -0
- package/es/src/components/ColorScale/colorScaleRender.js +25 -1
- package/es/src/components/ColorScale/colorScaleScale.js +43 -24
- package/es/src/components/ColorScale/colorScaleType.js +26 -0
- package/es/src/components/Legend/Legend.js +3 -0
- package/es/src/components/Legend/legendConfig.js +2 -6
- package/es/src/components/SizeLegend/SizeLegend.js +1 -0
- package/es/src/components/TextBox.js +31 -65
- package/es/src/components/Timeline/Timeline.js +54 -54
- package/es/src/components/Timeline/brushSpan.js +78 -0
- package/es/src/components/Timeline/timelineConfig.js +27 -10
- package/es/src/components/Timeline/timelineMode.js +26 -0
- package/es/src/components/Timeline/timelineRender.js +51 -9
- package/es/src/components/Tooltip.js +28 -13
- package/es/src/components/fontStack.js +20 -0
- package/es/src/components/textBoxLayout.js +58 -21
- package/es/src/components/textBoxPath.js +73 -0
- package/es/src/components/textBoxScene.js +223 -0
- package/es/src/components/textBoxWords.js +70 -0
- package/es/src/shapes/Area.js +1 -0
- package/es/src/shapes/Bar.js +1 -0
- package/es/src/shapes/Box.js +67 -79
- package/es/src/shapes/Circle.js +1 -0
- package/es/src/shapes/Line.js +1 -0
- package/es/src/shapes/Path.js +1 -0
- package/es/src/shapes/Rect.js +1 -0
- package/es/src/shapes/Shape.js +1 -0
- package/es/src/shapes/Whisker.js +1 -0
- package/es/src/shapes/boxOutlierShape.js +19 -0
- package/es/src/shapes/boxStats.js +35 -0
- package/es/src/shapes/boxStyle.js +78 -0
- package/es/src/shapes/boxSummary.js +174 -0
- package/es/src/shapes/shapeStandalone.js +2 -0
- package/es/src/utils/BaseClass.js +44 -12
- package/es/src/utils/className.js +78 -0
- package/es/src/utils/configPrep.js +2 -1
- package/es/src/utils/configWarnings.js +25 -0
- package/es/src/utils/constant.js +13 -1
- package/es/src/utils/displayName.js +12 -0
- package/es/src/utils/fieldAccessor.js +31 -0
- package/es/src/utils/paintComponentScene.js +2 -0
- package/es/src/utils/theme.js +190 -0
- package/es/src/utils/themeInk.js +68 -0
- package/package.json +14 -10
- package/types/index.d.ts +8 -2
- package/types/internal.d.ts +253 -9
- package/types/src/charts/Alluvial/aggregate.d.ts +98 -0
- package/types/src/charts/Alluvial/applyLayout.d.ts +67 -0
- package/types/src/charts/Alluvial/dimensions.d.ts +40 -0
- package/types/src/charts/Alluvial/emit.d.ts +9 -0
- package/types/src/charts/Alluvial/hover.d.ts +31 -0
- package/types/src/charts/Alluvial/index.d.ts +27 -0
- package/types/src/charts/Alluvial/layout.d.ts +70 -0
- package/types/src/charts/Alluvial/meta.d.ts +54 -0
- package/types/src/charts/Alluvial/titles.d.ts +33 -0
- package/types/src/charts/ArcDiagram/applyLayout.d.ts +70 -0
- package/types/src/charts/ArcDiagram/arcGeometry.d.ts +150 -0
- package/types/src/charts/ArcDiagram/arcLabels.d.ts +89 -0
- package/types/src/charts/ArcDiagram/arcLoops.d.ts +48 -0
- package/types/src/charts/ArcDiagram/emit.d.ts +23 -0
- package/types/src/charts/ArcDiagram/events.d.ts +28 -0
- package/types/src/charts/ArcDiagram/index.d.ts +28 -0
- package/types/src/charts/BoxWhisker/index.d.ts +3 -1
- package/types/src/charts/BoxWhisker/outliers.d.ts +25 -0
- package/types/src/charts/BoxWhisker/summary.d.ts +39 -0
- package/types/src/charts/BoxWhisker/tooltip.d.ts +36 -0
- package/types/src/charts/BubbleChart/emit.d.ts +20 -0
- package/types/src/charts/BubbleChart/index.d.ts +16 -0
- package/types/src/charts/Candlestick/aggregate.d.ts +6 -0
- package/types/src/charts/Chord/applyLayout.d.ts +3 -0
- package/types/src/charts/Chord/labels.d.ts +66 -0
- package/types/src/charts/Donut/index.d.ts +2 -1
- package/types/src/charts/Gantt/applyLayout.d.ts +64 -0
- package/types/src/charts/Gantt/emit.d.ts +17 -0
- package/types/src/charts/Gantt/ganttDecor.d.ts +41 -0
- package/types/src/charts/Gantt/ganttGeometry.d.ts +57 -0
- package/types/src/charts/Gantt/ganttLabels.d.ts +41 -0
- package/types/src/charts/Gantt/ganttRows.d.ts +84 -0
- package/types/src/charts/Gantt/ganttTooltip.d.ts +57 -0
- package/types/src/charts/Gantt/index.d.ts +36 -0
- package/types/src/charts/Geomap/applyLayout.d.ts +8 -0
- package/types/src/charts/Geomap/basemapTheme.d.ts +2 -19
- package/types/src/charts/Geomap/emit.d.ts +2 -2
- package/types/src/charts/Geomap/flowEmit.d.ts +35 -0
- package/types/src/charts/Geomap/flowEvents.d.ts +20 -0
- package/types/src/charts/Geomap/flowFields.d.ts +7 -0
- package/types/src/charts/Geomap/flowGeometry.d.ts +91 -0
- package/types/src/charts/Geomap/flowLinks.d.ts +97 -0
- package/types/src/charts/Geomap/geoCache.d.ts +47 -0
- package/types/src/charts/Geomap/globeKeys.d.ts +41 -0
- package/types/src/charts/Geomap/globeRotate.d.ts +70 -0
- package/types/src/charts/Geomap/index.d.ts +3 -0
- package/types/src/charts/Geomap/pointLabels.d.ts +24 -0
- package/types/src/charts/Hexbin/binning.d.ts +64 -0
- package/types/src/charts/Hexbin/buffer.d.ts +18 -0
- package/types/src/charts/Hexbin/contourLabels.d.ts +95 -0
- package/types/src/charts/Hexbin/contours.d.ts +48 -0
- package/types/src/charts/Hexbin/emit.d.ts +23 -0
- package/types/src/charts/Hexbin/index.d.ts +25 -0
- package/types/src/charts/Hexbin/layers.d.ts +94 -0
- package/types/src/charts/Hexbin/settings.d.ts +122 -0
- package/types/src/charts/Hexbin/tooltip.d.ts +26 -0
- package/types/src/charts/Histogram/binData.d.ts +20 -1
- package/types/src/charts/Histogram/index.d.ts +3 -2
- package/types/src/charts/Histogram/labels.d.ts +7 -0
- package/types/src/charts/Marimekko/index.d.ts +2 -1
- package/types/src/charts/Network/bundle.d.ts +67 -0
- package/types/src/charts/Network/clusterLabels.d.ts +112 -0
- package/types/src/charts/Network/clusters.d.ts +115 -0
- package/types/src/charts/Network/graph.d.ts +65 -0
- package/types/src/charts/Network/graphFluent.d.ts +20 -0
- package/types/src/charts/Network/minNodeDistance.d.ts +18 -0
- package/types/src/charts/Network/polygonRows.d.ts +29 -0
- package/types/src/charts/Pie/applyLayout.d.ts +31 -3
- package/types/src/charts/Pie/arcFit.d.ts +63 -0
- package/types/src/charts/Pie/curvedLabels.d.ts +57 -0
- package/types/src/charts/Pie/labelRoom.d.ts +83 -0
- package/types/src/charts/Pie/outsideLabels.d.ts +119 -0
- package/types/src/charts/Pie/outsideNodes.d.ts +93 -0
- package/types/src/charts/Pie/pieLabels.d.ts +85 -0
- package/types/src/charts/Pie/sectorBox.d.ts +95 -0
- package/types/src/charts/Pie/straightLabels.d.ts +24 -0
- package/types/src/charts/Pie/straightLayout.d.ts +88 -0
- package/types/src/charts/Plot/alongLegend.d.ts +42 -0
- package/types/src/charts/Plot/areaLabelsAlong.d.ts +119 -0
- package/types/src/charts/Plot/axisHover.d.ts +68 -0
- package/types/src/charts/Plot/axisHoverAnchors.d.ts +88 -0
- package/types/src/charts/Plot/axisHoverScene.d.ts +88 -0
- package/types/src/charts/Plot/axisValues.d.ts +24 -0
- package/types/src/charts/Plot/barHitArea.d.ts +59 -0
- package/types/src/charts/Plot/barLabelFit.d.ts +81 -0
- package/types/src/charts/Plot/barWidth.d.ts +38 -4
- package/types/src/charts/Plot/circleLabels.d.ts +29 -0
- package/types/src/charts/Plot/connectGaps.d.ts +99 -0
- package/types/src/charts/Plot/connectGapsScene.d.ts +55 -0
- package/types/src/charts/Plot/forecastScene.d.ts +5 -0
- package/types/src/charts/Plot/index.d.ts +28 -8
- package/types/src/charts/Plot/labelPlacement.d.ts +5 -0
- package/types/src/charts/Plot/lineLabelEmit.d.ts +48 -0
- package/types/src/charts/Plot/lineLabelSides.d.ts +50 -0
- package/types/src/charts/Plot/lineLabelSpread.d.ts +15 -0
- package/types/src/charts/Plot/lineLabelsAlong.d.ts +116 -0
- package/types/src/charts/Plot/pipeline.d.ts +15 -1
- package/types/src/charts/Plot/pipelineLineLabels.d.ts +68 -0
- package/types/src/charts/Plot/plotFacet.d.ts +5 -0
- package/types/src/charts/Plot/plotInit.d.ts +23 -2
- package/types/src/charts/Plot/plotRangeBreaks.d.ts +35 -0
- package/types/src/charts/Plot/plotZoom.d.ts +2 -0
- package/types/src/charts/Plot/referenceDomains.d.ts +49 -0
- package/types/src/charts/Plot/sharedHoverScene.d.ts +3 -3
- package/types/src/charts/Plot/sharedTooltip.d.ts +11 -4
- package/types/src/charts/Plot/stackHelpers.d.ts +5 -0
- package/types/src/charts/Plot/stackLegendOrder.d.ts +83 -0
- package/types/src/charts/Plot/stackThreshold.d.ts +75 -0
- package/types/src/charts/Plot/trendLabels.d.ts +73 -0
- package/types/src/charts/Plot/trendTooltip.d.ts +6 -0
- package/types/src/charts/Priestley/timeAxis.d.ts +76 -0
- package/types/src/charts/Radar/axisDecorations.d.ts +7 -2
- package/types/src/charts/Radar/curvedLabels.d.ts +94 -0
- package/types/src/charts/RadialBar/curvedLabels.d.ts +31 -0
- package/types/src/charts/RadialBar/trackLayout.d.ts +34 -3
- package/types/src/charts/Rings/emit.d.ts +50 -0
- package/types/src/charts/Rings/ringsGraph.d.ts +10 -2
- package/types/src/charts/Rings/ringsLoops.d.ts +13 -0
- package/types/src/charts/Rings/ringsParallel.d.ts +43 -0
- package/types/src/charts/Sankey/circularLayout.d.ts +103 -0
- package/types/src/charts/Sankey/circularLinks.d.ts +178 -0
- package/types/src/charts/Sankey/emit.d.ts +58 -0
- package/types/src/charts/Sankey/labels.d.ts +19 -0
- package/types/src/charts/Sankey/ribbons.d.ts +36 -0
- package/types/src/charts/Sankey/sankeyCycles.d.ts +24 -0
- package/types/src/charts/Sankey/sankeyLayout.d.ts +6 -0
- package/types/src/charts/Sankey/sankeyLinks.d.ts +36 -0
- package/types/src/charts/Scatter/index.d.ts +15 -0
- package/types/src/charts/SlopeChart/index.d.ts +43 -0
- package/types/src/charts/SlopeChart/slope.d.ts +43 -0
- package/types/src/charts/Streamgraph/index.d.ts +28 -0
- package/types/src/charts/Sunburst/curvedLabels.d.ts +56 -0
- package/types/src/charts/Treemap/emit.d.ts +2 -1
- package/types/src/charts/Treemap/emitGroupHeaders.d.ts +16 -0
- package/types/src/charts/Treemap/groupHeaders.d.ts +91 -0
- package/types/src/charts/Treemap/index.d.ts +2 -0
- package/types/src/charts/Treemap/thresholdFunction.d.ts +5 -2
- package/types/src/charts/definition/ChartDefinition.d.ts +27 -2
- package/types/src/charts/definition/makeChart.d.ts +5 -3
- package/types/src/charts/drawSteps/backControl.d.ts +7 -22
- package/types/src/charts/drawSteps/gestureHover.d.ts +33 -0
- package/types/src/charts/drawSteps/minimapMarkup.d.ts +5 -4
- package/types/src/charts/drawSteps/saveChart.d.ts +47 -0
- package/types/src/charts/drawSteps/saveControl.d.ts +9 -0
- package/types/src/charts/drawSteps/saveControlMarkup.d.ts +44 -0
- package/types/src/charts/drawSteps/tableViewMarkup.d.ts +4 -1
- package/types/src/charts/drawSteps/topLeftControls.d.ts +1 -1
- package/types/src/charts/drawSteps/topLeftControlsMarkup.d.ts +1 -1
- package/types/src/charts/drawSteps/zoomGesture.d.ts +32 -0
- package/types/src/charts/events/click.legend.d.ts +2 -1
- package/types/src/charts/facet/facetConfig.d.ts +4 -2
- package/types/src/charts/facet/facetData.d.ts +1 -1
- package/types/src/charts/features/annotationFrame.d.ts +108 -0
- package/types/src/charts/features/annotationText.d.ts +57 -0
- package/types/src/charts/features/annotationTypes.d.ts +161 -0
- package/types/src/charts/features/axesMeasure.d.ts +13 -1
- package/types/src/charts/features/calloutLayout.d.ts +78 -0
- package/types/src/charts/features/calloutScene.d.ts +40 -0
- package/types/src/charts/features/chartGeometry.d.ts +1 -1
- package/types/src/charts/features/circleLabelPlacement.d.ts +97 -0
- package/types/src/charts/features/circleLabels.d.ts +130 -0
- package/types/src/charts/features/colorScaleBucket.d.ts +9 -0
- package/types/src/charts/features/colorScaleHover.d.ts +32 -0
- package/types/src/charts/features/colorScaleValue.d.ts +35 -0
- package/types/src/charts/features/curvedArrows.d.ts +105 -0
- package/types/src/charts/features/edgeArrows.d.ts +74 -2
- package/types/src/charts/features/edgeBundling.d.ts +86 -0
- package/types/src/charts/features/edgeBundlingSmooth.d.ts +29 -0
- package/types/src/charts/features/ensureZoomDom.d.ts +19 -1
- package/types/src/charts/features/features.d.ts +8 -0
- package/types/src/charts/features/featuresLegend.d.ts +4 -3
- package/types/src/charts/features/legendKeys.d.ts +34 -0
- package/types/src/charts/features/lineLabels.d.ts +15 -12
- package/types/src/charts/features/linkBundle.d.ts +16 -0
- package/types/src/charts/features/linkColor.d.ts +48 -0
- package/types/src/charts/features/linkFields.d.ts +16 -0
- package/types/src/charts/features/linkFocus.d.ts +51 -0
- package/types/src/charts/features/linkInteraction.d.ts +183 -0
- package/types/src/charts/features/linkKeys.d.ts +11 -0
- package/types/src/charts/features/linkLabelGeometry.d.ts +67 -0
- package/types/src/charts/features/linkLabelPath.d.ts +85 -0
- package/types/src/charts/features/linkLabels.d.ts +77 -0
- package/types/src/charts/features/linkWidths.d.ts +19 -0
- package/types/src/charts/features/pathLabelGeometry.d.ts +99 -0
- package/types/src/charts/features/pathLabels.d.ts +41 -0
- package/types/src/charts/features/plotAnnotations.d.ts +23 -8
- package/types/src/charts/features/plotPaint.d.ts +19 -0
- package/types/src/charts/features/polyline.d.ts +32 -0
- package/types/src/charts/features/referenceAnnotations.d.ts +130 -0
- package/types/src/charts/features/referenceLabelPlacement.d.ts +58 -0
- package/types/src/charts/features/ringLabelNodes.d.ts +63 -0
- package/types/src/charts/features/ringLabels.d.ts +164 -0
- package/types/src/charts/features/sceneBounds.d.ts +6 -0
- package/types/src/charts/features/selfLoops.d.ts +165 -0
- package/types/src/charts/features/shapeEmit.d.ts +5 -1
- package/types/src/charts/features/shareKey.d.ts +9 -0
- package/types/src/charts/features/sharedFields.d.ts +11 -2
- package/types/src/charts/features/textHalo.d.ts +14 -0
- package/types/src/charts/features/thresholdMembers.d.ts +38 -0
- package/types/src/charts/helpers/valueTitle.d.ts +4 -2
- package/types/src/charts/index.d.ts +8 -0
- package/types/src/charts/partition/interaction.d.ts +6 -3
- package/types/src/charts/partition/zoom.d.ts +4 -4
- package/types/src/charts/pipeline/preDrawData.d.ts +14 -1
- package/types/src/charts/pipeline/stages.d.ts +9 -0
- package/types/src/charts/pipeline/vizDraw.d.ts +8 -3
- package/types/src/charts/pipeline/vizPreDraw.d.ts +3 -2
- package/types/src/charts/plotBuffers/discreteBuffer.d.ts +0 -5
- package/types/src/charts/viz/Viz.d.ts +44 -6
- package/types/src/charts/viz/VizBase.d.ts +16 -7
- package/types/src/charts/viz/backgroundInk.d.ts +11 -4
- package/types/src/charts/viz/dataPoller.d.ts +28 -0
- package/types/src/charts/viz/focusRing.d.ts +25 -0
- package/types/src/charts/viz/focusTargets.d.ts +56 -0
- package/types/src/charts/viz/groupRow.d.ts +24 -0
- package/types/src/charts/viz/history.d.ts +35 -0
- package/types/src/charts/viz/interactionOpacity.d.ts +3 -1
- package/types/src/charts/viz/keyboardNav.d.ts +55 -0
- package/types/src/charts/viz/keyboardNavHost.d.ts +53 -0
- package/types/src/charts/viz/loaderFormat.d.ts +78 -0
- package/types/src/charts/viz/missingFields.d.ts +57 -0
- package/types/src/charts/viz/mountTarget.d.ts +7 -0
- package/types/src/charts/viz/nearestHover.d.ts +75 -0
- package/types/src/charts/viz/nearestHoverSurface.d.ts +21 -0
- package/types/src/charts/viz/ordinalColor.d.ts +10 -8
- package/types/src/charts/viz/pageTheme.d.ts +34 -0
- package/types/src/charts/viz/pointTooltipAnchor.d.ts +36 -0
- package/types/src/charts/viz/pointVoronoi.d.ts +65 -0
- package/types/src/charts/viz/reducedMotion.d.ts +25 -0
- package/types/src/charts/viz/reportHandlerError.d.ts +7 -0
- package/types/src/charts/viz/shapeClassTargets.d.ts +6 -0
- package/types/src/charts/viz/simpleHover.d.ts +2 -1
- package/types/src/charts/viz/vizClassName.d.ts +23 -0
- package/types/src/charts/viz/vizDataPolling.d.ts +48 -0
- package/types/src/charts/viz/vizDefaults.d.ts +49 -9
- package/types/src/charts/viz/vizFields.d.ts +47 -0
- package/types/src/charts/viz/vizRender.d.ts +2 -1
- package/types/src/charts/viz/vizTheme.d.ts +40 -0
- package/types/src/charts/viz/vizTypes.d.ts +117 -8
- package/types/src/charts/viz/vizVisibility.d.ts +6 -0
- package/types/src/components/Axis/Axis.d.ts +37 -8
- package/types/src/components/Axis/AxisBottom.d.ts +1 -0
- package/types/src/components/Axis/AxisLeft.d.ts +1 -0
- package/types/src/components/Axis/AxisRight.d.ts +1 -0
- package/types/src/components/Axis/AxisTop.d.ts +1 -0
- package/types/src/components/Axis/axisBreak.d.ts +2 -0
- package/types/src/components/Axis/axisLabelAngle.d.ts +110 -0
- package/types/src/components/Axis/axisLabelThinning.d.ts +3 -7
- package/types/src/components/Axis/axisLayout.d.ts +5 -0
- package/types/src/components/Axis/axisLayoutLabels.d.ts +13 -0
- package/types/src/components/Axis/axisRangeBreaks.d.ts +25 -0
- package/types/src/components/Axis/axisRounding.d.ts +6 -3
- package/types/src/components/Axis/axisSlantWrap.d.ts +22 -0
- package/types/src/components/Axis/brokenTimeScale.d.ts +51 -0
- package/types/src/components/Axis/powTicks.d.ts +29 -0
- package/types/src/components/Axis/rangeBreaks.d.ts +82 -0
- package/types/src/components/Axis/timeValues.d.ts +1 -1
- package/types/src/components/ColorScale/ColorScale.d.ts +14 -0
- package/types/src/components/ColorScale/bucketBounds.d.ts +28 -0
- package/types/src/components/ColorScale/colorScaleHoverMark.d.ts +86 -0
- package/types/src/components/ColorScale/colorScaleScale.d.ts +3 -0
- package/types/src/components/ColorScale/colorScaleType.d.ts +17 -0
- package/types/src/components/Legend/Legend.d.ts +1 -0
- package/types/src/components/SizeLegend/SizeLegend.d.ts +1 -0
- package/types/src/components/TextBox.d.ts +1 -0
- package/types/src/components/Timeline/Timeline.d.ts +1 -0
- package/types/src/components/Timeline/brushSpan.d.ts +41 -0
- package/types/src/components/Timeline/timelineConfig.d.ts +11 -0
- package/types/src/components/Timeline/timelineMode.d.ts +17 -0
- package/types/src/components/Timeline/timelineRender.d.ts +8 -0
- package/types/src/components/Tooltip.d.ts +12 -3
- package/types/src/components/fontStack.d.ts +10 -0
- package/types/src/components/textBoxLayout.d.ts +18 -9
- package/types/src/components/textBoxPath.d.ts +59 -0
- package/types/src/components/textBoxScene.d.ts +51 -0
- package/types/src/components/textBoxWords.d.ts +33 -0
- package/types/src/shapes/Area.d.ts +1 -0
- package/types/src/shapes/Bar.d.ts +1 -0
- package/types/src/shapes/Box.d.ts +2 -8
- package/types/src/shapes/Circle.d.ts +1 -0
- package/types/src/shapes/Line.d.ts +1 -0
- package/types/src/shapes/Path.d.ts +1 -0
- package/types/src/shapes/Rect.d.ts +1 -0
- package/types/src/shapes/Shape.d.ts +1 -0
- package/types/src/shapes/Whisker.d.ts +1 -0
- package/types/src/shapes/boxOutlierShape.d.ts +9 -0
- package/types/src/shapes/boxStats.d.ts +19 -0
- package/types/src/shapes/boxStyle.d.ts +25 -0
- package/types/src/shapes/boxSummary.d.ts +66 -0
- package/types/src/shapes/emitLabels.d.ts +1 -1
- package/types/src/shapes/shapeConfig.d.ts +42 -4
- package/types/src/utils/BaseClass.d.ts +32 -0
- package/types/src/utils/D3Scale.d.ts +3 -0
- package/types/src/utils/D3plusConfig.d.ts +1240 -33
- package/types/src/utils/className.d.ts +64 -0
- package/types/src/utils/configPrep.d.ts +2 -0
- package/types/src/utils/configWarnings.d.ts +21 -2
- package/types/src/utils/constant.d.ts +8 -0
- package/types/src/utils/displayName.d.ts +10 -0
- package/types/src/utils/fieldAccessor.d.ts +24 -0
- package/types/src/utils/index.d.ts +1 -1
- package/types/src/utils/paintComponentScene.d.ts +3 -1
- package/types/src/utils/theme.d.ts +170 -0
- package/types/src/utils/themeInk.d.ts +56 -0
- package/umd/d3plus-core.full.js +87388 -56271
- package/umd/d3plus-core.full.min.js +2 -2
- package/umd/d3plus-core.js +37988 -11768
- package/umd/d3plus-core.min.js +2 -2
- package/es/src/components/Axis/gridStroke.js +0 -10
- package/types/src/components/Axis/gridStroke.d.ts +0 -8
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
The marks keyboard navigation moves between, read off a painted scene,
|
|
3
|
+
and the spatial rules for moving from one to the next.
|
|
4
|
+
|
|
5
|
+
@module
|
|
6
|
+
*/ import { mapBox, mapper, ownBoxes } from "../features/sceneBounds.js";
|
|
7
|
+
import { MARK_TYPES } from "./sceneRows.js";
|
|
8
|
+
/** Root groups that hold navigable marks, and the handler group each routes to. */ const ROOT_GROUPS = {
|
|
9
|
+
"viz-chart-cells": "shape",
|
|
10
|
+
"viz-legend": "legend"
|
|
11
|
+
};
|
|
12
|
+
/** Interaction groups that are chart chrome rather than data marks. */ const CHROME_GROUPS = new Set([
|
|
13
|
+
"axis",
|
|
14
|
+
"timeline",
|
|
15
|
+
"trend"
|
|
16
|
+
]);
|
|
17
|
+
/** Whether a node (and everything inside it) is out of keyboard reach. */ function skipped(node) {
|
|
18
|
+
const n = node;
|
|
19
|
+
return String(n.key).endsWith("::hit") || n.interactive === false || !!n.aria?.hidden || n.interactionGroup !== undefined && CHROME_GROUPS.has(n.interactionGroup);
|
|
20
|
+
}
|
|
21
|
+
/** The source row a node's datum wraps, so a mark drawn twice counts once. */ function rowOf(datum) {
|
|
22
|
+
const raw = datum;
|
|
23
|
+
return raw && raw.data ? raw.data : raw;
|
|
24
|
+
}
|
|
25
|
+
/** The box around a list of boxes. */ function union(boxes) {
|
|
26
|
+
const x = Math.min(...boxes.map((b)=>b.x)), y = Math.min(...boxes.map((b)=>b.y));
|
|
27
|
+
const x2 = Math.max(...boxes.map((b)=>b.x + b.width)), y2 = Math.max(...boxes.map((b)=>b.y + b.height));
|
|
28
|
+
return {
|
|
29
|
+
x,
|
|
30
|
+
y,
|
|
31
|
+
width: x2 - x,
|
|
32
|
+
height: y2 - y
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** Whether a point lies within a box, give or take a pixel. */ const inside = ([x, y], b)=>x >= b.x - 1 && x <= b.x + b.width + 1 && y >= b.y - 1 && y <= b.y + b.height + 1;
|
|
36
|
+
const finite = (b)=>[
|
|
37
|
+
b.x,
|
|
38
|
+
b.y,
|
|
39
|
+
b.width,
|
|
40
|
+
b.height
|
|
41
|
+
].every(Number.isFinite);
|
|
42
|
+
/** One target per series point of a Line/Area node. */ function pointTargets(node, chain, group, seen) {
|
|
43
|
+
const map = mapper(chain);
|
|
44
|
+
const out = [];
|
|
45
|
+
(node.interactionPoints || []).forEach((p, pointIndex)=>{
|
|
46
|
+
if (seen.has(p.datum)) return;
|
|
47
|
+
seen.add(p.datum);
|
|
48
|
+
const center = map([
|
|
49
|
+
p.x,
|
|
50
|
+
p.y
|
|
51
|
+
]);
|
|
52
|
+
const box = {
|
|
53
|
+
x: center[0],
|
|
54
|
+
y: center[1],
|
|
55
|
+
width: 0,
|
|
56
|
+
height: 0
|
|
57
|
+
};
|
|
58
|
+
if (!finite(box)) return;
|
|
59
|
+
const id = `${node.key}@${pointIndex}`;
|
|
60
|
+
out.push({
|
|
61
|
+
id,
|
|
62
|
+
node,
|
|
63
|
+
pointIndex,
|
|
64
|
+
center,
|
|
65
|
+
box,
|
|
66
|
+
group,
|
|
67
|
+
chain
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
/** The target for a single mark, or null when it has no finite geometry. */ function markTarget(node, chain, group) {
|
|
73
|
+
const full = node.transform ? [
|
|
74
|
+
...chain,
|
|
75
|
+
node.transform
|
|
76
|
+
] : chain;
|
|
77
|
+
const map = mapper(full);
|
|
78
|
+
const boxes = ownBoxes(node).filter(finite).map((b)=>mapBox(b, map));
|
|
79
|
+
if (!boxes.length) return null;
|
|
80
|
+
const box = union(boxes);
|
|
81
|
+
// A path's boxes are its outline's vertices; their mean sits inside a
|
|
82
|
+
// curved shape (a pie wedge) more often than its bounding box's center.
|
|
83
|
+
const center = node.type === "path" ? [
|
|
84
|
+
boxes.reduce((s, b)=>s + b.x, 0) / boxes.length,
|
|
85
|
+
boxes.reduce((s, b)=>s + b.y, 0) / boxes.length
|
|
86
|
+
] : [
|
|
87
|
+
box.x + box.width / 2,
|
|
88
|
+
box.y + box.height / 2
|
|
89
|
+
];
|
|
90
|
+
return {
|
|
91
|
+
id: String(node.key),
|
|
92
|
+
node,
|
|
93
|
+
center,
|
|
94
|
+
box,
|
|
95
|
+
group,
|
|
96
|
+
chain
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
Sorts targets left to right by their left edge, then top to bottom: bars
|
|
101
|
+
and series points read along the x axis, a stack or a vertical legend
|
|
102
|
+
reads downward, and a treemap starts at its top-left cell.
|
|
103
|
+
*/ export function readingOrder(targets) {
|
|
104
|
+
return [
|
|
105
|
+
...targets
|
|
106
|
+
].sort((a, b)=>Math.round(a.box.x) - Math.round(b.box.x) || Math.round(a.box.y) - Math.round(b.box.y));
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
Every mark keyboard focus can visit in a painted scene, chart marks first
|
|
110
|
+
and then legend items, each in reading order (see `readingOrder`).
|
|
111
|
+
Visits the chart cells and the legend only (not the colorScale, timeline,
|
|
112
|
+
or chrome), skipping `::hit` duplicates, inert or aria-hidden nodes,
|
|
113
|
+
text, axis/trend chrome, nodes without a datum, and marks a rectangular
|
|
114
|
+
clip hides (a zoomed chart's off-screen marks). A Line or Area node
|
|
115
|
+
becomes one target per point, and a row drawn by several nodes counts
|
|
116
|
+
once.
|
|
117
|
+
@param nodes The scene root's children (`viz._paintedScene.root.children`).
|
|
118
|
+
*/ export function focusTargets(nodes) {
|
|
119
|
+
const lists = {
|
|
120
|
+
shape: [],
|
|
121
|
+
legend: []
|
|
122
|
+
};
|
|
123
|
+
for (const top of nodes){
|
|
124
|
+
const group = ROOT_GROUPS[String(top.key)];
|
|
125
|
+
if (!group) continue;
|
|
126
|
+
const seen = new Set();
|
|
127
|
+
const walk = (node, chain, clips)=>{
|
|
128
|
+
if (skipped(node)) return;
|
|
129
|
+
if (node.type === "group") {
|
|
130
|
+
const next = node.transform ? [
|
|
131
|
+
...chain,
|
|
132
|
+
node.transform
|
|
133
|
+
] : chain;
|
|
134
|
+
const clip = node.clip;
|
|
135
|
+
const inner = clip && clip.type === "rect" ? [
|
|
136
|
+
...clips,
|
|
137
|
+
mapBox(clip, mapper(next))
|
|
138
|
+
] : clips;
|
|
139
|
+
for (const child of node.children)walk(child, next, inner);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (!MARK_TYPES.has(node.type) || node.datum === undefined) return;
|
|
143
|
+
if (node.paint?.opacity === 0) return;
|
|
144
|
+
const visible = (t)=>clips.every((c)=>inside(t.center, c));
|
|
145
|
+
if (node.interactionPoints?.length) {
|
|
146
|
+
const points = pointTargets(node, chain, group, seen);
|
|
147
|
+
lists[group].push(...points.filter(visible));
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const row = rowOf(node.datum);
|
|
151
|
+
if (seen.has(row)) return;
|
|
152
|
+
const target = markTarget(node, chain, group);
|
|
153
|
+
if (!target || !visible(target)) return;
|
|
154
|
+
seen.add(row);
|
|
155
|
+
lists[group].push(target);
|
|
156
|
+
};
|
|
157
|
+
walk(top, [], []);
|
|
158
|
+
}
|
|
159
|
+
return [
|
|
160
|
+
...readingOrder(lists.shape),
|
|
161
|
+
...readingOrder(lists.legend)
|
|
162
|
+
];
|
|
163
|
+
}
|
|
164
|
+
/** The vertical (or horizontal) overlap of two boxes, in pixels. */ function overlap(a, b, axis) {
|
|
165
|
+
const size = axis === "x" ? "width" : "height";
|
|
166
|
+
return Math.min(a[axis] + a[size], b[axis] + b[size]) - Math.max(a[axis], b[axis]);
|
|
167
|
+
}
|
|
168
|
+
/** The axis a Line/Area node's points run along: the one they spread farther across. */ function seriesAxis(node) {
|
|
169
|
+
const points = node.interactionPoints || [];
|
|
170
|
+
const spread = (k)=>Math.max(...points.map((p)=>p[k])) - Math.min(...points.map((p)=>p[k]));
|
|
171
|
+
return spread("x") >= spread("y") ? "x" : "y";
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
The target an arrow key moves to from `current`: the nearest one in that
|
|
175
|
+
direction whose center lies within a 45° cone of it, where two marks that
|
|
176
|
+
overlap across the direction of travel (bars sharing a baseline, cells
|
|
177
|
+
in one row) count as level with each other. Without one in the cone, the
|
|
178
|
+
nearest center anywhere in that half-plane. Returns `current` when
|
|
179
|
+
nothing lies that way, and the first target when there is no current
|
|
180
|
+
one. Moving along a series (Line/Area points), its own next point counts
|
|
181
|
+
as level, so the series is followed rather than a neighbor's point.
|
|
182
|
+
*/ export function nextTarget(targets, current, direction) {
|
|
183
|
+
if (!current) return targets[0] ?? null;
|
|
184
|
+
const horizontal = direction === "left" || direction === "right";
|
|
185
|
+
const sign = direction === "right" || direction === "down" ? 1 : -1;
|
|
186
|
+
const across = horizontal ? "y" : "x";
|
|
187
|
+
const alongSeries = current.pointIndex !== undefined && seriesAxis(current.node) === (horizontal ? "x" : "y");
|
|
188
|
+
let cone = null, coneScore = Infinity;
|
|
189
|
+
let plane = null, planeScore = Infinity;
|
|
190
|
+
for (const t of targets){
|
|
191
|
+
if (t.id === current.id) continue;
|
|
192
|
+
const dx = t.center[0] - current.center[0], dy = t.center[1] - current.center[1];
|
|
193
|
+
const ahead = sign * (horizontal ? dx : dy);
|
|
194
|
+
if (ahead <= 0.5) continue;
|
|
195
|
+
const level = alongSeries && t.node === current.node || overlap(t.box, current.box, across) > 0;
|
|
196
|
+
const side = level ? 0 : Math.abs(horizontal ? dy : dx);
|
|
197
|
+
if (side <= ahead && ahead + 2 * side < coneScore) {
|
|
198
|
+
cone = t;
|
|
199
|
+
coneScore = ahead + 2 * side;
|
|
200
|
+
}
|
|
201
|
+
const dist = Math.hypot(dx, dy);
|
|
202
|
+
if (dist < planeScore) {
|
|
203
|
+
plane = t;
|
|
204
|
+
planeScore = dist;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return cone ?? plane ?? current;
|
|
208
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Group rows: a row a chart draws for a whole group at a shallower `groupBy`
|
|
3
|
+
level than its marks (a Treemap's group header), merged from every row in
|
|
4
|
+
that group and stamped with its level under `GROUP_DEPTH_KEY`. Labels,
|
|
5
|
+
hover, and clicks read that level in place of the chart's drawn depth.
|
|
6
|
+
*/ /** The row key holding a group row's `groupBy` level. */ export const GROUP_DEPTH_KEY = "__d3plusGroupDepth";
|
|
7
|
+
/** The row key holding a group row's own label, when its chart sets one. */ export const GROUP_LABEL_KEY = "__d3plusGroupLabel";
|
|
8
|
+
/** The source row a datum wraps (a label record, or a laid-out node). */ function unwrap(d) {
|
|
9
|
+
let row = d;
|
|
10
|
+
while(row && row.__d3plus__ && row.data)row = row.data;
|
|
11
|
+
return row;
|
|
12
|
+
}
|
|
13
|
+
/** The `groupBy` level a group row stands for, or undefined for any other row. */ export function groupDepthOf(d) {
|
|
14
|
+
const row = unwrap(d);
|
|
15
|
+
const depth = row ? row[GROUP_DEPTH_KEY] : undefined;
|
|
16
|
+
return typeof depth === "number" ? depth : undefined;
|
|
17
|
+
}
|
|
18
|
+
/** A group row's key at each `groupBy` level, from the first down to its own. */ export function groupPath(groupBy, d, depth) {
|
|
19
|
+
const row = unwrap(d);
|
|
20
|
+
return groupBy.slice(0, depth + 1).map((g)=>g(row, 0));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
Whether `d` belongs to the group at `path`: its key at each of the path's
|
|
24
|
+
levels is the group's, or for a merged row holds it.
|
|
25
|
+
*/ export function inGroup(groupBy, path, d, i) {
|
|
26
|
+
const row = unwrap(d);
|
|
27
|
+
if (!row) return false;
|
|
28
|
+
return path.every((key, j)=>{
|
|
29
|
+
const value = groupBy[j](row, i);
|
|
30
|
+
return value === key || Array.isArray(value) && value.includes(key);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** Whether `rows` hold any row outside the group at `path`, so zooming into it narrows the view. */ export function groupNarrows(groupBy, path, rows) {
|
|
34
|
+
return rows.some((d, i)=>!inGroup(groupBy, path, d, i));
|
|
35
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
The chart's Back history (`viz._history`): one stack holding drill-downs
|
|
3
|
+
and legend hide/solo clicks in the order they happened, so Back undoes
|
|
4
|
+
them in reverse.
|
|
5
|
+
*/ /** Whether a Back history entry records a legend click. */ export function isLegendEntry(entry) {
|
|
6
|
+
return entry.kind === "legend";
|
|
7
|
+
}
|
|
8
|
+
/** The newest drill-down entry on a Back history, skipping legend entries. */ export function latestDrillEntry(history) {
|
|
9
|
+
if (!history) return undefined;
|
|
10
|
+
for(let i = history.length - 1; i >= 0; i--){
|
|
11
|
+
const entry = history[i];
|
|
12
|
+
if (!isLegendEntry(entry)) return entry;
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
/** Removes and returns the newest drill-down entry, leaving the legend entries around it in place. */ export function removeLatestDrillEntry(history) {
|
|
17
|
+
const entry = latestDrillEntry(history);
|
|
18
|
+
if (entry) history.splice(history.lastIndexOf(entry), 1);
|
|
19
|
+
return entry;
|
|
20
|
+
}
|
|
21
|
+
/** Whether two legend id lists hold the same ids, in any order. */ export function sameLegendIds(a, b) {
|
|
22
|
+
return a.length === b.length && a.every((id)=>b.includes(id));
|
|
23
|
+
}
|
|
24
|
+
/** The chart's current legend hide/solo state, as a Back history entry. */ export function legendSnapshot(viz) {
|
|
25
|
+
return {
|
|
26
|
+
kind: "legend",
|
|
27
|
+
hidden: [
|
|
28
|
+
...viz._hidden
|
|
29
|
+
],
|
|
30
|
+
solo: [
|
|
31
|
+
...viz._solo
|
|
32
|
+
]
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
Records a legend click on the Back history: pushes `before` (the state
|
|
37
|
+
the click started from) when the click changed what is hidden or solo'd
|
|
38
|
+
and `legendHistory` is on. Returns whether it pushed.
|
|
39
|
+
*/ export function recordLegendChange(viz, before) {
|
|
40
|
+
if (!viz.schema.legendHistory) return false;
|
|
41
|
+
if (sameLegendIds(before.hidden, viz._hidden) && sameLegendIds(before.solo, viz._solo)) return false;
|
|
42
|
+
(viz._history ??= []).push(before);
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
/** Puts back the legend state a history entry recorded. */ export function restoreLegendEntry(viz, entry) {
|
|
46
|
+
viz._hidden = [
|
|
47
|
+
...entry.hidden
|
|
48
|
+
];
|
|
49
|
+
viz._solo = [
|
|
50
|
+
...entry.solo
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
Clears the legend's hide/solo state for a drill to a deeper level, whose
|
|
55
|
+
legend lists other groups, and returns the state it cleared for the
|
|
56
|
+
drill's history entry (undefined when nothing was hidden or solo'd).
|
|
57
|
+
*/ export function takeLegendState(viz) {
|
|
58
|
+
if (!viz._hidden.length && !viz._solo.length) return undefined;
|
|
59
|
+
const state = {
|
|
60
|
+
hidden: viz._hidden,
|
|
61
|
+
solo: viz._solo
|
|
62
|
+
};
|
|
63
|
+
viz._hidden = [];
|
|
64
|
+
viz._solo = [];
|
|
65
|
+
return state;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
Drops the legend's steps from the Back history: every legend entry, and
|
|
69
|
+
the legend state drill-down entries would put back. The drill-downs stay.
|
|
70
|
+
*/ export function dropLegendHistory(viz) {
|
|
71
|
+
if (!viz._history) return;
|
|
72
|
+
viz._history = viz._history.filter((e)=>!isLegendEntry(e));
|
|
73
|
+
for (const entry of viz._history)delete entry.legend;
|
|
74
|
+
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/ import { color } from "d3-color";
|
|
11
11
|
import { colorGrayscale } from "@d3plus/color";
|
|
12
12
|
import { activeBucketColors } from "../features/colorScaleBucket.js";
|
|
13
|
+
import { hoveredSwatch } from "../features/colorScaleHover.js";
|
|
13
14
|
import { MARK_TYPES } from "./sceneRows.js";
|
|
14
15
|
/** z value that floats a hovered/highlighted node above its (z-less, i.e. 0) siblings. */ const HOVER_RAISE_Z = 1e6;
|
|
15
16
|
/**
|
|
@@ -73,11 +74,24 @@ import { MARK_TYPES } from "./sceneRows.js";
|
|
|
73
74
|
by its bucket COLOR, not by id/value — so this only touches those nodes and
|
|
74
75
|
leaves the colorScale title/axis/gradient at full opacity. A swatch stays
|
|
75
76
|
bright when its color is "active" (its range contains a datum matching the
|
|
76
|
-
current hover); every other swatch dims.
|
|
77
|
+
current hover); every other swatch dims. A chart without a hover
|
|
78
|
+
predicate of its own (shape hover off) lights the swatch of the value
|
|
79
|
+
its colorScale marks (see `hoveredSwatch`). No-op when nothing is hovered.
|
|
77
80
|
*/ export function applyColorScaleBucketOpacity(nodes, viz) {
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
const swatch = hoveredSwatch(viz);
|
|
82
|
+
let activeColors;
|
|
83
|
+
let dimOpacity;
|
|
84
|
+
if (swatch) {
|
|
85
|
+
activeColors = new Set([
|
|
86
|
+
swatch.color
|
|
87
|
+
]);
|
|
88
|
+
dimOpacity = swatch.dimOpacity;
|
|
89
|
+
} else {
|
|
90
|
+
const settings = dimSettings(viz);
|
|
91
|
+
if (!settings) return nodes;
|
|
92
|
+
activeColors = activeBucketColors(viz, settings.predicate);
|
|
93
|
+
dimOpacity = settings.dimOpacity;
|
|
94
|
+
}
|
|
81
95
|
if (!activeColors) return nodes;
|
|
82
96
|
const walk = (node)=>{
|
|
83
97
|
let next = node;
|
|
@@ -91,7 +105,7 @@ import { MARK_TYPES } from "./sceneRows.js";
|
|
|
91
105
|
...node,
|
|
92
106
|
paint: {
|
|
93
107
|
...node.paint ?? {},
|
|
94
|
-
opacity: base *
|
|
108
|
+
opacity: base * dimOpacity
|
|
95
109
|
}
|
|
96
110
|
};
|
|
97
111
|
}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Keyboard navigation between a chart's data marks (`keyboardNav`). The
|
|
3
|
+
chart is one Tab stop: a focusable host beside its root svg (see
|
|
4
|
+
`keyboardNavHost.ts`). Arrow keys move between marks spatially, and each
|
|
5
|
+
move is replayed through the pointer bridge as the events a mouse would
|
|
6
|
+
send over that mark, so tooltips, hover highlights, the shared tooltip,
|
|
7
|
+
click handlers, and drill-down all behave as they do for the pointer.
|
|
8
|
+
|
|
9
|
+
@module
|
|
10
|
+
*/ import { backgroundInk, chartBackground } from "./backgroundInk.js";
|
|
11
|
+
import { focusRingNode } from "./focusRing.js";
|
|
12
|
+
import { focusTargets, nextTarget } from "./focusTargets.js";
|
|
13
|
+
import { createKeyboardNavHost, updateKeyboardNavHost } from "./keyboardNavHost.js";
|
|
14
|
+
import { handlerDatum } from "./shapeClassTargets.js";
|
|
15
|
+
/** Arrow keys and the direction each moves. */ const ARROWS = {
|
|
16
|
+
ArrowUp: "up",
|
|
17
|
+
ArrowDown: "down",
|
|
18
|
+
ArrowLeft: "left",
|
|
19
|
+
ArrowRight: "right"
|
|
20
|
+
};
|
|
21
|
+
/** The targets in the scene last painted. */ function paintedTargets(viz) {
|
|
22
|
+
return focusTargets(viz._paintedScene?.root.children ?? []);
|
|
23
|
+
}
|
|
24
|
+
/** The focused target in `targets`, if it is still there. */ function currentTarget(state, targets) {
|
|
25
|
+
return targets.find((t)=>t.id === state.current) ?? null;
|
|
26
|
+
}
|
|
27
|
+
/** The source row and index a target reports to handlers. */ function targetRow(target) {
|
|
28
|
+
const { node, pointIndex } = target;
|
|
29
|
+
const point = pointIndex !== undefined ? node.interactionPoints?.[pointIndex] : undefined;
|
|
30
|
+
return point ? handlerDatum(point.datum, point.index) : handlerDatum(node.datum, node.index ?? 0);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
What the live region announces for a target: a series point's label from
|
|
34
|
+
the chart's `ariaLabel` accessor, a mark's own `aria-label`, or else its
|
|
35
|
+
label as the tooltip titles it.
|
|
36
|
+
*/ export function targetLabel(viz, target) {
|
|
37
|
+
const { node, pointIndex } = target;
|
|
38
|
+
const point = pointIndex !== undefined ? node.interactionPoints?.[pointIndex] : undefined;
|
|
39
|
+
if (point) {
|
|
40
|
+
const config = viz.schema.shapeConfig || {};
|
|
41
|
+
const accessor = node.shapeType && config[node.shapeType]?.ariaLabel || config.ariaLabel;
|
|
42
|
+
if (typeof accessor === "function") {
|
|
43
|
+
try {
|
|
44
|
+
const { d, i } = targetRow(target);
|
|
45
|
+
const label = accessor(d, i);
|
|
46
|
+
if (label) return String(label);
|
|
47
|
+
} catch {
|
|
48
|
+
// Falls back to the point's label below.
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
} else if (node.aria?.label) return node.aria.label;
|
|
52
|
+
const { d, i } = targetRow(target);
|
|
53
|
+
return d === undefined ? "" : String(viz._drawLabel(d, i) ?? "");
|
|
54
|
+
}
|
|
55
|
+
/** The focus ring's style for a target, from `keyboardNavConfig`. */ export function focusRingStyle(viz, target) {
|
|
56
|
+
const config = viz.schema.keyboardNavConfig || {};
|
|
57
|
+
const { d, i } = targetRow(target);
|
|
58
|
+
const value = (v, fallback)=>{
|
|
59
|
+
const out = typeof v === "function" ? v(d, i) : v;
|
|
60
|
+
return out === undefined || out === null ? fallback : out;
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
stroke: value(config.stroke, backgroundInk(viz)),
|
|
64
|
+
strokeWidth: value(config.strokeWidth, 2),
|
|
65
|
+
padding: value(config.padding, 2),
|
|
66
|
+
halo: chartBackground(viz)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** Runs `fn` now, or once a running transition settles (the bridge drops events until then). */ function whenSettled(viz, state, fn) {
|
|
70
|
+
state.queue.push(fn);
|
|
71
|
+
if (state.timer !== undefined) return;
|
|
72
|
+
const flush = ()=>{
|
|
73
|
+
state.timer = undefined;
|
|
74
|
+
const wait = (viz._transitionEndsAt ?? 0) - Date.now();
|
|
75
|
+
if (wait > 0) {
|
|
76
|
+
state.timer = setTimeout(flush, wait + 5);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const queue = state.queue.splice(0);
|
|
80
|
+
for (const run of queue)run();
|
|
81
|
+
};
|
|
82
|
+
flush();
|
|
83
|
+
}
|
|
84
|
+
/** Sends one replayed pointer event over `target` (or a leave) through the bridge. */ function send(viz, type, target, init = {}) {
|
|
85
|
+
const at = target ?? init.at;
|
|
86
|
+
const point = at ? [
|
|
87
|
+
...at.center
|
|
88
|
+
] : [
|
|
89
|
+
0,
|
|
90
|
+
0
|
|
91
|
+
];
|
|
92
|
+
const svg = viz._select?.node?.();
|
|
93
|
+
const rect = svg?.getBoundingClientRect?.() ?? {
|
|
94
|
+
left: 0,
|
|
95
|
+
top: 0
|
|
96
|
+
};
|
|
97
|
+
const nativeEvent = new MouseEvent(init.nativeType ?? type, {
|
|
98
|
+
clientX: rect.left + point[0],
|
|
99
|
+
clientY: rect.top + point[1],
|
|
100
|
+
shiftKey: !!init.shiftKey
|
|
101
|
+
});
|
|
102
|
+
const pick = target ? {
|
|
103
|
+
node: target.node,
|
|
104
|
+
datum: target.node.datum,
|
|
105
|
+
index: target.node.index
|
|
106
|
+
} : null;
|
|
107
|
+
const event = {
|
|
108
|
+
type,
|
|
109
|
+
point,
|
|
110
|
+
pick,
|
|
111
|
+
nativeEvent
|
|
112
|
+
};
|
|
113
|
+
viz._routeSceneEvent?.(event);
|
|
114
|
+
}
|
|
115
|
+
/** Replays the pointer moving onto `target`, leaving the mark it was over. */ function hover(viz, state, t) {
|
|
116
|
+
const prev = state.hovered;
|
|
117
|
+
if (!prev || prev.node.key !== t.node.key) {
|
|
118
|
+
if (prev) send(viz, "mouseleave", null, {
|
|
119
|
+
nativeType: "mousemove",
|
|
120
|
+
at: t
|
|
121
|
+
});
|
|
122
|
+
send(viz, "mouseenter", t);
|
|
123
|
+
}
|
|
124
|
+
send(viz, "mousemove", t);
|
|
125
|
+
state.hovered = t;
|
|
126
|
+
}
|
|
127
|
+
/** Replays the pointer leaving the chart. */ function leave(viz, state) {
|
|
128
|
+
const prev = state.hovered;
|
|
129
|
+
if (!prev) return;
|
|
130
|
+
state.hovered = null;
|
|
131
|
+
send(viz, "mouseleave", null, {
|
|
132
|
+
at: prev
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/** Outlines the host itself while it has keyboard focus but no mark does. */ function updateOutline(viz, state) {
|
|
136
|
+
const { host } = state;
|
|
137
|
+
let visible = host.ownerDocument.activeElement === host && !state.current;
|
|
138
|
+
if (visible) {
|
|
139
|
+
try {
|
|
140
|
+
visible = host.matches(":focus-visible");
|
|
141
|
+
} catch {
|
|
142
|
+
// Without :focus-visible support, any focus shows the outline.
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
host.style.outline = visible ? `2px solid ${backgroundInk(viz)}` : "none";
|
|
146
|
+
host.style.outlineOffset = visible ? "-2px" : "";
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
Focuses `target`: announces it, replays the hover over it, and redraws
|
|
150
|
+
the ring (unless the paint that called this already drew it).
|
|
151
|
+
*/ function focusOn(viz, state, target, repaint = true) {
|
|
152
|
+
state.current = target.id;
|
|
153
|
+
state.chartScene = viz._chartScene;
|
|
154
|
+
state.zoom = viz._zoomTransform;
|
|
155
|
+
const label = targetLabel(viz, target);
|
|
156
|
+
if (state.live.textContent !== label) state.live.textContent = label;
|
|
157
|
+
whenSettled(viz, state, ()=>{
|
|
158
|
+
hover(viz, state, target);
|
|
159
|
+
if (repaint) viz._scheduleSceneRepaint();
|
|
160
|
+
});
|
|
161
|
+
updateOutline(viz, state);
|
|
162
|
+
}
|
|
163
|
+
/** Clears the focused mark (Escape, blur): its hover, tooltip, and ring. */ function clearFocus(viz, state) {
|
|
164
|
+
const had = state.current !== null;
|
|
165
|
+
state.current = null;
|
|
166
|
+
whenSettled(viz, state, ()=>{
|
|
167
|
+
leave(viz, state);
|
|
168
|
+
if (had) viz._scheduleSceneRepaint();
|
|
169
|
+
});
|
|
170
|
+
updateOutline(viz, state);
|
|
171
|
+
}
|
|
172
|
+
/** Where a movement key goes (arrows, Home, End), or undefined for any other key. */ function moveTarget(key, targets, current) {
|
|
173
|
+
if (ARROWS[key]) return nextTarget(targets, current, ARROWS[key]);
|
|
174
|
+
if (key === "Home") return targets[0] ?? null;
|
|
175
|
+
if (key === "End") return targets[targets.length - 1] ?? null;
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
/** The keydown handler: the chart's own keys, then arrows, Home/End, Enter/Space, and Escape. */ function onKeydown(viz, state, e) {
|
|
179
|
+
const event = e;
|
|
180
|
+
if (event.altKey || event.ctrlKey || event.metaKey) return;
|
|
181
|
+
if (viz._keyboardGesture?.keydown(event)) {
|
|
182
|
+
event.preventDefault();
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const { key } = event;
|
|
186
|
+
const targets = paintedTargets(viz);
|
|
187
|
+
const current = currentTarget(state, targets);
|
|
188
|
+
const next = moveTarget(key, targets, current);
|
|
189
|
+
if (next !== undefined) {
|
|
190
|
+
event.preventDefault();
|
|
191
|
+
if (next) focusOn(viz, state, next);
|
|
192
|
+
} else if (current && (key === "Enter" || key === " ")) {
|
|
193
|
+
event.preventDefault();
|
|
194
|
+
const shiftKey = event.shiftKey;
|
|
195
|
+
whenSettled(viz, state, ()=>{
|
|
196
|
+
hover(viz, state, current);
|
|
197
|
+
send(viz, "click", current, {
|
|
198
|
+
shiftKey
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
} else if (current && key === "Escape") {
|
|
202
|
+
event.preventDefault();
|
|
203
|
+
clearFocus(viz, state);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/** Focusing the chart focuses its first mark. */ function onFocus(viz, state) {
|
|
207
|
+
if (!state.current) {
|
|
208
|
+
const first = paintedTargets(viz)[0];
|
|
209
|
+
if (first) focusOn(viz, state, first);
|
|
210
|
+
}
|
|
211
|
+
updateOutline(viz, state);
|
|
212
|
+
}
|
|
213
|
+
/** The element the host is placed in: the root svg's parent, when it is HTML. */ function hostParent(viz) {
|
|
214
|
+
const svg = viz._select?.node?.();
|
|
215
|
+
const parent = svg?.parentNode;
|
|
216
|
+
if (!parent || parent.nodeType !== 1) return null;
|
|
217
|
+
return parent.namespaceURI === "http://www.w3.org/1999/xhtml" ? parent : null;
|
|
218
|
+
}
|
|
219
|
+
/** Removes the host and its listeners, clearing any replayed hover. */ export function teardownKeyboardNav(viz) {
|
|
220
|
+
const state = viz._keyboardNav;
|
|
221
|
+
if (!state) return;
|
|
222
|
+
viz._keyboardNav = undefined;
|
|
223
|
+
if (state.timer !== undefined) clearTimeout(state.timer);
|
|
224
|
+
state.queue = [];
|
|
225
|
+
leave(viz, state);
|
|
226
|
+
for (const [type, fn] of state.listeners)state.host.removeEventListener(type, fn);
|
|
227
|
+
state.host.remove();
|
|
228
|
+
}
|
|
229
|
+
/** Creates the host and binds its listeners. */ function installKeyboardNav(viz, parent) {
|
|
230
|
+
const state = {
|
|
231
|
+
...createKeyboardNavHost(parent, viz._uuid),
|
|
232
|
+
current: null,
|
|
233
|
+
hovered: null,
|
|
234
|
+
stale: false,
|
|
235
|
+
queue: [],
|
|
236
|
+
listeners: []
|
|
237
|
+
};
|
|
238
|
+
state.listeners = [
|
|
239
|
+
[
|
|
240
|
+
"keydown",
|
|
241
|
+
(e)=>onKeydown(viz, state, e)
|
|
242
|
+
],
|
|
243
|
+
[
|
|
244
|
+
"focus",
|
|
245
|
+
()=>onFocus(viz, state)
|
|
246
|
+
],
|
|
247
|
+
[
|
|
248
|
+
"blur",
|
|
249
|
+
()=>clearFocus(viz, state)
|
|
250
|
+
]
|
|
251
|
+
];
|
|
252
|
+
for (const [type, fn] of state.listeners)state.host.addEventListener(type, fn);
|
|
253
|
+
return state;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
Brings the host in line with the chart after a paint: creates it (or
|
|
257
|
+
removes it under `keyboardNav(false)`), refreshes its name and box, and
|
|
258
|
+
re-enters the focused mark when a redraw moved or replaced it.
|
|
259
|
+
*/ export function syncKeyboardNav(viz) {
|
|
260
|
+
const parent = viz.schema.keyboardNav ? hostParent(viz) : null;
|
|
261
|
+
if (!parent) {
|
|
262
|
+
teardownKeyboardNav(viz);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
let state = viz._keyboardNav;
|
|
266
|
+
if (state && state.host.parentNode !== parent) {
|
|
267
|
+
teardownKeyboardNav(viz);
|
|
268
|
+
state = undefined;
|
|
269
|
+
}
|
|
270
|
+
if (!state) state = viz._keyboardNav = installKeyboardNav(viz, parent);
|
|
271
|
+
updateKeyboardNavHost(viz, state);
|
|
272
|
+
const moved = viz._chartScene !== state.chartScene || viz._zoomTransform !== state.zoom;
|
|
273
|
+
if (state.current && moved) state.stale = true;
|
|
274
|
+
if (state.stale) {
|
|
275
|
+
state.stale = false;
|
|
276
|
+
const target = state.current ? currentTarget(state, paintedTargets(viz)) : null;
|
|
277
|
+
if (target) focusOn(viz, state, target, false);
|
|
278
|
+
else clearFocus(viz, state);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
The focus ring for the scene being built, appended last so it draws above
|
|
283
|
+
everything. Resolves the focused mark by its id in `children`, falling
|
|
284
|
+
back to the first mark when a redraw removed it (and marking the state
|
|
285
|
+
stale so `syncKeyboardNav` re-enters it).
|
|
286
|
+
*/ export function appendFocusRing(viz, children) {
|
|
287
|
+
const state = viz._keyboardNav;
|
|
288
|
+
if (!state || !state.current) return;
|
|
289
|
+
const targets = focusTargets(children);
|
|
290
|
+
let target = currentTarget(state, targets);
|
|
291
|
+
if (!target) {
|
|
292
|
+
target = targets[0] ?? null;
|
|
293
|
+
state.current = target ? target.id : null;
|
|
294
|
+
state.stale = true;
|
|
295
|
+
}
|
|
296
|
+
if (target) children.push(focusRingNode(target, focusRingStyle(viz, target)));
|
|
297
|
+
}
|