@d3plus/core 3.1.6 → 4.0.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 +9922 -78537
- package/es/index.js +8 -0
- package/es/index.js.map +1 -1
- package/es/internal.js +54 -0
- package/es/internal.js.map +1 -0
- package/es/src/charts/AreaPlot/index.js +36 -0
- package/es/src/charts/AreaPlot/index.js.map +1 -0
- package/es/src/charts/BarChart/index.js +48 -0
- package/es/src/charts/BarChart/index.js.map +1 -0
- package/es/src/charts/BoxWhisker/index.js +52 -0
- package/es/src/charts/BoxWhisker/index.js.map +1 -0
- package/es/src/charts/BumpChart/index.js +81 -0
- package/es/src/charts/BumpChart/index.js.map +1 -0
- package/es/src/charts/Donut/index.js +42 -0
- package/es/src/charts/Donut/index.js.map +1 -0
- package/es/src/charts/Geomap/applyLayout.js +208 -0
- package/es/src/charts/Geomap/applyLayout.js.map +1 -0
- package/es/src/charts/Geomap/emit.js +169 -0
- package/es/src/charts/Geomap/emit.js.map +1 -0
- package/es/src/charts/Geomap/index.js +521 -0
- package/es/src/charts/Geomap/index.js.map +1 -0
- package/es/src/charts/LinePlot/index.js +32 -0
- package/es/src/charts/LinePlot/index.js.map +1 -0
- package/es/src/charts/Matrix/applyLayout.js +92 -0
- package/es/src/charts/Matrix/applyLayout.js.map +1 -0
- package/es/src/charts/Matrix/emit.js +44 -0
- package/es/src/charts/Matrix/emit.js.map +1 -0
- package/es/src/charts/Matrix/index.js +154 -0
- package/es/src/charts/Matrix/index.js.map +1 -0
- package/es/src/charts/Network/applyLayout.js +322 -0
- package/es/src/charts/Network/applyLayout.js.map +1 -0
- package/es/src/charts/Network/emit.js +273 -0
- package/es/src/charts/Network/emit.js.map +1 -0
- package/es/src/charts/Network/index.js +422 -0
- package/es/src/charts/Network/index.js.map +1 -0
- package/es/src/charts/Pack/applyLayout.js +46 -0
- package/es/src/charts/Pack/applyLayout.js.map +1 -0
- package/es/src/charts/Pack/emit.js +116 -0
- package/es/src/charts/Pack/emit.js.map +1 -0
- package/es/src/charts/Pack/index.js +194 -0
- package/es/src/charts/Pack/index.js.map +1 -0
- package/es/src/charts/Pack/recursionCircles.js +18 -0
- package/es/src/charts/Pack/recursionCircles.js.map +1 -0
- package/es/src/charts/Pie/applyLayout.js +44 -0
- package/es/src/charts/Pie/applyLayout.js.map +1 -0
- package/es/src/charts/Pie/emit.js +111 -0
- package/es/src/charts/Pie/emit.js.map +1 -0
- package/es/src/charts/Pie/index.js +134 -0
- package/es/src/charts/Pie/index.js.map +1 -0
- package/es/src/charts/Plot/draw.js +424 -0
- package/es/src/charts/Plot/draw.js.map +1 -0
- package/es/src/charts/Plot/index.js +827 -0
- package/es/src/charts/Plot/index.js.map +1 -0
- package/es/src/charts/Plot/labelPlacement.js +36 -0
- package/es/src/charts/Plot/labelPlacement.js.map +1 -0
- package/es/src/charts/Plot/pipeline.js +594 -0
- package/es/src/charts/Plot/pipeline.js.map +1 -0
- package/es/src/charts/Plot/pipelineDomains.js +254 -0
- package/es/src/charts/Plot/pipelineDomains.js.map +1 -0
- package/es/src/charts/Plot/pipelineLineLabels.js +210 -0
- package/es/src/charts/Plot/pipelineLineLabels.js.map +1 -0
- package/es/src/charts/Plot/shapeDefaults.js +189 -0
- package/es/src/charts/Plot/shapeDefaults.js.map +1 -0
- package/es/src/charts/Plot/stackHelpers.js +52 -0
- package/es/src/charts/Plot/stackHelpers.js.map +1 -0
- package/es/src/charts/Priestley/applyLayout.js +121 -0
- package/es/src/charts/Priestley/applyLayout.js.map +1 -0
- package/es/src/charts/Priestley/emit.js +129 -0
- package/es/src/charts/Priestley/emit.js.map +1 -0
- package/es/src/charts/Priestley/index.js +97 -0
- package/es/src/charts/Priestley/index.js.map +1 -0
- package/es/src/charts/Radar/applyLayout.js +326 -0
- package/es/src/charts/Radar/applyLayout.js.map +1 -0
- package/es/src/charts/Radar/emit.js +28 -0
- package/es/src/charts/Radar/emit.js.map +1 -0
- package/es/src/charts/Radar/index.js +98 -0
- package/es/src/charts/Radar/index.js.map +1 -0
- package/es/src/charts/RadialMatrix/applyLayout.js +132 -0
- package/es/src/charts/RadialMatrix/applyLayout.js.map +1 -0
- package/es/src/charts/RadialMatrix/emit.js +33 -0
- package/es/src/charts/RadialMatrix/emit.js.map +1 -0
- package/es/src/charts/RadialMatrix/index.js +144 -0
- package/es/src/charts/RadialMatrix/index.js.map +1 -0
- package/es/src/charts/Rings/applyLayout.js +508 -0
- package/es/src/charts/Rings/applyLayout.js.map +1 -0
- package/es/src/charts/Rings/emit.js +222 -0
- package/es/src/charts/Rings/emit.js.map +1 -0
- package/es/src/charts/Rings/index.js +245 -0
- package/es/src/charts/Rings/index.js.map +1 -0
- package/es/src/charts/Sankey/applyLayout.js +107 -0
- package/es/src/charts/Sankey/applyLayout.js.map +1 -0
- package/es/src/charts/Sankey/emit.js +134 -0
- package/es/src/charts/Sankey/emit.js.map +1 -0
- package/es/src/charts/Sankey/index.js +219 -0
- package/es/src/charts/Sankey/index.js.map +1 -0
- package/es/src/charts/StackedArea/index.js +27 -0
- package/es/src/charts/StackedArea/index.js.map +1 -0
- package/es/src/charts/Tree/applyLayout.js +233 -0
- package/es/src/charts/Tree/applyLayout.js.map +1 -0
- package/es/src/charts/Tree/emit.js +257 -0
- package/es/src/charts/Tree/emit.js.map +1 -0
- package/es/src/charts/Tree/index.js +105 -0
- package/es/src/charts/Tree/index.js.map +1 -0
- package/es/src/charts/Treemap/applyLayout.js +85 -0
- package/es/src/charts/Treemap/applyLayout.js.map +1 -0
- package/es/src/charts/Treemap/emit.js +141 -0
- package/es/src/charts/Treemap/emit.js.map +1 -0
- package/es/src/charts/Treemap/index.js +177 -0
- package/es/src/charts/Treemap/index.js.map +1 -0
- package/es/src/charts/Treemap/thresholdFunction.js +112 -0
- package/es/src/charts/Treemap/thresholdFunction.js.map +1 -0
- package/es/src/charts/definition/ChartDefinition.js +12 -0
- package/es/src/charts/definition/ChartDefinition.js.map +1 -0
- package/es/src/charts/definition/applyDefinition.js +107 -0
- package/es/src/charts/definition/applyDefinition.js.map +1 -0
- package/es/src/charts/definition/makeChart.js +153 -0
- package/es/src/charts/definition/makeChart.js.map +1 -0
- package/es/src/charts/drawSteps/zoomControls.js +231 -96
- package/es/src/charts/drawSteps/zoomControls.js.map +1 -1
- package/es/src/charts/events/click.legend.js +2 -2
- package/es/src/charts/events/click.legend.js.map +1 -1
- package/es/src/charts/events/click.shape.js +5 -5
- package/es/src/charts/events/click.shape.js.map +1 -1
- package/es/src/charts/events/mouseenter.js +20 -1
- package/es/src/charts/events/mouseenter.js.map +1 -1
- package/es/src/charts/events/mouseleave.js +19 -4
- package/es/src/charts/events/mouseleave.js.map +1 -1
- package/es/src/charts/events/mousemove.legend.js +10 -10
- package/es/src/charts/events/mousemove.legend.js.map +1 -1
- package/es/src/charts/events/mousemove.shape.js +14 -8
- package/es/src/charts/events/mousemove.shape.js.map +1 -1
- package/es/src/charts/events/touchstart.body.js.map +1 -1
- package/es/src/charts/features/axes.js +432 -0
- package/es/src/charts/features/axes.js.map +1 -0
- package/es/src/charts/features/chartGeometry.js +66 -0
- package/es/src/charts/features/chartGeometry.js.map +1 -0
- package/es/src/charts/features/colorScaleBucket.js +92 -0
- package/es/src/charts/features/colorScaleBucket.js.map +1 -0
- package/es/src/charts/features/emitHelpers.js +217 -0
- package/es/src/charts/features/emitHelpers.js.map +1 -0
- package/es/src/charts/features/ensureZoomDom.js +71 -0
- package/es/src/charts/features/ensureZoomDom.js.map +1 -0
- package/es/src/charts/features/features.js +650 -0
- package/es/src/charts/features/features.js.map +1 -0
- package/es/src/charts/features/featuresLegend.js +180 -0
- package/es/src/charts/features/featuresLegend.js.map +1 -0
- package/es/src/charts/features/legendLabel.js +12 -0
- package/es/src/charts/features/legendLabel.js.map +1 -0
- package/es/src/charts/features/lineLabels.js +154 -0
- package/es/src/charts/features/lineLabels.js.map +1 -0
- package/es/src/charts/features/plotPaint.js +512 -0
- package/es/src/charts/features/plotPaint.js.map +1 -0
- package/es/src/charts/features/shapeEmit.js +273 -0
- package/es/src/charts/features/shapeEmit.js.map +1 -0
- package/es/src/charts/helpers/matrixData.js +3 -3
- package/es/src/charts/helpers/matrixData.js.map +1 -1
- package/es/src/charts/index.js +21 -21
- package/es/src/charts/index.js.map +1 -1
- package/es/src/charts/pipeline/resolveSpec.js +44 -0
- package/es/src/charts/pipeline/resolveSpec.js.map +1 -0
- package/es/src/charts/pipeline/runChartDraw.js +109 -0
- package/es/src/charts/pipeline/runChartDraw.js.map +1 -0
- package/es/src/charts/pipeline/runVizPipeline.js +84 -0
- package/es/src/charts/pipeline/runVizPipeline.js.map +1 -0
- package/es/src/charts/pipeline/stages.js +103 -0
- package/es/src/charts/pipeline/stages.js.map +1 -0
- package/es/src/charts/pipeline/vizContext.js +29 -0
- package/es/src/charts/pipeline/vizContext.js.map +1 -0
- package/es/src/charts/pipeline/vizDraw.js +37 -0
- package/es/src/charts/pipeline/vizDraw.js.map +1 -0
- package/es/src/charts/pipeline/vizDrawPure.js +174 -0
- package/es/src/charts/pipeline/vizDrawPure.js.map +1 -0
- package/es/src/charts/pipeline/vizPreDraw.js +145 -0
- package/es/src/charts/pipeline/vizPreDraw.js.map +1 -0
- package/es/src/charts/pipeline/vizPreDrawPure.js +279 -0
- package/es/src/charts/pipeline/vizPreDrawPure.js.map +1 -0
- package/es/src/charts/plotBuffers/Bar.js +4 -4
- package/es/src/charts/plotBuffers/Bar.js.map +1 -1
- package/es/src/charts/plotBuffers/Box.js +4 -4
- package/es/src/charts/plotBuffers/Box.js.map +1 -1
- package/es/src/charts/plotBuffers/Circle.js +2 -2
- package/es/src/charts/plotBuffers/Circle.js.map +1 -1
- package/es/src/charts/plotBuffers/Line.js +5 -5
- package/es/src/charts/plotBuffers/Line.js.map +1 -1
- package/es/src/charts/plotBuffers/Rect.js +2 -2
- package/es/src/charts/plotBuffers/Rect.js.map +1 -1
- package/es/src/charts/plotBuffers/discreteBuffer.js +1 -2
- package/es/src/charts/plotBuffers/discreteBuffer.js.map +1 -1
- package/es/src/charts/plotBuffers/numericBuffer.js +1 -2
- package/es/src/charts/plotBuffers/numericBuffer.js.map +1 -1
- package/es/src/charts/viz/Viz.js +985 -0
- package/es/src/charts/viz/Viz.js.map +1 -0
- package/es/src/charts/viz/VizBase.js +447 -0
- package/es/src/charts/viz/VizBase.js.map +1 -0
- package/es/src/charts/viz/VizBaseConfig.js +504 -0
- package/es/src/charts/viz/VizBaseConfig.js.map +1 -0
- package/es/src/charts/viz/interactionOpacity.js +247 -0
- package/es/src/charts/viz/interactionOpacity.js.map +1 -0
- package/es/src/charts/viz/ordinalColor.js +71 -0
- package/es/src/charts/viz/ordinalColor.js.map +1 -0
- package/es/src/charts/viz/trailCatchup.js +127 -0
- package/es/src/charts/viz/trailCatchup.js.map +1 -0
- package/es/src/charts/viz/vizDefaults.js +602 -0
- package/es/src/charts/viz/vizDefaults.js.map +1 -0
- package/es/src/charts/viz/vizRender.js +251 -0
- package/es/src/charts/viz/vizRender.js.map +1 -0
- package/es/src/charts/viz/vizTypes.js +28 -0
- package/es/src/charts/viz/vizTypes.js.map +1 -0
- package/es/src/components/Axis/Axis.js +691 -0
- package/es/src/components/Axis/Axis.js.map +1 -0
- package/es/src/components/Axis/AxisBottom.js.map +1 -0
- package/es/src/components/Axis/AxisLeft.js.map +1 -0
- package/es/src/components/Axis/AxisRight.js.map +1 -0
- package/es/src/components/Axis/AxisTop.js.map +1 -0
- package/es/src/components/Axis/axisLayout.js +208 -0
- package/es/src/components/Axis/axisLayout.js.map +1 -0
- package/es/src/components/Axis/axisLayoutLabels.js +177 -0
- package/es/src/components/Axis/axisLayoutLabels.js.map +1 -0
- package/es/src/components/Axis/axisLayoutScale.js +374 -0
- package/es/src/components/Axis/axisLayoutScale.js.map +1 -0
- package/es/src/components/Axis/axisRender.js +535 -0
- package/es/src/components/Axis/axisRender.js.map +1 -0
- package/es/src/components/ColorScale/ColorScale.js +506 -0
- package/es/src/components/ColorScale/ColorScale.js.map +1 -0
- package/es/src/components/ColorScale/colorScaleRender.js +277 -0
- package/es/src/components/ColorScale/colorScaleRender.js.map +1 -0
- package/es/src/components/ColorScale/colorScaleScale.js +274 -0
- package/es/src/components/ColorScale/colorScaleScale.js.map +1 -0
- package/es/src/components/Legend/Legend.js +445 -0
- package/es/src/components/Legend/Legend.js.map +1 -0
- package/es/src/components/Legend/legendConfig.js +87 -0
- package/es/src/components/Legend/legendConfig.js.map +1 -0
- package/es/src/components/Legend/legendRender.js +245 -0
- package/es/src/components/Legend/legendRender.js.map +1 -0
- package/es/src/components/Message.js.map +1 -1
- package/es/src/components/TextBox.js +639 -453
- package/es/src/components/TextBox.js.map +1 -1
- package/es/src/components/Timeline/Timeline.js +674 -0
- package/es/src/components/Timeline/Timeline.js.map +1 -0
- package/es/src/components/Timeline/timelineConfig.js +115 -0
- package/es/src/components/Timeline/timelineConfig.js.map +1 -0
- package/es/src/components/Timeline/timelineRender.js +267 -0
- package/es/src/components/Timeline/timelineRender.js.map +1 -0
- package/es/src/components/Tooltip.js +288 -249
- package/es/src/components/Tooltip.js.map +1 -1
- package/es/src/components/index.js +8 -8
- package/es/src/components/index.js.map +1 -1
- package/es/src/fluent.js +265 -0
- package/es/src/fluent.js.map +1 -0
- package/es/src/shapes/Area.js +96 -114
- package/es/src/shapes/Area.js.map +1 -1
- package/es/src/shapes/Bar.js +71 -86
- package/es/src/shapes/Bar.js.map +1 -1
- package/es/src/shapes/Box.js +295 -190
- package/es/src/shapes/Box.js.map +1 -1
- package/es/src/shapes/Circle.js +72 -31
- package/es/src/shapes/Circle.js.map +1 -1
- package/es/src/shapes/Image.js +164 -85
- package/es/src/shapes/Image.js.map +1 -1
- package/es/src/shapes/Line.js +51 -94
- package/es/src/shapes/Line.js.map +1 -1
- package/es/src/shapes/Path.js +33 -41
- package/es/src/shapes/Path.js.map +1 -1
- package/es/src/shapes/Rect.js +86 -37
- package/es/src/shapes/Rect.js.map +1 -1
- package/es/src/shapes/Shape.js +655 -678
- package/es/src/shapes/Shape.js.map +1 -1
- package/es/src/shapes/Whisker.js +156 -61
- package/es/src/shapes/Whisker.js.map +1 -1
- package/es/src/shapes/buildLabelData.js +70 -0
- package/es/src/shapes/buildLabelData.js.map +1 -0
- package/es/src/shapes/emitLabels.js +84 -0
- package/es/src/shapes/emitLabels.js.map +1 -0
- package/es/src/shapes/hitAreaNode.js +37 -0
- package/es/src/shapes/hitAreaNode.js.map +1 -0
- package/es/src/shapes/sceneSort.js +57 -0
- package/es/src/shapes/sceneSort.js.map +1 -0
- package/es/src/shapes/shapeConfig.js +31 -0
- package/es/src/shapes/shapeConfig.js.map +1 -0
- package/es/src/utils/BaseClass.js +35 -19
- package/es/src/utils/BaseClass.js.map +1 -1
- package/es/src/utils/D3Scale.js +16 -0
- package/es/src/utils/D3Scale.js.map +1 -0
- package/es/src/utils/D3plusConfig.js.map +1 -1
- package/es/src/utils/configPrep.js +8 -3
- package/es/src/utils/configPrep.js.map +1 -1
- package/es/src/utils/getProp.js +1 -1
- package/es/src/utils/getProp.js.map +1 -1
- package/es/src/utils/index.js +1 -0
- package/es/src/utils/index.js.map +1 -1
- package/es/src/utils/paintComponentScene.js +59 -0
- package/es/src/utils/paintComponentScene.js.map +1 -0
- package/es/umd-entry.js +16 -0
- package/es/umd-entry.js.map +1 -0
- package/package.json +14 -9
- package/types/index.d.ts +3 -1
- package/types/internal.d.ts +54 -0
- package/types/src/charts/AreaPlot/index.d.ts +10 -0
- package/types/src/charts/BarChart/index.d.ts +10 -0
- package/types/src/charts/BoxWhisker/index.d.ts +11 -0
- package/types/src/charts/BumpChart/index.d.ts +11 -0
- package/types/src/charts/ChartDefinition.d.ts +75 -0
- package/types/src/charts/Donut/index.d.ts +13 -0
- package/types/src/charts/Geomap/applyLayout.d.ts +7 -0
- package/types/src/charts/Geomap/emit.d.ts +7 -0
- package/types/src/charts/Geomap/index.d.ts +14 -0
- package/types/src/charts/Geomap.d.ts +6 -0
- package/types/src/charts/LinePlot/index.d.ts +10 -0
- package/types/src/charts/Matrix/applyLayout.d.ts +9 -0
- package/types/src/charts/Matrix/emit.d.ts +6 -0
- package/types/src/charts/Matrix/index.d.ts +14 -0
- package/types/src/charts/Matrix.d.ts +0 -26
- package/types/src/charts/Network/applyLayout.d.ts +10 -0
- package/types/src/charts/Network/emit.d.ts +6 -0
- package/types/src/charts/Network/index.d.ts +7 -0
- package/types/src/charts/Network.d.ts +0 -24
- package/types/src/charts/Pack/applyLayout.d.ts +16 -0
- package/types/src/charts/Pack/emit.d.ts +6 -0
- package/types/src/charts/Pack/index.d.ts +15 -0
- package/types/src/charts/Pack/recursionCircles.d.ts +7 -0
- package/types/src/charts/Pack.d.ts +0 -13
- package/types/src/charts/Pie/applyLayout.d.ts +8 -0
- package/types/src/charts/Pie/emit.d.ts +5 -0
- package/types/src/charts/Pie/index.d.ts +14 -0
- package/types/src/charts/Pie.d.ts +0 -27
- package/types/src/charts/Plot/draw.d.ts +2 -0
- package/types/src/charts/Plot/index.d.ts +167 -0
- package/types/src/charts/Plot/labelPlacement.d.ts +15 -0
- package/types/src/charts/Plot/pipeline.d.ts +70 -0
- package/types/src/charts/Plot/pipelineDomains.d.ts +2 -0
- package/types/src/charts/Plot/pipelineLineLabels.d.ts +2 -0
- package/types/src/charts/Plot/shapeDefaults.d.ts +64 -0
- package/types/src/charts/Plot/stackHelpers.d.ts +24 -0
- package/types/src/charts/Plot.d.ts +23 -72
- package/types/src/charts/Priestley/applyLayout.d.ts +21 -0
- package/types/src/charts/Priestley/emit.d.ts +6 -0
- package/types/src/charts/Priestley/index.d.ts +14 -0
- package/types/src/charts/Radar/applyLayout.d.ts +10 -0
- package/types/src/charts/Radar/emit.d.ts +7 -0
- package/types/src/charts/Radar/index.d.ts +14 -0
- package/types/src/charts/RadialMatrix/applyLayout.d.ts +11 -0
- package/types/src/charts/RadialMatrix/emit.d.ts +6 -0
- package/types/src/charts/RadialMatrix/index.d.ts +14 -0
- package/types/src/charts/RadialMatrix.d.ts +0 -15
- package/types/src/charts/Rings/applyLayout.d.ts +2 -0
- package/types/src/charts/Rings/emit.d.ts +7 -0
- package/types/src/charts/Rings/index.d.ts +15 -0
- package/types/src/charts/Rings.d.ts +0 -13
- package/types/src/charts/Sankey/applyLayout.d.ts +7 -0
- package/types/src/charts/Sankey/emit.d.ts +6 -0
- package/types/src/charts/Sankey/index.d.ts +7 -0
- package/types/src/charts/Sankey.d.ts +0 -4
- package/types/src/charts/StackedArea/index.d.ts +10 -0
- package/types/src/charts/Tree/applyLayout.d.ts +2 -0
- package/types/src/charts/Tree/emit.d.ts +7 -0
- package/types/src/charts/Tree/index.d.ts +14 -0
- package/types/src/charts/Tree.d.ts +0 -16
- package/types/src/charts/Treemap/applyLayout.d.ts +16 -0
- package/types/src/charts/Treemap/emit.d.ts +6 -0
- package/types/src/charts/Treemap/index.d.ts +18 -0
- package/types/src/charts/Treemap/thresholdFunction.d.ts +25 -0
- package/types/src/charts/Treemap.d.ts +4 -13
- package/types/src/charts/Viz.d.ts +49 -361
- package/types/src/charts/VizBase.d.ts +158 -0
- package/types/src/charts/VizBaseConfig.d.ts +148 -0
- package/types/src/charts/applyDefinition.d.ts +13 -0
- package/types/src/charts/axes.d.ts +134 -0
- package/types/src/charts/chartGeometry.d.ts +58 -0
- package/types/src/charts/definition/ChartDefinition.d.ts +84 -0
- package/types/src/charts/definition/applyDefinition.d.ts +13 -0
- package/types/src/charts/definition/makeChart.d.ts +22 -0
- package/types/src/charts/drawSteps/zoomControls.d.ts +25 -5
- package/types/src/charts/emitHelpers.d.ts +122 -0
- package/types/src/charts/ensureZoomDom.d.ts +39 -0
- package/types/src/charts/events/click.legend.d.ts +1 -1
- package/types/src/charts/events/click.shape.d.ts +1 -1
- package/types/src/charts/events/mouseenter.d.ts +1 -1
- package/types/src/charts/events/mouseleave.d.ts +1 -1
- package/types/src/charts/events/mousemove.legend.d.ts +1 -1
- package/types/src/charts/events/mousemove.shape.d.ts +1 -1
- package/types/src/charts/events/touchstart.body.d.ts +1 -1
- package/types/src/charts/factories.d.ts +73 -0
- package/types/src/charts/features/axes.d.ts +134 -0
- package/types/src/charts/features/chartGeometry.d.ts +58 -0
- package/types/src/charts/features/colorScaleBucket.d.ts +43 -0
- package/types/src/charts/features/colorScaleBucketShare.d.ts +16 -0
- package/types/src/charts/features/emitHelpers.d.ts +123 -0
- package/types/src/charts/features/ensureZoomDom.d.ts +39 -0
- package/types/src/charts/features/features.d.ts +152 -0
- package/types/src/charts/features/featuresLegend.d.ts +12 -0
- package/types/src/charts/features/legendLabel.d.ts +11 -0
- package/types/src/charts/features/lineLabels.d.ts +40 -0
- package/types/src/charts/features/plotPaint.d.ts +233 -0
- package/types/src/charts/features/shapeEmit.d.ts +61 -0
- package/types/src/charts/features.d.ts +152 -0
- package/types/src/charts/featuresLegend.d.ts +12 -0
- package/types/src/charts/helpers/matrixData.d.ts +1 -1
- package/types/src/charts/index.d.ts +21 -21
- package/types/src/charts/legendLabel.d.ts +11 -0
- package/types/src/charts/lineLabels.d.ts +40 -0
- package/types/src/charts/makeChart.d.ts +22 -0
- package/types/src/charts/pipeline/resolveSpec.d.ts +51 -0
- package/types/src/charts/pipeline/runChartDraw.d.ts +38 -0
- package/types/src/charts/pipeline/runVizPipeline.d.ts +31 -0
- package/types/src/charts/pipeline/stages.d.ts +160 -0
- package/types/src/charts/pipeline/vizContext.d.ts +45 -0
- package/types/src/charts/pipeline/vizDraw.d.ts +25 -0
- package/types/src/charts/pipeline/vizDrawPure.d.ts +46 -0
- package/types/src/charts/pipeline/vizPreDraw.d.ts +22 -0
- package/types/src/charts/pipeline/vizPreDrawPure.d.ts +68 -0
- package/types/src/charts/plotBuffers/Bar.d.ts +6 -5
- package/types/src/charts/plotBuffers/Box.d.ts +6 -5
- package/types/src/charts/plotBuffers/Circle.d.ts +6 -5
- package/types/src/charts/plotBuffers/Line.d.ts +6 -5
- package/types/src/charts/plotBuffers/Rect.d.ts +6 -5
- package/types/src/charts/plotBuffers/discreteBuffer.d.ts +2 -1
- package/types/src/charts/plotBuffers/numericBuffer.d.ts +2 -1
- package/types/src/charts/plotPaint.d.ts +233 -0
- package/types/src/charts/resolveSpec.d.ts +50 -0
- package/types/src/charts/runChartDraw.d.ts +38 -0
- package/types/src/charts/runVizPipeline.d.ts +31 -0
- package/types/src/charts/shapeEmit.d.ts +61 -0
- package/types/src/charts/stages.d.ts +117 -0
- package/types/src/charts/viz/Viz.d.ts +111 -0
- package/types/src/charts/viz/VizBase.d.ts +160 -0
- package/types/src/charts/viz/VizBaseConfig.d.ts +156 -0
- package/types/src/charts/viz/interactionOpacity.d.ts +23 -0
- package/types/src/charts/viz/ordinalColor.d.ts +14 -0
- package/types/src/charts/viz/trailCatchup.d.ts +14 -0
- package/types/src/charts/viz/vizDefaults.d.ts +8 -0
- package/types/src/charts/viz/vizRender.d.ts +8 -0
- package/types/src/charts/viz/vizTypes.d.ts +250 -0
- package/types/src/charts/vizContext.d.ts +46 -0
- package/types/src/charts/vizDefaults.d.ts +8 -0
- package/types/src/charts/vizDraw.d.ts +25 -0
- package/types/src/charts/vizDrawPure.d.ts +17 -0
- package/types/src/charts/vizPreDraw.d.ts +22 -0
- package/types/src/charts/vizPreDrawPure.d.ts +40 -0
- package/types/src/charts/vizRender.d.ts +8 -0
- package/types/src/charts/vizTypes.d.ts +202 -0
- package/types/src/components/Axis/Axis.d.ts +182 -0
- package/types/src/components/Axis/AxisBottom.d.ts +11 -0
- package/types/src/components/Axis/AxisLeft.d.ts +11 -0
- package/types/src/components/Axis/AxisRight.d.ts +11 -0
- package/types/src/components/Axis/AxisTop.d.ts +11 -0
- package/types/src/components/Axis/axisLayout.d.ts +29 -0
- package/types/src/components/Axis/axisLayoutLabels.d.ts +70 -0
- package/types/src/components/Axis/axisLayoutScale.d.ts +14 -0
- package/types/src/components/Axis/axisRender.d.ts +68 -0
- package/types/src/components/Axis.d.ts +68 -194
- package/types/src/components/ColorScale/ColorScale.d.ts +100 -0
- package/types/src/components/ColorScale/colorScaleRender.d.ts +15 -0
- package/types/src/components/ColorScale/colorScaleScale.d.ts +19 -0
- package/types/src/components/ColorScale.d.ts +1 -129
- package/types/src/components/Legend/Legend.d.ts +95 -0
- package/types/src/components/Legend/legendConfig.d.ts +7 -0
- package/types/src/components/Legend/legendRender.d.ts +16 -0
- package/types/src/components/Legend.d.ts +9 -73
- package/types/src/components/TextBox.d.ts +25 -218
- package/types/src/components/Timeline/Timeline.d.ts +118 -0
- package/types/src/components/Timeline/timelineConfig.d.ts +6 -0
- package/types/src/components/Timeline/timelineRender.d.ts +24 -0
- package/types/src/components/Timeline.d.ts +7 -81
- package/types/src/components/Tooltip.d.ts +20 -200
- package/types/src/components/axisLayout.d.ts +27 -0
- package/types/src/components/axisLayoutLabels.d.ts +42 -0
- package/types/src/components/axisLayoutScale.d.ts +12 -0
- package/types/src/components/axisRender.d.ts +65 -0
- package/types/src/components/colorScaleRender.d.ts +15 -0
- package/types/src/components/colorScaleScale.d.ts +19 -0
- package/types/src/components/index.d.ts +8 -8
- package/types/src/components/legendConfig.d.ts +7 -0
- package/types/src/components/legendRender.d.ts +16 -0
- package/types/src/components/timelineConfig.d.ts +6 -0
- package/types/src/components/timelineRender.d.ts +14 -0
- package/types/src/fluent.d.ts +94 -0
- package/types/src/shapes/Area.d.ts +15 -27
- package/types/src/shapes/Bar.d.ts +13 -33
- package/types/src/shapes/Box.d.ts +17 -56
- package/types/src/shapes/Circle.d.ts +11 -17
- package/types/src/shapes/Image.d.ts +18 -84
- package/types/src/shapes/Line.d.ts +12 -22
- package/types/src/shapes/Path.d.ts +12 -19
- package/types/src/shapes/Rect.d.ts +11 -27
- package/types/src/shapes/Shape.d.ts +46 -257
- package/types/src/shapes/Whisker.d.ts +15 -42
- package/types/src/shapes/buildLabelData.d.ts +50 -0
- package/types/src/shapes/emitLabels.d.ts +16 -0
- package/types/src/shapes/hitAreaNode.d.ts +19 -0
- package/types/src/shapes/sceneSort.d.ts +20 -0
- package/types/src/shapes/shapeConfig.d.ts +226 -0
- package/types/src/utils/BaseClass.d.ts +13 -7
- package/types/src/utils/D3Scale.d.ts +48 -0
- package/types/src/utils/D3plusConfig.d.ts +230 -3
- package/types/src/utils/configPrep.d.ts +7 -4
- package/types/src/utils/getProp.d.ts +3 -1
- package/types/src/utils/index.d.ts +3 -1
- package/types/src/utils/paintComponentScene.d.ts +28 -0
- package/types/umd-entry.d.ts +15 -0
- package/umd/d3plus-core.full.js +31148 -19484
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +5309 -2944
- package/umd/d3plus-core.js +17379 -10578
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +3470 -1876
- package/es/src/charts/AreaPlot.js +0 -85
- package/es/src/charts/AreaPlot.js.map +0 -1
- package/es/src/charts/BarChart.js +0 -92
- package/es/src/charts/BarChart.js.map +0 -1
- package/es/src/charts/BoxWhisker.js +0 -92
- package/es/src/charts/BoxWhisker.js.map +0 -1
- package/es/src/charts/BumpChart.js +0 -147
- package/es/src/charts/BumpChart.js.map +0 -1
- package/es/src/charts/Donut.js +0 -84
- package/es/src/charts/Donut.js.map +0 -1
- package/es/src/charts/Geomap.js +0 -766
- package/es/src/charts/Geomap.js.map +0 -1
- package/es/src/charts/LinePlot.js +0 -83
- package/es/src/charts/LinePlot.js.map +0 -1
- package/es/src/charts/Matrix.js +0 -341
- package/es/src/charts/Matrix.js.map +0 -1
- package/es/src/charts/Network.js +0 -796
- package/es/src/charts/Network.js.map +0 -1
- package/es/src/charts/Pack.js +0 -308
- package/es/src/charts/Pack.js.map +0 -1
- package/es/src/charts/Pie.js +0 -232
- package/es/src/charts/Pie.js.map +0 -1
- package/es/src/charts/Plot.js +0 -2114
- package/es/src/charts/Plot.js.map +0 -1
- package/es/src/charts/Priestley.js +0 -296
- package/es/src/charts/Priestley.js.map +0 -1
- package/es/src/charts/Radar.js +0 -420
- package/es/src/charts/Radar.js.map +0 -1
- package/es/src/charts/RadialMatrix.js +0 -383
- package/es/src/charts/RadialMatrix.js.map +0 -1
- package/es/src/charts/Rings.js +0 -788
- package/es/src/charts/Rings.js.map +0 -1
- package/es/src/charts/Sankey.js +0 -461
- package/es/src/charts/Sankey.js.map +0 -1
- package/es/src/charts/StackedArea.js +0 -80
- package/es/src/charts/StackedArea.js.map +0 -1
- package/es/src/charts/Tree.js +0 -347
- package/es/src/charts/Tree.js.map +0 -1
- package/es/src/charts/Treemap.js +0 -454
- package/es/src/charts/Treemap.js.map +0 -1
- package/es/src/charts/Viz.js +0 -1832
- package/es/src/charts/Viz.js.map +0 -1
- package/es/src/charts/drawSteps/drawAttribution.js +0 -16
- package/es/src/charts/drawSteps/drawAttribution.js.map +0 -1
- package/es/src/charts/drawSteps/drawBack.js +0 -24
- package/es/src/charts/drawSteps/drawBack.js.map +0 -1
- package/es/src/charts/drawSteps/drawColorScale.js +0 -75
- package/es/src/charts/drawSteps/drawColorScale.js.map +0 -1
- package/es/src/charts/drawSteps/drawLegend.js +0 -122
- package/es/src/charts/drawSteps/drawLegend.js.map +0 -1
- package/es/src/charts/drawSteps/drawSubtitle.js +0 -31
- package/es/src/charts/drawSteps/drawSubtitle.js.map +0 -1
- package/es/src/charts/drawSteps/drawTimeline.js +0 -85
- package/es/src/charts/drawSteps/drawTimeline.js.map +0 -1
- package/es/src/charts/drawSteps/drawTitle.js +0 -31
- package/es/src/charts/drawSteps/drawTitle.js.map +0 -1
- package/es/src/charts/drawSteps/drawTotal.js +0 -32
- package/es/src/charts/drawSteps/drawTotal.js.map +0 -1
- package/es/src/components/Axis.js +0 -1457
- package/es/src/components/Axis.js.map +0 -1
- package/es/src/components/AxisBottom.js.map +0 -1
- package/es/src/components/AxisLeft.js.map +0 -1
- package/es/src/components/AxisRight.js.map +0 -1
- package/es/src/components/AxisTop.js.map +0 -1
- package/es/src/components/ColorScale.js +0 -843
- package/es/src/components/ColorScale.js.map +0 -1
- package/es/src/components/Legend.js +0 -622
- package/es/src/components/Legend.js.map +0 -1
- package/es/src/components/Timeline.js +0 -695
- package/es/src/components/Timeline.js.map +0 -1
- /package/es/src/components/{AxisBottom.js → Axis/AxisBottom.js} +0 -0
- /package/es/src/components/{AxisLeft.js → Axis/AxisLeft.js} +0 -0
- /package/es/src/components/{AxisRight.js → Axis/AxisRight.js} +0 -0
- /package/es/src/components/{AxisTop.js → Axis/AxisTop.js} +0 -0
package/es/src/shapes/Shape.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function _array_without_holes(arr) {
|
|
10
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
11
|
+
}
|
|
1
12
|
function _assert_this_initialized(self) {
|
|
2
13
|
if (self === void 0) {
|
|
3
14
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
@@ -40,6 +51,22 @@ function _define_property(obj, key, value) {
|
|
|
40
51
|
}
|
|
41
52
|
return obj;
|
|
42
53
|
}
|
|
54
|
+
function _get(target, property, receiver) {
|
|
55
|
+
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
56
|
+
_get = Reflect.get;
|
|
57
|
+
} else {
|
|
58
|
+
_get = function get(target, property, receiver) {
|
|
59
|
+
var base = _super_prop_base(target, property);
|
|
60
|
+
if (!base) return;
|
|
61
|
+
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
62
|
+
if (desc.get) {
|
|
63
|
+
return desc.get.call(receiver || target);
|
|
64
|
+
}
|
|
65
|
+
return desc.value;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return _get(target, property, receiver || target);
|
|
69
|
+
}
|
|
43
70
|
function _get_prototype_of(o) {
|
|
44
71
|
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
45
72
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
@@ -59,13 +86,77 @@ function _inherits(subClass, superClass) {
|
|
|
59
86
|
});
|
|
60
87
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
61
88
|
}
|
|
62
|
-
function
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
89
|
+
function _iterable_to_array(iter) {
|
|
90
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
91
|
+
}
|
|
92
|
+
function _iterable_to_array_limit(arr, i) {
|
|
93
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
94
|
+
if (_i == null) return;
|
|
95
|
+
var _arr = [];
|
|
96
|
+
var _n = true;
|
|
97
|
+
var _d = false;
|
|
98
|
+
var _s, _e;
|
|
99
|
+
try {
|
|
100
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
101
|
+
_arr.push(_s.value);
|
|
102
|
+
if (i && _arr.length === i) break;
|
|
103
|
+
}
|
|
104
|
+
} catch (err) {
|
|
105
|
+
_d = true;
|
|
106
|
+
_e = err;
|
|
107
|
+
} finally{
|
|
108
|
+
try {
|
|
109
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
110
|
+
} finally{
|
|
111
|
+
if (_d) throw _e;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return _arr;
|
|
115
|
+
}
|
|
116
|
+
function _non_iterable_rest() {
|
|
117
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
118
|
+
}
|
|
119
|
+
function _non_iterable_spread() {
|
|
120
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
121
|
+
}
|
|
122
|
+
function _object_spread(target) {
|
|
123
|
+
for(var i = 1; i < arguments.length; i++){
|
|
124
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
125
|
+
var ownKeys = Object.keys(source);
|
|
126
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
127
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
128
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
ownKeys.forEach(function(key) {
|
|
132
|
+
_define_property(target, key, source[key]);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return target;
|
|
136
|
+
}
|
|
137
|
+
function ownKeys(object, enumerableOnly) {
|
|
138
|
+
var keys = Object.keys(object);
|
|
139
|
+
if (Object.getOwnPropertySymbols) {
|
|
140
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
141
|
+
if (enumerableOnly) {
|
|
142
|
+
symbols = symbols.filter(function(sym) {
|
|
143
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
keys.push.apply(keys, symbols);
|
|
147
|
+
}
|
|
148
|
+
return keys;
|
|
149
|
+
}
|
|
150
|
+
function _object_spread_props(target, source) {
|
|
151
|
+
source = source != null ? source : {};
|
|
152
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
153
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
66
154
|
} else {
|
|
67
|
-
|
|
155
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
156
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
157
|
+
});
|
|
68
158
|
}
|
|
159
|
+
return target;
|
|
69
160
|
}
|
|
70
161
|
function _possible_constructor_return(self, call) {
|
|
71
162
|
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
@@ -80,10 +171,31 @@ function _set_prototype_of(o, p) {
|
|
|
80
171
|
};
|
|
81
172
|
return _set_prototype_of(o, p);
|
|
82
173
|
}
|
|
174
|
+
function _sliced_to_array(arr, i) {
|
|
175
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
176
|
+
}
|
|
177
|
+
function _super_prop_base(object, property) {
|
|
178
|
+
while(!Object.prototype.hasOwnProperty.call(object, property)){
|
|
179
|
+
object = _get_prototype_of(object);
|
|
180
|
+
if (object === null) break;
|
|
181
|
+
}
|
|
182
|
+
return object;
|
|
183
|
+
}
|
|
184
|
+
function _to_consumable_array(arr) {
|
|
185
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
186
|
+
}
|
|
83
187
|
function _type_of(obj) {
|
|
84
188
|
"@swc/helpers - typeof";
|
|
85
189
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
86
190
|
}
|
|
191
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
192
|
+
if (!o) return;
|
|
193
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
194
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
195
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
196
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
197
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
198
|
+
}
|
|
87
199
|
function _is_native_reflect_construct() {
|
|
88
200
|
try {
|
|
89
201
|
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
@@ -92,37 +204,199 @@ function _is_native_reflect_construct() {
|
|
|
92
204
|
return !!result;
|
|
93
205
|
})();
|
|
94
206
|
}
|
|
95
|
-
import { min } from "d3-array";
|
|
96
207
|
import { color } from "d3-color";
|
|
97
|
-
import {
|
|
98
|
-
import * as paths from "d3-shape";
|
|
99
|
-
import { transition } from "d3-transition";
|
|
100
|
-
import textures from "textures";
|
|
208
|
+
import { select } from "d3-selection";
|
|
101
209
|
import { colorContrast } from "@d3plus/color";
|
|
102
|
-
import {
|
|
103
|
-
import {
|
|
104
|
-
import { pointDistance } from "@d3plus/math";
|
|
105
|
-
import { strip } from "@d3plus/text";
|
|
210
|
+
import { assign, getSize, isObject } from "@d3plus/dom";
|
|
211
|
+
import { SvgRenderer } from "@d3plus/render";
|
|
106
212
|
import { TextBox } from "../components/index.js";
|
|
107
|
-
import { accessor, BaseClass,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
213
|
+
import { accessor, BaseClass, constant } from "../utils/index.js";
|
|
214
|
+
import { installFluent } from "../fluent.js";
|
|
215
|
+
import { buildLabelData } from "./buildLabelData.js";
|
|
216
|
+
import { hitAreaNode } from "./hitAreaNode.js";
|
|
217
|
+
/** Coerces a value to a finite number, or undefined. @private */ export function numOrUndef(v) {
|
|
218
|
+
var n = Number(v);
|
|
219
|
+
return Number.isFinite(n) ? n : undefined;
|
|
220
|
+
}
|
|
221
|
+
/** Returns a non-empty string, or undefined. @private */ export function strOrUndef(v) {
|
|
222
|
+
return v == null || v === "" ? undefined : String(v);
|
|
223
|
+
}
|
|
224
|
+
/** Parses an SVG stroke-dasharray value into an array of numbers. @private */ export function parseDash(v) {
|
|
225
|
+
if (v == null || v === "none" || v === "") return undefined;
|
|
226
|
+
if (typeof v === "number") return [
|
|
227
|
+
v
|
|
228
|
+
];
|
|
229
|
+
var parts = String(v).split(/[\s,]+/).map(Number).filter(function(n) {
|
|
230
|
+
return Number.isFinite(n);
|
|
231
|
+
});
|
|
232
|
+
return parts.length ? parts : undefined;
|
|
124
233
|
}
|
|
125
234
|
import Image from "./Image.js";
|
|
235
|
+
import { emitBackgroundImages, sortRanks } from "./sceneSort.js";
|
|
236
|
+
/** Shape's fluent accessor schema. Config storage lives on `this.schema.<key>`. */ var shapeSchema = [
|
|
237
|
+
{
|
|
238
|
+
key: "activeOpacity",
|
|
239
|
+
coerce: "identity",
|
|
240
|
+
default: 0.25
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
key: "ariaLabel",
|
|
244
|
+
coerce: "const",
|
|
245
|
+
default: constant("")
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
key: "backgroundImage",
|
|
249
|
+
coerce: "const",
|
|
250
|
+
default: constant(false)
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
key: "discrete",
|
|
254
|
+
coerce: "identity"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
key: "duration",
|
|
258
|
+
coerce: "identity",
|
|
259
|
+
default: 600
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
key: "fill",
|
|
263
|
+
coerce: "const",
|
|
264
|
+
default: constant("black")
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
key: "fillOpacity",
|
|
268
|
+
coerce: "const",
|
|
269
|
+
default: constant(1)
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
key: "hitArea",
|
|
273
|
+
coerce: "const"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
key: "hoverOpacity",
|
|
277
|
+
coerce: "identity",
|
|
278
|
+
default: 0.5
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
key: "id",
|
|
282
|
+
coerce: "accessor",
|
|
283
|
+
default: function _default(d, i) {
|
|
284
|
+
return d.id !== void 0 ? d.id : i;
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
key: "label",
|
|
289
|
+
coerce: "const",
|
|
290
|
+
default: constant(false)
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
key: "labelBounds",
|
|
294
|
+
coerce: "const"
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
key: "opacity",
|
|
298
|
+
coerce: "const",
|
|
299
|
+
default: constant(1)
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
key: "pointerEvents",
|
|
303
|
+
coerce: "const",
|
|
304
|
+
default: constant("visiblePainted")
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
key: "renderMode",
|
|
308
|
+
coerce: "identity",
|
|
309
|
+
default: "full"
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
key: "role",
|
|
313
|
+
coerce: "const",
|
|
314
|
+
default: constant("presentation")
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
key: "rotate",
|
|
318
|
+
coerce: "const",
|
|
319
|
+
default: constant(0)
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
key: "rx",
|
|
323
|
+
coerce: "const",
|
|
324
|
+
default: constant(0)
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
key: "ry",
|
|
328
|
+
coerce: "const",
|
|
329
|
+
default: constant(0)
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
key: "scale",
|
|
333
|
+
coerce: "const",
|
|
334
|
+
default: constant(1)
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
key: "shapeRendering",
|
|
338
|
+
coerce: "const",
|
|
339
|
+
default: constant("geometricPrecision")
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
key: "stroke",
|
|
343
|
+
coerce: "const"
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
key: "strokeDasharray",
|
|
347
|
+
coerce: "const",
|
|
348
|
+
default: constant("0")
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
key: "strokeLinecap",
|
|
352
|
+
coerce: "const",
|
|
353
|
+
default: constant("butt")
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
key: "strokeOpacity",
|
|
357
|
+
coerce: "const",
|
|
358
|
+
default: constant(1)
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
key: "strokeWidth",
|
|
362
|
+
coerce: "const",
|
|
363
|
+
default: constant(0)
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
key: "textAnchor",
|
|
367
|
+
coerce: "const",
|
|
368
|
+
default: constant("start")
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
key: "texture",
|
|
372
|
+
coerce: "const",
|
|
373
|
+
default: constant(false)
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
key: "vectorEffect",
|
|
377
|
+
coerce: "const",
|
|
378
|
+
default: constant("non-scaling-stroke")
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
key: "verticalAlign",
|
|
382
|
+
coerce: "const",
|
|
383
|
+
default: constant("top")
|
|
384
|
+
},
|
|
385
|
+
// "accessor" (not "const"): a string names a data key (`.x("year")`), a
|
|
386
|
+
// number is a constant (`.x(50)`), and a function passes through — so a
|
|
387
|
+
// standalone shape given string accessors (as the pipeline never does, but
|
|
388
|
+
// direct users do) reads the field instead of treating "x" as the literal.
|
|
389
|
+
{
|
|
390
|
+
key: "x",
|
|
391
|
+
coerce: "accessor",
|
|
392
|
+
default: accessor("x", 0)
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
key: "y",
|
|
396
|
+
coerce: "accessor",
|
|
397
|
+
default: accessor("y", 0)
|
|
398
|
+
}
|
|
399
|
+
];
|
|
126
400
|
var Shape = /*#__PURE__*/ function(BaseClass) {
|
|
127
401
|
"use strict";
|
|
128
402
|
_inherits(Shape, BaseClass);
|
|
@@ -130,81 +404,76 @@ var Shape = /*#__PURE__*/ function(BaseClass) {
|
|
|
130
404
|
var tagName = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "g";
|
|
131
405
|
_class_call_check(this, Shape);
|
|
132
406
|
var _this;
|
|
133
|
-
_this = _call_super(this, Shape), _define_property(_this, "
|
|
134
|
-
_this
|
|
135
|
-
_this.
|
|
407
|
+
_this = _call_super(this, Shape), _define_property(_this, "_backgroundImageClass", void 0), _define_property(_this, "_data", void 0), _define_property(_this, "_labelClass", void 0), _define_property(_this, "_name", void 0), _define_property(_this, "_tagName", void 0), _define_property(_this, "_textureDefs", void 0), _define_property(_this, "_select", void 0), _define_property(_this, "_transition", void 0), _define_property(_this, "_group", void 0), _define_property(_this, "_update", void 0), _define_property(_this, "_enter", void 0), _define_property(_this, "_exit", void 0), _define_property(_this, "_hoverGroup", void 0), _define_property(_this, "_activeGroup", void 0), _define_property(_this, "_path", void 0), /** SvgRenderer mounted by the standalone `render()` path; reused across redraws. */ _define_property(_this, "_sceneRenderer", void 0);
|
|
408
|
+
installFluent(_this, shapeSchema);
|
|
409
|
+
_this._backgroundImageClass = new Image();
|
|
410
|
+
_this._data = [];
|
|
411
|
+
_this._labelClass = new TextBox();
|
|
412
|
+
_this._name = "Shape";
|
|
413
|
+
_this._tagName = tagName;
|
|
414
|
+
_this._textureDefs = {};
|
|
415
|
+
// stroke defaults to a darker shade of fill — closes over `this.schema`
|
|
416
|
+
// so it tracks the current fill accessor. A fill that doesn't parse as a
|
|
417
|
+
// color (e.g. "none"/"transparent", a gradient token) has no darker shade,
|
|
418
|
+
// so fall back to the fill value itself.
|
|
419
|
+
_this.schema.stroke = function(d, i) {
|
|
420
|
+
var c = color(_this.schema.fill(d, i));
|
|
421
|
+
return c ? c.darker(1).formatHex() : _this.schema.fill(d, i);
|
|
422
|
+
};
|
|
423
|
+
_this.schema.activeStyle = {
|
|
136
424
|
stroke: function stroke(d, i) {
|
|
137
|
-
var c = _this.
|
|
425
|
+
var c = _this.schema.fill(d, i);
|
|
138
426
|
if ([
|
|
139
427
|
"transparent",
|
|
140
428
|
"none"
|
|
141
|
-
].includes(c)) c = _this.
|
|
142
|
-
|
|
429
|
+
].includes(c)) c = _this.schema.stroke(d, i);
|
|
430
|
+
var col = color(c);
|
|
431
|
+
return col ? col.darker(1) : c;
|
|
143
432
|
},
|
|
144
433
|
"stroke-width": function(d, i) {
|
|
145
|
-
var s = _this.
|
|
434
|
+
var s = _this.schema.strokeWidth(d, i) || 1;
|
|
146
435
|
return s * 3;
|
|
147
436
|
}
|
|
148
437
|
};
|
|
149
|
-
_this.
|
|
150
|
-
_this._backgroundImage = constant(false);
|
|
151
|
-
_this._backgroundImageClass = new Image();
|
|
152
|
-
_this._data = [];
|
|
153
|
-
_this._duration = 600;
|
|
154
|
-
_this._fill = constant("black");
|
|
155
|
-
_this._fillOpacity = constant(1);
|
|
156
|
-
_this._hoverOpacity = 0.5;
|
|
157
|
-
_this._hoverStyle = {
|
|
438
|
+
_this.schema.hoverStyle = {
|
|
158
439
|
stroke: function stroke(d, i) {
|
|
159
|
-
var c = _this.
|
|
440
|
+
var c = _this.schema.fill(d, i);
|
|
160
441
|
if ([
|
|
161
442
|
"transparent",
|
|
162
443
|
"none"
|
|
163
|
-
].includes(c)) c = _this.
|
|
164
|
-
|
|
444
|
+
].includes(c)) c = _this.schema.stroke(d, i);
|
|
445
|
+
var col = color(c);
|
|
446
|
+
return col ? col.darker(0.5) : c;
|
|
165
447
|
},
|
|
166
448
|
"stroke-width": function(d, i) {
|
|
167
|
-
var s = _this.
|
|
449
|
+
var s = _this.schema.strokeWidth(d, i) || 1;
|
|
168
450
|
return s * 2;
|
|
169
451
|
}
|
|
170
452
|
};
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
_this.
|
|
453
|
+
// Shape's label defaults. These are pushed to `_labelClass` via
|
|
454
|
+
// `_labelClass.config(this.schema.labelConfig)` in render() so the
|
|
455
|
+
// TextBox actually picks them up.
|
|
456
|
+
// textAnchor defaults to "start" (left-aligned) — Treemap, Pie,
|
|
457
|
+
// etc. rely on this. Bar overrides to "middle" in its constructor.
|
|
458
|
+
_this.schema.labelConfig = {
|
|
177
459
|
fontColor: function fontColor(d, i) {
|
|
178
|
-
return colorContrast(_this.
|
|
460
|
+
return colorContrast(_this.schema.fill(d, i));
|
|
461
|
+
},
|
|
462
|
+
// Fade labels with their shape's opacity (e.g. an axis tick label hides
|
|
463
|
+
// when `shapeConfig.opacity` is 0). Reads `this.schema.opacity` live —
|
|
464
|
+
// like `fontColor` reads `fill` — which unwraps nested label data.
|
|
465
|
+
fontOpacity: function fontOpacity(d, i) {
|
|
466
|
+
return _this.schema.opacity(d, i);
|
|
179
467
|
},
|
|
468
|
+
fontResize: true,
|
|
469
|
+
fontMax: 50,
|
|
470
|
+
fontMin: 8,
|
|
180
471
|
fontSize: 12,
|
|
181
|
-
padding: 5
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
_this._opacity = constant(1);
|
|
185
|
-
_this._pointerEvents = constant("visiblePainted");
|
|
186
|
-
_this._role = constant("presentation");
|
|
187
|
-
_this._rotate = constant(0);
|
|
188
|
-
_this._rx = constant(0);
|
|
189
|
-
_this._ry = constant(0);
|
|
190
|
-
_this._scale = constant(1);
|
|
191
|
-
_this._shapeRendering = constant("geometricPrecision");
|
|
192
|
-
_this._stroke = function(d, i) {
|
|
193
|
-
return color(_this._fill(d, i)).darker(1).formatHex();
|
|
472
|
+
padding: 5,
|
|
473
|
+
textAnchor: "start",
|
|
474
|
+
verticalAlign: "top"
|
|
194
475
|
};
|
|
195
|
-
_this.
|
|
196
|
-
_this._strokeLinecap = constant("butt");
|
|
197
|
-
_this._strokeOpacity = constant(1);
|
|
198
|
-
_this._strokeWidth = constant(0);
|
|
199
|
-
_this._tagName = tagName;
|
|
200
|
-
_this._textAnchor = constant("start");
|
|
201
|
-
_this._texture = constant(false);
|
|
202
|
-
_this._textureDefault = {};
|
|
203
|
-
_this._textureDefs = {};
|
|
204
|
-
_this._vectorEffect = constant("non-scaling-stroke");
|
|
205
|
-
_this._verticalAlign = constant("top");
|
|
206
|
-
_this._x = accessor("x", 0);
|
|
207
|
-
_this._y = accessor("y", 0);
|
|
476
|
+
_this.schema.textureDefault = {};
|
|
208
477
|
return _this;
|
|
209
478
|
}
|
|
210
479
|
_create_class(Shape, [
|
|
@@ -220,117 +489,13 @@ var Shape = /*#__PURE__*/ function(BaseClass) {
|
|
|
220
489
|
},
|
|
221
490
|
{
|
|
222
491
|
/**
|
|
223
|
-
Adds event listeners to each shape group or hit area.
|
|
224
|
-
@private
|
|
225
|
-
*/ key: "_applyEvents",
|
|
226
|
-
value: function _applyEvents(handler) {
|
|
227
|
-
var _loop = function(e) {
|
|
228
|
-
handler.on(events[e], function(event, d) {
|
|
229
|
-
var i = 0;
|
|
230
|
-
if (!_this._on[events[e]]) return;
|
|
231
|
-
if (d.i !== void 0) i = d.i;
|
|
232
|
-
if (d.nested && d.values) {
|
|
233
|
-
var calcPoint = function calcPoint(d, i) {
|
|
234
|
-
if (_this._discrete === "x") return [
|
|
235
|
-
_this._x(d, i),
|
|
236
|
-
cursor[1]
|
|
237
|
-
];
|
|
238
|
-
else if (_this._discrete === "y") return [
|
|
239
|
-
cursor[0],
|
|
240
|
-
_this._y(d, i)
|
|
241
|
-
];
|
|
242
|
-
else return [
|
|
243
|
-
_this._x(d, i),
|
|
244
|
-
_this._y(d, i)
|
|
245
|
-
];
|
|
246
|
-
};
|
|
247
|
-
var cursor = pointer(event, _this._select.node()), values = d.values.map(function(d) {
|
|
248
|
-
return pointDistance(cursor, calcPoint(d, i));
|
|
249
|
-
});
|
|
250
|
-
i = values.indexOf(min(values));
|
|
251
|
-
d = d.values[i];
|
|
252
|
-
}
|
|
253
|
-
_this._on[events[e]].bind(_this)(d, i, undefined, event);
|
|
254
|
-
});
|
|
255
|
-
};
|
|
256
|
-
var _this = this;
|
|
257
|
-
var events = Object.keys(this._on);
|
|
258
|
-
for(var e = 0; e < events.length; e++)_loop(e);
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
/**
|
|
263
|
-
Provides the updated styling to the given shape elements.
|
|
264
|
-
|
|
265
|
-
@private
|
|
266
|
-
*/ key: "_updateStyle",
|
|
267
|
-
value: function _updateStyle(elem, style) {
|
|
268
|
-
var that = this;
|
|
269
|
-
if (elem.size() && elem.node().tagName === "g") elem = elem.selectAll("*");
|
|
270
|
-
/**
|
|
271
|
-
Determines whether a shape is a nested collection of data points, and uses the appropriate data and index for the given function context.
|
|
272
|
-
@param d data point
|
|
273
|
-
@param i index
|
|
274
|
-
@private
|
|
275
|
-
*/ function styleLogic(d, i) {
|
|
276
|
-
return typeof this !== "function" ? this : d.nested && d.key && d.values ? this(d.values[0], that._data.indexOf(d.values[0])) : this(d, i);
|
|
277
|
-
}
|
|
278
|
-
var styleObject = {};
|
|
279
|
-
for(var key in style){
|
|
280
|
-
if (({}).hasOwnProperty.call(style, key)) {
|
|
281
|
-
styleObject[key] = styleLogic.bind(style[key]);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
285
|
-
elem.transition().duration(0).call(attrize, styleObject);
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
/**
|
|
290
|
-
Provides the default styling to the shape elements.
|
|
291
|
-
@param elem @private
|
|
292
|
-
*/ key: "_applyStyle",
|
|
293
|
-
value: function _applyStyle(elem) {
|
|
294
|
-
var _this = this;
|
|
295
|
-
var that = this;
|
|
296
|
-
if (elem.size() && elem.node().tagName === "g") elem = elem.selectAll("*");
|
|
297
|
-
/**
|
|
298
|
-
Determines whether a shape is a nested collection of data points, and uses the appropriate data and index for the given function context.
|
|
299
|
-
@param d data point
|
|
300
|
-
@param i index
|
|
301
|
-
@private
|
|
302
|
-
*/ function styleLogic(d, i) {
|
|
303
|
-
return typeof this !== "function" ? this : d.nested && d.key && d.values ? this(d.values[0], that._data.indexOf(d.values[0])) : this(d, i);
|
|
304
|
-
}
|
|
305
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
306
|
-
elem.attr("fill", function(d, i) {
|
|
307
|
-
var texture = _this._getTextureKey.bind(_this)(d, i);
|
|
308
|
-
return texture ? _this._textureDefs[texture].url() : styleLogic.bind(_this._fill)(d, i);
|
|
309
|
-
}).attr("fill-opacity", styleLogic.bind(this._fillOpacity)).attr("rx", styleLogic.bind(this._rx)).attr("ry", styleLogic.bind(this._ry)).attr("stroke", styleLogic.bind(this._stroke)).attr("stroke-dasharray", styleLogic.bind(this._strokeDasharray)).attr("stroke-linecap", styleLogic.bind(this._strokeLinecap)).attr("stroke-opacity", styleLogic.bind(this._strokeOpacity)).attr("stroke-width", styleLogic.bind(this._strokeWidth)).attr("vector-effect", styleLogic.bind(this._vectorEffect));
|
|
310
|
-
}
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
/**
|
|
314
|
-
Calculates the transform for the group elements.
|
|
315
|
-
@param elem @private
|
|
316
|
-
*/ key: "_applyTransform",
|
|
317
|
-
value: function _applyTransform(elem) {
|
|
318
|
-
var _this = this;
|
|
319
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
320
|
-
elem.attr("transform", function(d, i) {
|
|
321
|
-
return "\n translate(".concat(d.__d3plusShape__ ? d.translate ? d.translate : "".concat(_this._x(d.data, d.i), ",").concat(_this._y(d.data, d.i)) : "".concat(_this._x(d, i), ",").concat(_this._y(d, i)), ")\n scale(").concat(d.__d3plusShape__ ? d.scale || _this._scale(d.data, d.i) : _this._scale(d, i), ")\n rotate(").concat(d.__d3plusShape__ ? d.rotate ? d.rotate : _this._rotate(d.data || d, d.i) : _this._rotate(d.data || d, d.i), ")");
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
/**
|
|
327
492
|
Returns a full JSON string of the texture config for a given data point.
|
|
328
493
|
|
|
329
494
|
@private
|
|
330
495
|
*/ key: "_getTextureKey",
|
|
331
496
|
value: function _getTextureKey(d, i) {
|
|
332
497
|
var _this = this;
|
|
333
|
-
var textureVal = this.
|
|
498
|
+
var textureVal = this.schema.texture(d, i);
|
|
334
499
|
if (!textureVal) return false;
|
|
335
500
|
/**
|
|
336
501
|
Determines whether a shape is a nested collection of data points, and uses the appropriate data and index for the given function context.
|
|
@@ -338,14 +503,14 @@ var Shape = /*#__PURE__*/ function(BaseClass) {
|
|
|
338
503
|
*/ var styleLogic = function styleLogic(_) {
|
|
339
504
|
return typeof _ !== "function" ? _ : d.nested && d.key && d.values ? _(d.values[0], _this._data.indexOf(d.values[0])) : _(d, i);
|
|
340
505
|
};
|
|
341
|
-
var fallback = this.
|
|
506
|
+
var fallback = this.schema.textureDefault;
|
|
342
507
|
var texture;
|
|
343
508
|
if (!isObject(textureVal)) texture = {
|
|
344
509
|
texture: textureVal
|
|
345
510
|
};
|
|
346
511
|
else texture = textureVal;
|
|
347
|
-
if (!texture.background) texture.background = styleLogic(this.
|
|
348
|
-
if (!texture.stroke && !fallback.stroke) texture.stroke = styleLogic(this.
|
|
512
|
+
if (!texture.background) texture.background = styleLogic(this.schema.fill);
|
|
513
|
+
if (!texture.stroke && !fallback.stroke) texture.stroke = styleLogic(this.schema.stroke);
|
|
349
514
|
var pathNames = [
|
|
350
515
|
"squares",
|
|
351
516
|
"nylon",
|
|
@@ -386,359 +551,335 @@ var Shape = /*#__PURE__*/ function(BaseClass) {
|
|
|
386
551
|
},
|
|
387
552
|
{
|
|
388
553
|
/**
|
|
389
|
-
|
|
554
|
+
Adds labels to each shape group.
|
|
390
555
|
@private
|
|
391
|
-
*/ key: "
|
|
392
|
-
value: function
|
|
393
|
-
|
|
394
|
-
this
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
select(this).call(that._applyStyle.bind(that));
|
|
412
|
-
else select(this).call(that._updateStyle.bind(that, select(this), that._activeStyle));
|
|
413
|
-
}
|
|
414
|
-
}
|
|
556
|
+
*/ key: "_buildLabelData",
|
|
557
|
+
value: function _buildLabelData() {
|
|
558
|
+
// Delegates to the pure `buildLabelData()` helper. The helper
|
|
559
|
+
// takes the same inputs `this` exposes but works without a Shape
|
|
560
|
+
// instance — emit functions or other callers that need only the
|
|
561
|
+
// label-record layout can call it directly without instantiating
|
|
562
|
+
// a Shape in compute mode.
|
|
563
|
+
// All Shape methods bound to `this` before handing them to the pure
|
|
564
|
+
// helper — subclasses (e.g. Line._dataFilter) reach for `this.schema.id`
|
|
565
|
+
// and friends inside their bodies.
|
|
566
|
+
return buildLabelData({
|
|
567
|
+
data: this._data,
|
|
568
|
+
dataFilter: this._dataFilter ? this._dataFilter.bind(this) : undefined,
|
|
569
|
+
label: this.schema.label,
|
|
570
|
+
labelBounds: this.schema.labelBounds ? this.schema.labelBounds.bind(this) : undefined,
|
|
571
|
+
x: this.schema.x,
|
|
572
|
+
y: this.schema.y,
|
|
573
|
+
aes: this._aes.bind(this),
|
|
574
|
+
rotate: this.schema.rotate,
|
|
575
|
+
id: this.schema.id
|
|
415
576
|
});
|
|
416
|
-
// this._renderImage();
|
|
417
|
-
// this._renderLabels();
|
|
418
|
-
this._group.selectAll("g.d3plus-".concat(this._name, "-shape, g.d3plus-").concat(this._name, "-image, g.d3plus-").concat(this._name, "-text")).attr("opacity", this._hover ? this._hoverOpacity : this._active ? this._activeOpacity : 1);
|
|
419
577
|
}
|
|
420
578
|
},
|
|
421
579
|
{
|
|
422
580
|
/**
|
|
423
|
-
|
|
581
|
+
Renders the current Shape to the page. If a *callback* is specified, it will be called once the shapes are done drawing.
|
|
582
|
+
@param callback Optional callback invoked after rendering completes.
|
|
583
|
+
*/ /**
|
|
584
|
+
Resolves a style accessor for a data point, mirroring the nested-data logic
|
|
585
|
+
of _applyStyle so scene output matches DOM rendering.
|
|
424
586
|
@private
|
|
425
|
-
*/ key: "
|
|
426
|
-
value: function
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
var d3plusType = select(this).classed("d3plus-textBox") ? "textBox" : select(this).classed("d3plus-Image") ? "Image" : "Shape";
|
|
434
|
-
if (d3plusType === "textBox") d = d.data;
|
|
435
|
-
if (d.__d3plusShape__ || d.__d3plus__) {
|
|
436
|
-
while(d && (d.__d3plusShape__ || d.__d3plus__)){
|
|
437
|
-
i = d.i;
|
|
438
|
-
d = d.data;
|
|
439
|
-
}
|
|
440
|
-
} else i = that._data.indexOf(d);
|
|
441
|
-
var notHovering = !that._hover || typeof that._hover !== "function" || !that._hover(d, i);
|
|
442
|
-
var group = notHovering ? parent : that._hoverGroup.node();
|
|
443
|
-
if (group !== this.parentNode) {
|
|
444
|
-
var afterIndex = d3plusType === "textBox" ? findLastIndexWithClass(group.childNodes, [
|
|
445
|
-
"d3plus-Image",
|
|
446
|
-
"d3plus-Shape"
|
|
447
|
-
]) : d3plusType === "Image" ? findLastIndexWithClass(group.childNodes, [
|
|
448
|
-
"d3plus-Shape"
|
|
449
|
-
]) : -1;
|
|
450
|
-
if (notHovering) group.appendChild(this);
|
|
451
|
-
else if (afterIndex === -1) group.prepend(this);
|
|
452
|
-
else group.childNodes[afterIndex].after(this);
|
|
453
|
-
}
|
|
454
|
-
if (this.className.baseVal.includes("d3plus-Shape")) {
|
|
455
|
-
if (parent === group) // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
456
|
-
select(this).call(that._applyStyle.bind(that));
|
|
457
|
-
else select(this).call(that._updateStyle.bind(that, select(this), that._hoverStyle));
|
|
458
|
-
}
|
|
459
|
-
});
|
|
460
|
-
// this._renderImage();
|
|
461
|
-
// this._renderLabels();
|
|
462
|
-
this._group.selectAll("g.d3plus-".concat(this._name, "-shape, g.d3plus-").concat(this._name, "-image, g.d3plus-").concat(this._name, "-text")).attr("opacity", this._hover ? this._hoverOpacity : this._active ? this._activeOpacity : 1);
|
|
587
|
+
*/ key: "_styleVal",
|
|
588
|
+
value: function _styleVal(fn, d, i) {
|
|
589
|
+
if (typeof fn !== "function") return fn;
|
|
590
|
+
if (d.nested && d.key && d.values) {
|
|
591
|
+
var first = d.values[0];
|
|
592
|
+
return fn(first, this._data.indexOf(first));
|
|
593
|
+
}
|
|
594
|
+
return fn(d, i);
|
|
463
595
|
}
|
|
464
596
|
},
|
|
465
597
|
{
|
|
466
598
|
/**
|
|
467
|
-
|
|
599
|
+
Builds the resolved Transform for a data point, mirroring _applyTransform.
|
|
468
600
|
@private
|
|
469
|
-
*/ key: "
|
|
470
|
-
value: function
|
|
471
|
-
var
|
|
472
|
-
var
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
__d3plus__: true,
|
|
492
|
-
data: d,
|
|
493
|
-
height: height,
|
|
494
|
-
i: i,
|
|
495
|
-
id: _this._id(d, i),
|
|
496
|
-
url: url,
|
|
497
|
-
width: width,
|
|
498
|
-
x: x + -width / 2,
|
|
499
|
-
y: y + -height / 2
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
|
-
this._backgroundImageClass.data(imageData).duration(this._duration).opacity(this._nestWrapper(this._opacity)).pointerEvents("none").select(elem("g.d3plus-".concat(this._name, "-image"), {
|
|
505
|
-
parent: this._group,
|
|
506
|
-
update: {
|
|
507
|
-
opacity: this._active ? this._activeOpacity : 1
|
|
508
|
-
}
|
|
509
|
-
}).node()).render();
|
|
601
|
+
*/ key: "_sceneTransform",
|
|
602
|
+
value: function _sceneTransform(d, i) {
|
|
603
|
+
var wrapped = Boolean(d.__d3plusShape__);
|
|
604
|
+
var dd = wrapped ? d.data : d;
|
|
605
|
+
var ii = wrapped ? d.i : i;
|
|
606
|
+
var x, y;
|
|
607
|
+
if (wrapped && d.translate) {
|
|
608
|
+
var _String_split_map = _sliced_to_array(String(d.translate).split(",").map(Number), 2), tx = _String_split_map[0], ty = _String_split_map[1];
|
|
609
|
+
x = tx;
|
|
610
|
+
y = ty;
|
|
611
|
+
} else {
|
|
612
|
+
x = Number(this.schema.x(dd, ii));
|
|
613
|
+
y = Number(this.schema.y(dd, ii));
|
|
614
|
+
}
|
|
615
|
+
var scale = wrapped && d.scale !== undefined ? Number(d.scale) : Number(this.schema.scale(dd, ii));
|
|
616
|
+
var rotate = wrapped && d.rotate !== undefined ? Number(d.rotate) : Number(this.schema.rotate(d.data || d, ii));
|
|
617
|
+
return {
|
|
618
|
+
x: x,
|
|
619
|
+
y: y,
|
|
620
|
+
scale: scale,
|
|
621
|
+
rotate: rotate
|
|
622
|
+
};
|
|
510
623
|
}
|
|
511
624
|
},
|
|
512
625
|
{
|
|
513
626
|
/**
|
|
514
|
-
|
|
627
|
+
Builds the resolved Paint for a data point, mirroring _applyStyle.
|
|
628
|
+
Texture fills are encoded as a stable "pattern:<key>" token at this
|
|
629
|
+
layer; the backend renderers (`SvgRenderer._resolveFill`,
|
|
630
|
+
`CanvasRenderer._resolveFill`) materialize them into a real SVG
|
|
631
|
+
pattern or a Canvas image pattern. The two-stage resolve is
|
|
632
|
+
intentional — Shapes stay backend-free, and texture
|
|
633
|
+
materialization happens once per renderer instead of per-shape.
|
|
634
|
+
@private
|
|
635
|
+
*/ key: "_scenePaint",
|
|
636
|
+
value: function _scenePaint(d, i) {
|
|
637
|
+
// A texture resolves to a stable "pattern:<key>" token (the same JSON config
|
|
638
|
+
// render() uses); each backend materializes or degrades it.
|
|
639
|
+
var textureKey = this._getTextureKey(d, i);
|
|
640
|
+
return {
|
|
641
|
+
fill: textureKey ? "pattern:".concat(textureKey) : strOrUndef(this._styleVal(this.schema.fill, d, i)),
|
|
642
|
+
fillOpacity: numOrUndef(this._styleVal(this.schema.fillOpacity, d, i)),
|
|
643
|
+
stroke: strOrUndef(this._styleVal(this.schema.stroke, d, i)),
|
|
644
|
+
strokeWidth: numOrUndef(this._styleVal(this.schema.strokeWidth, d, i)),
|
|
645
|
+
strokeOpacity: numOrUndef(this._styleVal(this.schema.strokeOpacity, d, i)),
|
|
646
|
+
strokeDasharray: parseDash(this._styleVal(this.schema.strokeDasharray, d, i)),
|
|
647
|
+
strokeLinecap: strOrUndef(this._styleVal(this.schema.strokeLinecap, d, i)),
|
|
648
|
+
vectorEffect: strOrUndef(this._styleVal(this.schema.vectorEffect, d, i)),
|
|
649
|
+
shapeRendering: strOrUndef(this._nestWrapper(this.schema.shapeRendering)(d, i)),
|
|
650
|
+
opacity: numOrUndef(this._nestWrapper(this.schema.opacity)(d, i))
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
/**
|
|
656
|
+
Returns the geometry-specific scene fields for a data point. Overridden by
|
|
657
|
+
each shape subclass; the base provides none.
|
|
515
658
|
@private
|
|
516
|
-
*/ key: "
|
|
517
|
-
value: function
|
|
659
|
+
*/ key: "_sceneGeometry",
|
|
660
|
+
value: function _sceneGeometry(_d, _i) {
|
|
661
|
+
return null;
|
|
662
|
+
}
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
/**
|
|
666
|
+
Produces a backend-agnostic scene graph for this shape's data, reusing the
|
|
667
|
+
same accessors render() applies to the DOM. This is the migration seam toward
|
|
668
|
+
the @d3plus/render pluggable backends; it has no effect on render().
|
|
669
|
+
*/ key: "toScene",
|
|
670
|
+
value: function toScene() {
|
|
518
671
|
var _this = this;
|
|
519
|
-
var
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
672
|
+
var _children;
|
|
673
|
+
var data = this._data;
|
|
674
|
+
if (this._dataFilter) data = this._dataFilter(data);
|
|
675
|
+
var children = [];
|
|
676
|
+
// Build the backgroundImage data for emission below. Each datum that
|
|
677
|
+
// resolves to a non-false `backgroundImage(d, i)` becomes an
|
|
678
|
+
// ImageNode positioned at the shape's geometry.
|
|
679
|
+
var imageData = [];
|
|
680
|
+
// A `sort` comparator becomes per-datum `z` ranks rather than a reorder of
|
|
681
|
+
// `data`: the render backends sort each group's children ascending by `z`
|
|
682
|
+
// (stably), so a lower rank paints first (behind) and a higher rank paints
|
|
683
|
+
// last (on top) — the same back-to-front meaning `.sort()` has always had,
|
|
684
|
+
// without disturbing the keyed data-join order that drives transitions.
|
|
685
|
+
var rank = sortRanks(data, this.schema.sort);
|
|
686
|
+
data.forEach(function(d, i) {
|
|
687
|
+
var geom = _this._sceneGeometry(d, i);
|
|
688
|
+
if (!geom) return;
|
|
689
|
+
var key = _this._nestWrapper(_this.schema.id)(d, i);
|
|
690
|
+
var datum = d.__d3plusShape__ ? d.data : d;
|
|
691
|
+
var transform = _this._sceneTransform(d, i);
|
|
692
|
+
// Push the hit area (if any) before the geometry so it sits behind it.
|
|
693
|
+
if (_this.schema.hitArea) {
|
|
694
|
+
var ha = hitAreaNode(_this.schema.hitArea, d, i, _this._aes(d, i), key, datum, _this._name, transform);
|
|
695
|
+
// Share the datum's rank so the hit area stays paired just behind its
|
|
696
|
+
// own geometry (equal `z`, kept in push order by the stable sort).
|
|
697
|
+
if (ha) children.push(rank ? _object_spread_props(_object_spread({}, ha), {
|
|
698
|
+
z: rank[i]
|
|
699
|
+
}) : ha);
|
|
525
700
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
i = d.i;
|
|
537
|
-
}
|
|
538
|
-
for(var l = 0; l < labels.length; l++){
|
|
539
|
-
var b = bounds.constructor === Array ? bounds[l] : Object.assign({}, bounds);
|
|
540
|
-
var rotate = _this._rotate(d, i);
|
|
541
|
-
var labelConfig = d.labelConfig;
|
|
542
|
-
var r = labelConfig && labelConfig.rotate ? labelConfig.rotate : bounds.angle !== undefined ? bounds.angle : 0;
|
|
543
|
-
r += rotate;
|
|
544
|
-
var rotateAnchor = rotate !== 0 ? [
|
|
545
|
-
b.x * -1 || 0,
|
|
546
|
-
b.y * -1 || 0
|
|
547
|
-
] : [
|
|
548
|
-
b.width / 2,
|
|
549
|
-
b.height / 2
|
|
550
|
-
];
|
|
551
|
-
labelData.push({
|
|
552
|
-
__d3plus__: true,
|
|
553
|
-
data: d,
|
|
554
|
-
height: b.height,
|
|
555
|
-
l: l,
|
|
556
|
-
id: "".concat(_this._id(d, i), "_").concat(l),
|
|
557
|
-
r: r,
|
|
558
|
-
rotateAnchor: rotateAnchor,
|
|
559
|
-
text: labels[l],
|
|
560
|
-
width: b.width,
|
|
561
|
-
x: x + b.x,
|
|
562
|
-
y: y + b.y
|
|
563
|
-
});
|
|
564
|
-
}
|
|
701
|
+
children.push(_object_spread(_object_spread_props(_object_spread({}, geom), {
|
|
702
|
+
key: key,
|
|
703
|
+
datum: datum,
|
|
704
|
+
index: i,
|
|
705
|
+
shapeType: _this._name,
|
|
706
|
+
paint: _this._scenePaint(d, i),
|
|
707
|
+
transform: transform,
|
|
708
|
+
aria: {
|
|
709
|
+
role: strOrUndef(_this._nestWrapper(_this.schema.role)(d, i)),
|
|
710
|
+
label: strOrUndef(_this._nestWrapper(_this.schema.ariaLabel)(d, i))
|
|
565
711
|
}
|
|
712
|
+
}), rank ? {
|
|
713
|
+
z: rank[i]
|
|
714
|
+
} : {}));
|
|
715
|
+
// backgroundImage: collect a per-datum image when the accessor
|
|
716
|
+
// returns a truthy URL. The image is sized to the shape's
|
|
717
|
+
// geometry (preferring width/height fields when present).
|
|
718
|
+
var bg = _this._nestWrapper(_this.schema.backgroundImage)(d, i);
|
|
719
|
+
if (bg) {
|
|
720
|
+
var _t_x, _t_y;
|
|
721
|
+
var g = geom;
|
|
722
|
+
// Shape geometry is origin-centered; its on-screen position lives in
|
|
723
|
+
// the node transform. The background image is emitted as a flat sibling
|
|
724
|
+
// (no transform), so bake the shape's translate into the image x/y —
|
|
725
|
+
// otherwise every image lands at the origin (top-left).
|
|
726
|
+
var t = _this._sceneTransform(d, i);
|
|
727
|
+
var w = typeof g.width === "number" ? g.width : undefined;
|
|
728
|
+
var h = typeof g.height === "number" ? g.height : undefined;
|
|
729
|
+
var cx = typeof g.cx === "number" ? g.cx : typeof g.x === "number" ? g.x : 0;
|
|
730
|
+
var cy = typeof g.cy === "number" ? g.cy : typeof g.y === "number" ? g.y : 0;
|
|
731
|
+
var r = typeof g.r === "number" ? g.r : undefined;
|
|
732
|
+
var iw = w !== null && w !== void 0 ? w : r != null ? r * 2 : 0;
|
|
733
|
+
var ih = h !== null && h !== void 0 ? h : r != null ? r * 2 : 0;
|
|
734
|
+
imageData.push({
|
|
735
|
+
__d3plus__: true,
|
|
736
|
+
data: d,
|
|
737
|
+
i: i,
|
|
738
|
+
id: _this._nestWrapper(_this.schema.id)(d, i),
|
|
739
|
+
url: bg,
|
|
740
|
+
x: ((_t_x = t.x) !== null && _t_x !== void 0 ? _t_x : 0) + cx - iw / 2,
|
|
741
|
+
y: ((_t_y = t.y) !== null && _t_y !== void 0 ? _t_y : 0) + cy - ih / 2,
|
|
742
|
+
width: iw,
|
|
743
|
+
height: ih
|
|
744
|
+
});
|
|
566
745
|
}
|
|
567
746
|
});
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
.
|
|
747
|
+
// Emit background images AFTER shape children so they paint above the
|
|
748
|
+
// shape's fill — matches the DOM order where the <image> was
|
|
749
|
+
// appended as a sibling of the shape.
|
|
750
|
+
if (imageData.length) (_children = children).push.apply(_children, _to_consumable_array(emitBackgroundImages(this._backgroundImageClass, imageData, rank, data.length)));
|
|
751
|
+
// NOTE: Labels are NOT pushed here. The canonical aggregation point is
|
|
752
|
+
// `emitHelpers.collectComputed(shape)`, which appends `shape.toScene()`
|
|
753
|
+
// AND `shape._labelClass.toScene()` independently. Pushing labels here
|
|
754
|
+
// too would emit them twice in every chart that calls collectComputed
|
|
755
|
+
// (Pie/Donut/Pack/Treemap/Network/Priestley/Radar/RadialMatrix/Geomap…).
|
|
756
|
+
// Standalone shape.render() consumers (no collectComputed wrapper) get
|
|
757
|
+
// labels through Shape.render's own SvgRenderer path below.
|
|
758
|
+
return {
|
|
759
|
+
type: "group",
|
|
760
|
+
key: "".concat(this._name, "-group"),
|
|
761
|
+
children: children
|
|
762
|
+
};
|
|
579
763
|
}
|
|
580
764
|
},
|
|
581
765
|
{
|
|
582
|
-
|
|
583
|
-
Renders the current Shape to the page. If a *callback* is specified, it will be called once the shapes are done drawing.
|
|
584
|
-
@param callback Optional callback invoked after rendering completes.
|
|
585
|
-
*/ key: "render",
|
|
766
|
+
key: "render",
|
|
586
767
|
value: function render(callback) {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
768
|
+
// Populate the label TextBox so toScene() reads correct label data. The
|
|
769
|
+
// label class is always in compute mode — the scene path materializes text.
|
|
770
|
+
var lc = this._labelClass;
|
|
771
|
+
if (lc && typeof lc.renderMode === "function") lc.renderMode("compute");
|
|
772
|
+
// Apply Shape's labelConfig (fontColor, fontResize, padding, textAnchor,
|
|
773
|
+
// verticalAlign, fontSize, …) to the underlying TextBox. Function
|
|
774
|
+
// accessors receive the LABEL RECORD (with `d.data` = source
|
|
775
|
+
// datum, `d.l` = which label index in a multi-label-per-datum
|
|
776
|
+
// setup, `d.text` = label text, etc.). That gives consumers like
|
|
777
|
+
// Treemap (two labels per cell — title + share %) the context to
|
|
778
|
+
// vary anchor / color / etc. based on which label they're styling.
|
|
779
|
+
// Shape's default `fontColor` uses `this.schema.fill(d, i)` — since
|
|
780
|
+
// `fill` is the configPrep-wrapped accessor, it unwraps `d.data`
|
|
781
|
+
// back to the source datum automatically before invoking the user
|
|
782
|
+
// fill function.
|
|
783
|
+
this._labelClass.config(this.schema.labelConfig);
|
|
784
|
+
this._labelClass.data(this._buildLabelData());
|
|
785
|
+
if (this.schema.renderMode === "compute") {
|
|
786
|
+
// A Viz pipeline is driving this shape — Viz.renderScene composes the
|
|
787
|
+
// whole chart's scene itself, so don't spin up our own SvgRenderer.
|
|
788
|
+
if (callback) setTimeout(callback, 0);
|
|
789
|
+
return this;
|
|
596
790
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
791
|
+
// Standalone shape rendering: route the shape's own toScene() through
|
|
792
|
+
// SvgRenderer. Preserves `new Rect().render()` ergonomics with no
|
|
793
|
+
// d3-selection DOM.
|
|
794
|
+
if (this._select === undefined && typeof document !== "undefined") {
|
|
795
|
+
var div = document.createElement("div");
|
|
796
|
+
div.style.cssText = "display:block;";
|
|
797
|
+
document.body.appendChild(div);
|
|
798
|
+
this.select(div);
|
|
603
799
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
var
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
800
|
+
if (this._select) {
|
|
801
|
+
var sel = this._select;
|
|
802
|
+
// `_select` is a D3Selection, but the standalone path historically also
|
|
803
|
+
// accepted a raw element; handle both without widening to `any`.
|
|
804
|
+
var node = sel && typeof sel.node === "function" ? sel.node() : sel;
|
|
805
|
+
if (node) {
|
|
806
|
+
var tag = (node.tagName || "").toLowerCase();
|
|
807
|
+
var isSvg = tag === "svg";
|
|
808
|
+
// Explicit numeric size first: an <svg>'s width/height attribute, or a
|
|
809
|
+
// non-svg container's client box.
|
|
810
|
+
var rawW = isSvg ? Number(node.getAttribute("width")) : node.clientWidth;
|
|
811
|
+
var rawH = isSvg ? Number(node.getAttribute("height")) : node.clientHeight;
|
|
812
|
+
// When that isn't a usable number — e.g. width="100%" (Number → NaN)
|
|
813
|
+
// or a 0-size box — measure the container's real rendered size,
|
|
814
|
+
// walking up to the first constrained ancestor. Only fall back to the
|
|
815
|
+
// static 400x300 when nothing is measurable (e.g. no layout in jsdom).
|
|
816
|
+
var _ref = _sliced_to_array(rawW && rawH ? [
|
|
817
|
+
rawW,
|
|
818
|
+
rawH
|
|
819
|
+
] : getSize(node), 2), measuredW = _ref[0], measuredH = _ref[1];
|
|
820
|
+
var width = rawW || measuredW || 400;
|
|
821
|
+
var height = rawH || measuredH || 300;
|
|
822
|
+
// Combine the shape's scene + label children. toScene() deliberately
|
|
823
|
+
// omits labels (collectComputed is the canonical aggregator for the
|
|
824
|
+
// chart pipeline); for the standalone render() path we add them here
|
|
825
|
+
// so `new Rect().data(...).render()` still produces label text.
|
|
826
|
+
var shapeGroup = this.toScene();
|
|
827
|
+
var labelChildren = [];
|
|
828
|
+
if (this._labelClass && typeof this._labelClass.toScene === "function" && this._labelClass._data && this._labelClass._data.length) {
|
|
829
|
+
var _labelChildren;
|
|
830
|
+
(_labelChildren = labelChildren).push.apply(_labelChildren, _to_consumable_array(this._labelClass.toScene().children));
|
|
831
|
+
}
|
|
832
|
+
var root = _object_spread_props(_object_spread({}, shapeGroup), {
|
|
833
|
+
children: _to_consumable_array(shapeGroup.children).concat(_to_consumable_array(labelChildren))
|
|
834
|
+
});
|
|
835
|
+
var scene = {
|
|
836
|
+
root: root,
|
|
837
|
+
width: width,
|
|
838
|
+
height: height
|
|
622
839
|
};
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
840
|
+
// Tear down any previous SvgRenderer so its DOM listeners + timers
|
|
841
|
+
// are cleared instead of leaking on every re-render.
|
|
842
|
+
var prev = this._sceneRenderer;
|
|
843
|
+
if (prev && typeof prev.destroy === "function") prev.destroy();
|
|
844
|
+
// Caller's element is preserved (downstream selectors still find it);
|
|
845
|
+
// we mount SvgRenderer INSIDE it. When `node` is a <g> the result is
|
|
846
|
+
// a nested <svg>-in-<g>, which is valid SVG but visually unusual —
|
|
847
|
+
// chart code reaches this path only via the Box/Whisker full-mode
|
|
848
|
+
// fallback, which is not the recommended flow (compute mode is).
|
|
849
|
+
// Only wipe children when this is the FIRST time we're mounting
|
|
850
|
+
// here — re-renders into the same node would otherwise destroy any
|
|
851
|
+
// labels/auxiliary DOM the caller put alongside.
|
|
852
|
+
if (!prev) {
|
|
853
|
+
while(node.firstChild)node.removeChild(node.firstChild);
|
|
854
|
+
}
|
|
855
|
+
var renderer = new SvgRenderer();
|
|
856
|
+
renderer.mount({
|
|
857
|
+
container: node,
|
|
858
|
+
width: width,
|
|
859
|
+
height: height
|
|
860
|
+
});
|
|
861
|
+
renderer.drawScene(scene);
|
|
862
|
+
this._sceneRenderer = renderer;
|
|
646
863
|
}
|
|
647
|
-
}).selectAll(".d3plus-".concat(this._name)).data(data, key);
|
|
648
|
-
// Orders and transforms the updating Shapes.
|
|
649
|
-
update.order();
|
|
650
|
-
if (this._duration) {
|
|
651
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
652
|
-
update.transition(this._transition).call(this._applyTransform.bind(this));
|
|
653
|
-
} else {
|
|
654
|
-
update.call(this._applyTransform.bind(this));
|
|
655
864
|
}
|
|
656
|
-
|
|
657
|
-
var enter = this._enter = update.enter().append(this._tagName).attr("class", function(d, i) {
|
|
658
|
-
return "d3plus-Shape d3plus-".concat(_this._name, " d3plus-id-").concat(strip(_this._nestWrapper(_this._id)(d, i)));
|
|
659
|
-
}).call(this._applyTransform.bind(this)).attr("aria-label", this._ariaLabel).attr("role", this._role).attr("opacity", this._nestWrapper(this._opacity));
|
|
660
|
-
var enterUpdate = enter.merge(update);
|
|
661
|
-
var enterUpdateRender = enterUpdate.attr("shape-rendering", this._nestWrapper(this._shapeRendering));
|
|
662
|
-
if (this._duration) {
|
|
663
|
-
enterUpdateRender = enterUpdateRender.attr("pointer-events", "none").transition(this._transition).transition().delay(100).attr("pointer-events", this._pointerEvents);
|
|
664
|
-
}
|
|
665
|
-
enterUpdateRender.attr("opacity", this._nestWrapper(this._opacity));
|
|
666
|
-
// Makes the exit state of the group selection accessible.
|
|
667
|
-
var exit = this._exit = update.exit();
|
|
668
|
-
if (this._duration) exit.transition().delay(this._duration).remove();
|
|
669
|
-
else exit.remove();
|
|
670
|
-
this._renderImage();
|
|
671
|
-
this._renderLabels();
|
|
672
|
-
this._hoverGroup = elem("g.d3plus-".concat(this._name, "-hover"), {
|
|
673
|
-
parent: this._group
|
|
674
|
-
});
|
|
675
|
-
this._activeGroup = elem("g.d3plus-".concat(this._name, "-active"), {
|
|
676
|
-
parent: this._group
|
|
677
|
-
});
|
|
678
|
-
var hitAreas = this._group.selectAll(".d3plus-HitArea").data(this._hitArea && Object.keys(this._on).length ? data : [], key);
|
|
679
|
-
hitAreas.order().call(this._applyTransform.bind(this));
|
|
680
|
-
var isLine = this._name === "Line";
|
|
681
|
-
if (isLine) {
|
|
682
|
-
var curve = this._curve.bind(this)(this.config());
|
|
683
|
-
isLine && // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
684
|
-
this._path.curve(// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
685
|
-
paths["curve".concat(curve.charAt(0).toUpperCase()).concat(curve.slice(1))]).defined(this._defined).x(this._x).y(this._y);
|
|
686
|
-
}
|
|
687
|
-
var hitEnter = hitAreas.enter().append(isLine ? "path" : "rect").attr("class", function(d, i) {
|
|
688
|
-
return "d3plus-HitArea d3plus-id-".concat(strip(_this._nestWrapper(_this._id)(d, i)));
|
|
689
|
-
}).attr("fill", "black").attr("stroke", "black").attr("pointer-events", "painted").attr("opacity", 0).call(this._applyTransform.bind(this));
|
|
690
|
-
var that = this;
|
|
691
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
692
|
-
var hitUpdates = hitAreas.merge(hitEnter).each(function(d) {
|
|
693
|
-
var i = that._data.indexOf(d);
|
|
694
|
-
var h = that._hitArea(d, i, that._aes(d, i));
|
|
695
|
-
return h && !(that._name === "Line" && parseFloat(that._strokeWidth(d, i)) > 10) ? select(this).call(attrize, h) : select(this).remove();
|
|
696
|
-
});
|
|
697
|
-
hitAreas.exit().remove();
|
|
698
|
-
this._applyEvents(this._hitArea ? hitUpdates : enterUpdate);
|
|
699
|
-
setTimeout(function() {
|
|
700
|
-
if (_this._active) _this._renderActive();
|
|
701
|
-
else if (_this._hover) _this._renderHover();
|
|
702
|
-
if (callback) callback();
|
|
703
|
-
}, this._duration + 100);
|
|
865
|
+
if (callback) setTimeout(callback, 0);
|
|
704
866
|
return this;
|
|
705
867
|
}
|
|
706
868
|
},
|
|
707
869
|
{
|
|
708
870
|
key: "active",
|
|
709
871
|
value: function active(_) {
|
|
710
|
-
if (!arguments.length || _ === undefined) return this.
|
|
711
|
-
this.
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
// this._renderLabels();
|
|
715
|
-
this._renderActive();
|
|
716
|
-
}
|
|
872
|
+
if (!arguments.length || _ === undefined) return this.schema.active;
|
|
873
|
+
this.schema.active = _;
|
|
874
|
+
// v4: active/hover visuals come from the scene path's paint recomputation
|
|
875
|
+
// on the next render(); no DOM mutation here.
|
|
717
876
|
return this;
|
|
718
877
|
}
|
|
719
878
|
},
|
|
720
|
-
{
|
|
721
|
-
key: "activeOpacity",
|
|
722
|
-
value: function activeOpacity(_) {
|
|
723
|
-
return arguments.length ? (this._activeOpacity = _, this) : this._activeOpacity;
|
|
724
|
-
}
|
|
725
|
-
},
|
|
726
879
|
{
|
|
727
880
|
key: "activeStyle",
|
|
728
881
|
value: function activeStyle(_) {
|
|
729
|
-
return arguments.length ? (this.
|
|
730
|
-
}
|
|
731
|
-
},
|
|
732
|
-
{
|
|
733
|
-
key: "ariaLabel",
|
|
734
|
-
value: function ariaLabel(_) {
|
|
735
|
-
return _ !== undefined ? (this._ariaLabel = typeof _ === "function" ? _ : constant(_), this) : this._ariaLabel;
|
|
736
|
-
}
|
|
737
|
-
},
|
|
738
|
-
{
|
|
739
|
-
key: "backgroundImage",
|
|
740
|
-
value: function backgroundImage(_) {
|
|
741
|
-
return arguments.length ? (this._backgroundImage = typeof _ === "function" ? _ : constant(_), this) : this._backgroundImage;
|
|
882
|
+
return arguments.length ? (this.schema.activeStyle = assign({}, this.schema.activeStyle, _), this) : this.schema.activeStyle;
|
|
742
883
|
}
|
|
743
884
|
},
|
|
744
885
|
{
|
|
@@ -747,125 +888,25 @@ var Shape = /*#__PURE__*/ function(BaseClass) {
|
|
|
747
888
|
return arguments.length ? (this._data = _, this) : this._data;
|
|
748
889
|
}
|
|
749
890
|
},
|
|
750
|
-
{
|
|
751
|
-
key: "discrete",
|
|
752
|
-
value: function discrete(_) {
|
|
753
|
-
return arguments.length ? (this._discrete = _, this) : this._discrete;
|
|
754
|
-
}
|
|
755
|
-
},
|
|
756
|
-
{
|
|
757
|
-
key: "duration",
|
|
758
|
-
value: function duration(_) {
|
|
759
|
-
return arguments.length ? (this._duration = _, this) : this._duration;
|
|
760
|
-
}
|
|
761
|
-
},
|
|
762
|
-
{
|
|
763
|
-
key: "fill",
|
|
764
|
-
value: function fill(_) {
|
|
765
|
-
return arguments.length ? (this._fill = typeof _ === "function" ? _ : constant(_), this) : this._fill;
|
|
766
|
-
}
|
|
767
|
-
},
|
|
768
|
-
{
|
|
769
|
-
key: "fillOpacity",
|
|
770
|
-
value: function fillOpacity(_) {
|
|
771
|
-
return arguments.length ? (this._fillOpacity = typeof _ === "function" ? _ : constant(_), this) : this._fillOpacity;
|
|
772
|
-
}
|
|
773
|
-
},
|
|
774
891
|
{
|
|
775
892
|
key: "hover",
|
|
776
893
|
value: function hover(_) {
|
|
777
|
-
if (!arguments.length || _ === void 0) return this.
|
|
778
|
-
this.
|
|
779
|
-
|
|
780
|
-
// this._renderImage();
|
|
781
|
-
// this._renderLabels();
|
|
782
|
-
this._renderHover();
|
|
783
|
-
}
|
|
894
|
+
if (!arguments.length || _ === void 0) return this.schema.hover;
|
|
895
|
+
this.schema.hover = _;
|
|
896
|
+
// v4: hover dim comes from the scene path's paint recomputation; no DOM here.
|
|
784
897
|
return this;
|
|
785
898
|
}
|
|
786
899
|
},
|
|
787
900
|
{
|
|
788
901
|
key: "hoverStyle",
|
|
789
902
|
value: function hoverStyle(_) {
|
|
790
|
-
return arguments.length ? (this.
|
|
791
|
-
}
|
|
792
|
-
},
|
|
793
|
-
{
|
|
794
|
-
key: "hoverOpacity",
|
|
795
|
-
value: function hoverOpacity(_) {
|
|
796
|
-
return arguments.length ? (this._hoverOpacity = _, this) : this._hoverOpacity;
|
|
797
|
-
}
|
|
798
|
-
},
|
|
799
|
-
{
|
|
800
|
-
key: "hitArea",
|
|
801
|
-
value: function hitArea(_) {
|
|
802
|
-
return arguments.length ? (this._hitArea = typeof _ === "function" ? _ : constant(_), this) : this._hitArea;
|
|
803
|
-
}
|
|
804
|
-
},
|
|
805
|
-
{
|
|
806
|
-
key: "id",
|
|
807
|
-
value: function id(_) {
|
|
808
|
-
return arguments.length ? (this._id = _, this) : this._id;
|
|
809
|
-
}
|
|
810
|
-
},
|
|
811
|
-
{
|
|
812
|
-
key: "label",
|
|
813
|
-
value: function label(_) {
|
|
814
|
-
return arguments.length ? (this._label = typeof _ === "function" ? _ : constant(_), this) : this._label;
|
|
815
|
-
}
|
|
816
|
-
},
|
|
817
|
-
{
|
|
818
|
-
key: "labelBounds",
|
|
819
|
-
value: function labelBounds(_) {
|
|
820
|
-
return arguments.length ? (this._labelBounds = typeof _ === "function" ? _ : constant(_), this) : this._labelBounds;
|
|
903
|
+
return arguments.length ? (this.schema.hoverStyle = assign({}, this.schema.hoverStyle, _), this) : this.schema.hoverStyle;
|
|
821
904
|
}
|
|
822
905
|
},
|
|
823
906
|
{
|
|
824
907
|
key: "labelConfig",
|
|
825
908
|
value: function labelConfig(_) {
|
|
826
|
-
return arguments.length ? (this.
|
|
827
|
-
}
|
|
828
|
-
},
|
|
829
|
-
{
|
|
830
|
-
key: "opacity",
|
|
831
|
-
value: function opacity(_) {
|
|
832
|
-
return arguments.length ? (this._opacity = typeof _ === "function" ? _ : constant(_), this) : this._opacity;
|
|
833
|
-
}
|
|
834
|
-
},
|
|
835
|
-
{
|
|
836
|
-
key: "pointerEvents",
|
|
837
|
-
value: function pointerEvents(_) {
|
|
838
|
-
return arguments.length ? (this._pointerEvents = typeof _ === "function" ? _ : constant(_), this) : this._pointerEvents;
|
|
839
|
-
}
|
|
840
|
-
},
|
|
841
|
-
{
|
|
842
|
-
key: "role",
|
|
843
|
-
value: function role(_) {
|
|
844
|
-
return _ !== undefined ? (this._role = typeof _ === "function" ? _ : constant(_), this) : this._role;
|
|
845
|
-
}
|
|
846
|
-
},
|
|
847
|
-
{
|
|
848
|
-
key: "rotate",
|
|
849
|
-
value: function rotate(_) {
|
|
850
|
-
return arguments.length ? (this._rotate = typeof _ === "function" ? _ : constant(_), this) : this._rotate;
|
|
851
|
-
}
|
|
852
|
-
},
|
|
853
|
-
{
|
|
854
|
-
key: "rx",
|
|
855
|
-
value: function rx(_) {
|
|
856
|
-
return arguments.length ? (this._rx = typeof _ === "function" ? _ : constant(_), this) : this._rx;
|
|
857
|
-
}
|
|
858
|
-
},
|
|
859
|
-
{
|
|
860
|
-
key: "ry",
|
|
861
|
-
value: function ry(_) {
|
|
862
|
-
return arguments.length ? (this._ry = typeof _ === "function" ? _ : constant(_), this) : this._ry;
|
|
863
|
-
}
|
|
864
|
-
},
|
|
865
|
-
{
|
|
866
|
-
key: "scale",
|
|
867
|
-
value: function scale(_) {
|
|
868
|
-
return arguments.length ? (this._scale = typeof _ === "function" ? _ : constant(_), this) : this._scale;
|
|
909
|
+
return arguments.length ? (this.schema.labelConfig = assign(this.schema.labelConfig, _), this) : this.schema.labelConfig;
|
|
869
910
|
}
|
|
870
911
|
},
|
|
871
912
|
{
|
|
@@ -874,88 +915,24 @@ var Shape = /*#__PURE__*/ function(BaseClass) {
|
|
|
874
915
|
return arguments.length ? (this._select = select(_), this) : this._select;
|
|
875
916
|
}
|
|
876
917
|
},
|
|
877
|
-
{
|
|
878
|
-
key: "shapeRendering",
|
|
879
|
-
value: function shapeRendering(_) {
|
|
880
|
-
return arguments.length ? (this._shapeRendering = typeof _ === "function" ? _ : constant(_), this) : this._shapeRendering;
|
|
881
|
-
}
|
|
882
|
-
},
|
|
883
918
|
{
|
|
884
919
|
key: "sort",
|
|
885
920
|
value: function sort(_) {
|
|
886
|
-
return arguments.length ? (this.
|
|
887
|
-
}
|
|
888
|
-
},
|
|
889
|
-
{
|
|
890
|
-
key: "stroke",
|
|
891
|
-
value: function stroke(_) {
|
|
892
|
-
return arguments.length ? (this._stroke = typeof _ === "function" ? _ : constant(_), this) : this._stroke;
|
|
893
|
-
}
|
|
894
|
-
},
|
|
895
|
-
{
|
|
896
|
-
key: "strokeDasharray",
|
|
897
|
-
value: function strokeDasharray(_) {
|
|
898
|
-
return arguments.length ? (this._strokeDasharray = typeof _ === "function" ? _ : constant(_), this) : this._strokeDasharray;
|
|
899
|
-
}
|
|
900
|
-
},
|
|
901
|
-
{
|
|
902
|
-
key: "strokeLinecap",
|
|
903
|
-
value: function strokeLinecap(_) {
|
|
904
|
-
return arguments.length ? (this._strokeLinecap = typeof _ === "function" ? _ : constant(_), this) : this._strokeLinecap;
|
|
905
|
-
}
|
|
906
|
-
},
|
|
907
|
-
{
|
|
908
|
-
key: "strokeOpacity",
|
|
909
|
-
value: function strokeOpacity(_) {
|
|
910
|
-
return arguments.length ? (this._strokeOpacity = typeof _ === "function" ? _ : constant(_), this) : this._strokeOpacity;
|
|
911
|
-
}
|
|
912
|
-
},
|
|
913
|
-
{
|
|
914
|
-
key: "strokeWidth",
|
|
915
|
-
value: function strokeWidth(_) {
|
|
916
|
-
return arguments.length ? (this._strokeWidth = typeof _ === "function" ? _ : constant(_), this) : this._strokeWidth;
|
|
917
|
-
}
|
|
918
|
-
},
|
|
919
|
-
{
|
|
920
|
-
key: "textAnchor",
|
|
921
|
-
value: function textAnchor(_) {
|
|
922
|
-
return arguments.length ? (this._textAnchor = typeof _ === "function" ? _ : constant(_), this) : this._textAnchor;
|
|
923
|
-
}
|
|
924
|
-
},
|
|
925
|
-
{
|
|
926
|
-
key: "texture",
|
|
927
|
-
value: function texture(_) {
|
|
928
|
-
return arguments.length ? (this._texture = typeof _ === "function" ? _ : constant(_), this) : this._texture;
|
|
921
|
+
return arguments.length ? (this.schema.sort = _ !== null && _ !== void 0 ? _ : null, this) : this.schema.sort;
|
|
929
922
|
}
|
|
930
923
|
},
|
|
931
924
|
{
|
|
932
925
|
key: "textureDefault",
|
|
933
926
|
value: function textureDefault(_) {
|
|
934
|
-
return arguments.length ? (this.
|
|
935
|
-
}
|
|
936
|
-
},
|
|
937
|
-
{
|
|
938
|
-
key: "vectorEffect",
|
|
939
|
-
value: function vectorEffect(_) {
|
|
940
|
-
return arguments.length ? (this._vectorEffect = typeof _ === "function" ? _ : constant(_), this) : this._vectorEffect;
|
|
927
|
+
return arguments.length ? (this.schema.textureDefault = assign(this.schema.textureDefault, _), this) : this.schema.textureDefault;
|
|
941
928
|
}
|
|
942
929
|
},
|
|
943
930
|
{
|
|
944
|
-
key: "
|
|
945
|
-
value: function
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
{
|
|
950
|
-
key: "x",
|
|
951
|
-
value: function x(_) {
|
|
952
|
-
return arguments.length ? (this._x = typeof _ === "function" ? _ : constant(_), this) : this._x;
|
|
953
|
-
}
|
|
954
|
-
},
|
|
955
|
-
{
|
|
956
|
-
key: "y",
|
|
957
|
-
value: function y(_) {
|
|
958
|
-
return arguments.length ? (this._y = typeof _ === "function" ? _ : constant(_), this) : this._y;
|
|
931
|
+
key: "config",
|
|
932
|
+
value: function config(_) {
|
|
933
|
+
if (!arguments.length) return _get(_get_prototype_of(Shape.prototype), "config", this).call(this);
|
|
934
|
+
_get(_get_prototype_of(Shape.prototype), "config", this).call(this, _);
|
|
935
|
+
return this;
|
|
959
936
|
}
|
|
960
937
|
}
|
|
961
938
|
]);
|