semiotic 2.0.3 → 3.0.0-beta.1
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/CLAUDE.md +530 -0
- package/README.md +190 -37
- package/ai/cli.js +48 -0
- package/ai/dist/ai/componentRegistry.js +45 -0
- package/ai/dist/ai/mcp-server.js +99 -0
- package/ai/dist/ai/renderHOCToSVG.js +77 -0
- package/ai/dist/src/components/Annotation.js +358 -0
- package/ai/dist/src/components/AnnotationLayer/AnnotationLayer.js +369 -0
- package/ai/dist/src/components/Axis/Axis.js +373 -0
- package/ai/dist/src/components/Axis/axisTitle.js +14 -0
- package/ai/dist/src/components/Axis/index.js +7 -0
- package/ai/dist/src/components/Axis/summaryGraphic.js +37 -0
- package/ai/dist/src/components/Brush.js +84 -0
- package/ai/dist/src/components/DividedLine.js +65 -0
- package/ai/dist/src/components/FacetController.js +259 -0
- package/ai/dist/src/components/Frame.js +139 -0
- package/ai/dist/src/components/InteractionLayer.js +328 -0
- package/ai/dist/src/components/Legend.js +140 -0
- package/ai/dist/src/components/MiniMap.js +75 -0
- package/ai/dist/src/components/MinimapXYFrame.js +99 -0
- package/ai/dist/src/components/NetworkFrame.js +335 -0
- package/ai/dist/src/components/OrdinalFrame.js +437 -0
- package/ai/dist/src/components/ResponsiveFrame.js +68 -0
- package/ai/dist/src/components/ResponsiveMinimapXYFrame.js +11 -0
- package/ai/dist/src/components/ResponsiveNetworkFrame.js +11 -0
- package/ai/dist/src/components/ResponsiveOrdinalFrame.js +11 -0
- package/ai/dist/src/components/ResponsiveXYFrame.js +10 -0
- package/ai/dist/src/components/SparkFrame.js +113 -0
- package/ai/dist/src/components/SparkNetworkFrame.js +11 -0
- package/ai/dist/src/components/SparkOrdinalFrame.js +11 -0
- package/ai/dist/src/components/SparkXYFrame.js +11 -0
- package/ai/dist/src/components/Tooltip/Tooltip.js +304 -0
- package/ai/dist/src/components/TooltipPositioner/index.js +132 -0
- package/ai/dist/src/components/VisualizationLayer.js +395 -0
- package/ai/dist/src/components/XYFrame.js +524 -0
- package/ai/dist/src/components/annotationLayerBehavior/annotationHandling.js +73 -0
- package/ai/dist/src/components/annotationLayerBehavior/d3labeler.js +254 -0
- package/ai/dist/src/components/annotationRules/baseRules.js +150 -0
- package/ai/dist/src/components/annotationRules/networkframeRules.js +198 -0
- package/ai/dist/src/components/annotationRules/orframeRules.js +695 -0
- package/ai/dist/src/components/annotationRules/xyframeRules.js +299 -0
- package/ai/dist/src/components/batchWork.js +35 -0
- package/ai/dist/src/components/charts/index.js +96 -0
- package/ai/dist/src/components/charts/network/ChordDiagram.js +245 -0
- package/ai/dist/src/components/charts/network/CirclePack.js +177 -0
- package/ai/dist/src/components/charts/network/ForceDirectedGraph.js +248 -0
- package/ai/dist/src/components/charts/network/SankeyDiagram.js +305 -0
- package/ai/dist/src/components/charts/network/TreeDiagram.js +268 -0
- package/ai/dist/src/components/charts/network/Treemap.js +177 -0
- package/ai/dist/src/components/charts/ordinal/BarChart.js +191 -0
- package/ai/dist/src/components/charts/ordinal/BoxPlot.js +235 -0
- package/ai/dist/src/components/charts/ordinal/DonutChart.js +178 -0
- package/ai/dist/src/components/charts/ordinal/DotPlot.js +194 -0
- package/ai/dist/src/components/charts/ordinal/GroupedBarChart.js +194 -0
- package/ai/dist/src/components/charts/ordinal/PieChart.js +155 -0
- package/ai/dist/src/components/charts/ordinal/StackedBarChart.js +213 -0
- package/ai/dist/src/components/charts/ordinal/SwarmPlot.js +219 -0
- package/ai/dist/src/components/charts/realtime/RealtimeBarChart.js +91 -0
- package/ai/dist/src/components/charts/realtime/RealtimeLineChart.js +73 -0
- package/ai/dist/src/components/charts/realtime/RealtimeSwarmChart.js +85 -0
- package/ai/dist/src/components/charts/realtime/RealtimeWaterfallChart.js +86 -0
- package/ai/dist/src/components/charts/shared/ChartError.js +72 -0
- package/ai/dist/src/components/charts/shared/colorUtils.js +138 -0
- package/ai/dist/src/components/charts/shared/formatUtils.js +176 -0
- package/ai/dist/src/components/charts/shared/hooks.js +49 -0
- package/ai/dist/src/components/charts/shared/legendUtils.js +57 -0
- package/ai/dist/src/components/charts/shared/types.js +2 -0
- package/ai/dist/src/components/charts/shared/validateChartData.js +82 -0
- package/ai/dist/src/components/charts/shared/validateProps.js +640 -0
- package/ai/dist/src/components/charts/xy/AreaChart.js +220 -0
- package/ai/dist/src/components/charts/xy/BubbleChart.js +222 -0
- package/ai/dist/src/components/charts/xy/Heatmap.js +230 -0
- package/ai/dist/src/components/charts/xy/LineChart.js +302 -0
- package/ai/dist/src/components/charts/xy/Scatterplot.js +136 -0
- package/ai/dist/src/components/charts/xy/StackedAreaChart.js +220 -0
- package/ai/dist/src/components/constants/coordinateNames.js +11 -0
- package/ai/dist/src/components/constants/frame_props.js +251 -0
- package/ai/dist/src/components/constants/jsx.js +71 -0
- package/ai/dist/src/components/data/dataFunctions.js +473 -0
- package/ai/dist/src/components/data/multiAccessorUtils.js +14 -0
- package/ai/dist/src/components/data/networkPipelineCache.js +43 -0
- package/ai/dist/src/components/data/ordinalPipelineCache.js +53 -0
- package/ai/dist/src/components/data/unflowedFunctions.js +5 -0
- package/ai/dist/src/components/data/xyPipelineCache.js +49 -0
- package/ai/dist/src/components/generic_utilities/functions.js +5 -0
- package/ai/dist/src/components/index.js +145 -0
- package/ai/dist/src/components/interactionLayerBehavior/InteractionCanvas.js +128 -0
- package/ai/dist/src/components/processing/InteractionItems.js +223 -0
- package/ai/dist/src/components/processing/hierarchyUtils.js +104 -0
- package/ai/dist/src/components/processing/layouts/chordLayout.js +58 -0
- package/ai/dist/src/components/processing/layouts/forceLayout.js +142 -0
- package/ai/dist/src/components/processing/layouts/hierarchyLayout.js +31 -0
- package/ai/dist/src/components/processing/layouts/index.js +32 -0
- package/ai/dist/src/components/processing/layouts/sankeyLayout.js +96 -0
- package/ai/dist/src/components/processing/layouts/simpleLayouts.js +34 -0
- package/ai/dist/src/components/processing/layouts/types.js +2 -0
- package/ai/dist/src/components/processing/network.js +771 -0
- package/ai/dist/src/components/processing/networkDefaults.js +39 -0
- package/ai/dist/src/components/processing/networkLayoutHelpers.js +98 -0
- package/ai/dist/src/components/processing/ordinal.js +889 -0
- package/ai/dist/src/components/processing/ordinalConstants.js +23 -0
- package/ai/dist/src/components/processing/ordinalOverlays.js +88 -0
- package/ai/dist/src/components/processing/ordinalRenderPipeline.js +196 -0
- package/ai/dist/src/components/processing/xyDrawing.js +484 -0
- package/ai/dist/src/components/realtime/BinAccumulator.js +36 -0
- package/ai/dist/src/components/realtime/IncrementalExtent.js +55 -0
- package/ai/dist/src/components/realtime/RealtimeFrame.js +710 -0
- package/ai/dist/src/components/realtime/RingBuffer.js +104 -0
- package/ai/dist/src/components/realtime/renderers/barRenderer.js +133 -0
- package/ai/dist/src/components/realtime/renderers/candlestickRenderer.js +7 -0
- package/ai/dist/src/components/realtime/renderers/lineRenderer.js +164 -0
- package/ai/dist/src/components/realtime/renderers/swarmRenderer.js +91 -0
- package/ai/dist/src/components/realtime/renderers/types.js +2 -0
- package/ai/dist/src/components/realtime/renderers/waterfallRenderer.js +163 -0
- package/ai/dist/src/components/realtime/types.js +2 -0
- package/ai/dist/src/components/semiotic-ai.js +66 -0
- package/ai/dist/src/components/semiotic-network.js +30 -0
- package/ai/dist/src/components/semiotic-ordinal.js +28 -0
- package/ai/dist/src/components/semiotic-realtime.js +37 -0
- package/ai/dist/src/components/semiotic-server.js +8 -0
- package/ai/dist/src/components/semiotic-xy.js +41 -0
- package/ai/dist/src/components/semiotic.js +101 -0
- package/ai/dist/src/components/server/renderToStaticSVG.js +392 -0
- package/ai/dist/src/components/store/TooltipStore.js +13 -0
- package/ai/dist/src/components/store/createStore.js +77 -0
- package/ai/dist/src/components/svg/SvgHelper.js +308 -0
- package/ai/dist/src/components/svg/areaDrawing.js +312 -0
- package/ai/dist/src/components/svg/boxplotRenderer.js +441 -0
- package/ai/dist/src/components/svg/bucketizedRenderer.js +677 -0
- package/ai/dist/src/components/svg/ckbinsRenderer.js +92 -0
- package/ai/dist/src/components/svg/ckmeans.js +238 -0
- package/ai/dist/src/components/svg/contourLayout.js +73 -0
- package/ai/dist/src/components/svg/contourRenderer.js +53 -0
- package/ai/dist/src/components/svg/edgeGenerators.js +181 -0
- package/ai/dist/src/components/svg/frameFunctions.js +579 -0
- package/ai/dist/src/components/svg/graphAlgorithms.js +138 -0
- package/ai/dist/src/components/svg/hexbinLayout.js +163 -0
- package/ai/dist/src/components/svg/lineDrawing.js +427 -0
- package/ai/dist/src/components/svg/networkDrawing.js +207 -0
- package/ai/dist/src/components/svg/nodeGenerators.js +131 -0
- package/ai/dist/src/components/svg/pieceDrawing.js +110 -0
- package/ai/dist/src/components/svg/pieceLayouts.js +588 -0
- package/ai/dist/src/components/svg/sankeyLinks.js +143 -0
- package/ai/dist/src/components/svg/summaryAxis.js +48 -0
- package/ai/dist/src/components/svg/summaryLayouts.js +202 -0
- package/ai/dist/src/components/svg/swarmLayout.js +128 -0
- package/ai/dist/src/components/types/annotationTypes.js +2 -0
- package/ai/dist/src/components/types/canvasTypes.js +2 -0
- package/ai/dist/src/components/types/generalTypes.js +2 -0
- package/ai/dist/src/components/types/interactionTypes.js +2 -0
- package/ai/dist/src/components/types/legendTypes.js +2 -0
- package/ai/dist/src/components/types/networkTypes.js +2 -0
- package/ai/dist/src/components/types/ordinalTypes.js +2 -0
- package/ai/dist/src/components/types/xyTypes.js +2 -0
- package/ai/dist/src/components/useBoundingRect.js +24 -0
- package/ai/dist/src/components/useDerivedStateFromProps.js +25 -0
- package/ai/dist/src/components/useLegacyUnmountCallback.js +21 -0
- package/ai/dist/src/components/visualizationLayerBehavior/axis.js +249 -0
- package/ai/dist/src/components/visualizationLayerBehavior/general.js +435 -0
- package/ai/dist/src/setupTests.js +4 -0
- package/ai/examples.md +394 -0
- package/ai/schema.json +1178 -0
- package/ai/system-prompt.md +38 -0
- package/dist/AnnotationLayer/AnnotationLayer.d.ts +0 -1
- package/dist/Axis/axisTitle.d.ts +3 -3
- package/dist/Axis/summaryGraphic.d.ts +1 -1
- package/dist/FacetController.d.ts +1 -1
- package/dist/MinimapXYFrame.d.ts +2 -2
- package/dist/NetworkFrame.d.ts +5 -1
- package/dist/OrdinalFrame.d.ts +5 -1
- package/dist/ResponsiveFrame.d.ts +2 -2
- package/dist/ResponsiveMinimapXYFrame.d.ts +3 -6
- package/dist/ResponsiveNetworkFrame.d.ts +3 -6
- package/dist/ResponsiveOrdinalFrame.d.ts +3 -6
- package/dist/ResponsiveXYFrame.d.ts +3 -6
- package/dist/SparkFrame.d.ts +1 -1
- package/dist/SparkNetworkFrame.d.ts +3 -3
- package/dist/SparkOrdinalFrame.d.ts +3 -3
- package/dist/SparkXYFrame.d.ts +3 -3
- package/dist/Tooltip/Tooltip.d.ts +141 -0
- package/dist/TooltipPositioner/index.d.ts +1 -1
- package/dist/VisualizationLayer.d.ts +3 -3
- package/dist/XYFrame.d.ts +5 -1
- package/dist/annotationLayerBehavior/annotationHandling.d.ts +2 -2
- package/dist/annotationRules/networkframeRules.d.ts +2 -2
- package/dist/annotationRules/orframeRules.d.ts +2 -4
- package/dist/annotationRules/xyframeRules.d.ts +2 -2
- package/dist/batchWork.d.ts +1 -1
- package/dist/charts/index.d.ts +62 -0
- package/dist/charts/network/ChordDiagram.d.ts +181 -0
- package/dist/charts/network/CirclePack.d.ts +103 -0
- package/dist/charts/network/ForceDirectedGraph.d.ts +192 -0
- package/dist/charts/network/SankeyDiagram.d.ts +195 -0
- package/dist/charts/network/TreeDiagram.d.ts +200 -0
- package/dist/charts/network/Treemap.d.ts +98 -0
- package/dist/charts/ordinal/BarChart.d.ts +119 -0
- package/dist/charts/ordinal/BoxPlot.d.ts +125 -0
- package/dist/charts/ordinal/DonutChart.d.ts +95 -0
- package/dist/charts/ordinal/DotPlot.d.ts +128 -0
- package/dist/charts/ordinal/GroupedBarChart.d.ts +113 -0
- package/dist/charts/ordinal/PieChart.d.ts +83 -0
- package/dist/charts/ordinal/StackedBarChart.d.ts +119 -0
- package/dist/charts/ordinal/SwarmPlot.d.ts +137 -0
- package/dist/charts/realtime/RealtimeBarChart.d.ts +102 -0
- package/dist/charts/realtime/RealtimeLineChart.d.ts +78 -0
- package/dist/charts/realtime/RealtimeSwarmChart.d.ts +88 -0
- package/dist/charts/realtime/RealtimeWaterfallChart.d.ts +85 -0
- package/dist/charts/shared/ChartError.d.ts +19 -0
- package/dist/charts/shared/colorUtils.d.ts +62 -0
- package/dist/charts/shared/formatUtils.d.ts +82 -0
- package/dist/charts/shared/hooks.d.ts +20 -0
- package/dist/charts/shared/legendUtils.d.ts +32 -0
- package/dist/charts/shared/types.d.ts +58 -0
- package/dist/charts/shared/validateChartData.d.ts +41 -0
- package/dist/charts/shared/validateProps.d.ts +18 -0
- package/dist/charts/xy/AreaChart.d.ts +127 -0
- package/dist/charts/xy/BubbleChart.d.ts +157 -0
- package/dist/charts/xy/Heatmap.d.ts +153 -0
- package/dist/charts/xy/LineChart.d.ts +193 -0
- package/dist/charts/xy/Scatterplot.d.ts +50 -0
- package/dist/charts/xy/StackedAreaChart.d.ts +131 -0
- package/dist/constants/frame_props.d.ts +9 -0
- package/dist/constants/jsx.d.ts +2 -2
- package/dist/data/dataFunctions.d.ts +11 -12
- package/dist/data/networkPipelineCache.d.ts +27 -0
- package/dist/data/ordinalPipelineCache.d.ts +33 -0
- package/dist/data/xyPipelineCache.d.ts +35 -0
- package/dist/index.d.ts +70 -62
- package/dist/interactionLayerBehavior/InteractionCanvas.d.ts +1 -1
- package/dist/network.js +8520 -0
- package/dist/network.js.map +1 -0
- package/dist/network.min.js +1 -0
- package/dist/network.module.js +8484 -0
- package/dist/network.module.js.map +1 -0
- package/dist/network.module.min.js +1 -0
- package/dist/ordinal.js +9276 -0
- package/dist/ordinal.js.map +1 -0
- package/dist/ordinal.min.js +1 -0
- package/dist/ordinal.module.js +9242 -0
- package/dist/ordinal.module.js.map +1 -0
- package/dist/ordinal.module.min.js +1 -0
- package/dist/processing/InteractionItems.d.ts +5 -4
- package/dist/processing/hierarchyUtils.d.ts +16 -0
- package/dist/processing/layouts/chordLayout.d.ts +2 -0
- package/dist/processing/layouts/forceLayout.d.ts +3 -0
- package/dist/processing/layouts/hierarchyLayout.d.ts +10 -0
- package/dist/processing/layouts/index.d.ts +8 -0
- package/dist/processing/layouts/sankeyLayout.d.ts +8 -0
- package/dist/processing/layouts/simpleLayouts.d.ts +7 -0
- package/dist/processing/layouts/types.d.ts +17 -0
- package/dist/processing/network.d.ts +25 -28
- package/dist/processing/networkDefaults.d.ts +36 -0
- package/dist/processing/networkLayoutHelpers.d.ts +54 -0
- package/dist/processing/ordinal.d.ts +43 -43
- package/dist/processing/ordinalConstants.d.ts +33 -0
- package/dist/processing/ordinalOverlays.d.ts +33 -0
- package/dist/processing/ordinalRenderPipeline.d.ts +148 -0
- package/dist/processing/xyDrawing.d.ts +46 -41
- package/dist/realtime/BinAccumulator.d.ts +8 -0
- package/dist/realtime/IncrementalExtent.d.ts +13 -0
- package/dist/realtime/RealtimeFrame.d.ts +4 -0
- package/dist/realtime/RingBuffer.d.ts +19 -0
- package/dist/realtime/renderers/barRenderer.d.ts +2 -0
- package/dist/realtime/renderers/candlestickRenderer.d.ts +2 -0
- package/dist/realtime/renderers/lineRenderer.d.ts +2 -0
- package/dist/realtime/renderers/swarmRenderer.d.ts +2 -0
- package/dist/realtime/renderers/types.d.ts +9 -0
- package/dist/realtime/renderers/waterfallRenderer.d.ts +3 -0
- package/dist/realtime/types.d.ts +113 -0
- package/dist/realtime.js +1598 -0
- package/dist/realtime.js.map +1 -0
- package/dist/realtime.min.js +1 -0
- package/dist/realtime.module.js +1566 -0
- package/dist/realtime.module.js.map +1 -0
- package/dist/realtime.module.min.js +1 -0
- package/dist/semiotic-ai.d.ts +28 -0
- package/dist/semiotic-ai.js +18722 -0
- package/dist/semiotic-ai.js.map +1 -0
- package/dist/semiotic-ai.min.js +1 -0
- package/dist/semiotic-ai.module.js +18668 -0
- package/dist/semiotic-ai.module.js.map +1 -0
- package/dist/semiotic-ai.module.min.js +1 -0
- package/dist/semiotic-network.d.ts +19 -0
- package/dist/semiotic-ordinal.d.ts +18 -0
- package/dist/semiotic-realtime.d.ts +23 -0
- package/dist/semiotic-server.d.ts +1 -0
- package/dist/semiotic-xy.d.ts +24 -0
- package/dist/semiotic.d.ts +19 -3
- package/dist/semiotic.js +18707 -12983
- package/dist/semiotic.js.map +1 -0
- package/dist/semiotic.min.js +1 -0
- package/dist/semiotic.module.js +18651 -12953
- package/dist/semiotic.module.js.map +1 -0
- package/dist/semiotic.module.min.js +1 -0
- package/dist/server/renderToStaticSVG.d.ts +9 -0
- package/dist/server.js +8360 -0
- package/dist/server.js.map +1 -0
- package/dist/server.min.js +1 -0
- package/dist/server.module.js +8331 -0
- package/dist/server.module.js.map +1 -0
- package/dist/server.module.min.js +1 -0
- package/dist/svg/SvgHelper.d.ts +1 -5
- package/dist/svg/areaDrawing.d.ts +3 -13
- package/dist/svg/boxplotRenderer.d.ts +15 -0
- package/dist/svg/bucketizedRenderer.d.ts +16 -0
- package/dist/svg/ckbinsRenderer.d.ts +20 -0
- package/dist/svg/contourLayout.d.ts +6 -0
- package/dist/svg/contourRenderer.d.ts +12 -0
- package/dist/svg/edgeGenerators.d.ts +51 -0
- package/dist/svg/frameFunctions.d.ts +17 -28
- package/dist/svg/graphAlgorithms.d.ts +14 -0
- package/dist/svg/hexbinLayout.d.ts +7 -0
- package/dist/svg/lineDrawing.d.ts +8 -8
- package/dist/svg/networkDrawing.d.ts +5 -123
- package/dist/svg/nodeGenerators.d.ts +58 -0
- package/dist/svg/pieceDrawing.d.ts +1 -2
- package/dist/svg/pieceLayouts.d.ts +5 -23
- package/dist/svg/sankeyLinks.d.ts +3 -0
- package/dist/svg/summaryAxis.d.ts +6 -0
- package/dist/svg/summaryLayouts.d.ts +36 -57
- package/dist/svg/swarmLayout.d.ts +13 -0
- package/dist/types/annotationTypes.d.ts +13 -18
- package/dist/types/canvasTypes.d.ts +1 -1
- package/dist/types/generalTypes.d.ts +37 -35
- package/dist/types/interactionTypes.d.ts +7 -9
- package/dist/types/legendTypes.d.ts +2 -2
- package/dist/types/networkTypes.d.ts +40 -30
- package/dist/types/ordinalTypes.d.ts +27 -18
- package/dist/types/xyTypes.d.ts +13 -16
- package/dist/useLegacyUnmountCallback.d.ts +2 -1
- package/dist/visualizationLayerBehavior/axis.d.ts +3 -5
- package/dist/visualizationLayerBehavior/general.d.ts +8 -12
- package/dist/xy.js +7944 -0
- package/dist/xy.js.map +1 -0
- package/dist/xy.min.js +1 -0
- package/dist/xy.module.js +7903 -0
- package/dist/xy.module.js.map +1 -0
- package/dist/xy.module.min.js +1 -0
- package/package.json +116 -66
- package/dist/AnnotationLayer/helpers.d.ts +0 -6
- package/dist/AnnotationLayer/index.d.ts +0 -2
- package/dist/Mark/Mark.d.ts +0 -3
- package/dist/Mark/Mark.types.d.ts +0 -10
- package/dist/Mark/constants/markTransition.d.ts +0 -10
- package/dist/Mark/markBehavior/drawing.d.ts +0 -13
- package/dist/SpanOrDiv.d.ts +0 -10
- package/dist/components/Annotation.d.ts +0 -3
- package/dist/components/AnnotationLayer/AnnotationLayer.d.ts +0 -26
- package/dist/components/Axis/Axis.d.ts +0 -7
- package/dist/components/Axis/axisTitle.d.ts +0 -10
- package/dist/components/Axis/index.d.ts +0 -2
- package/dist/components/Axis/summaryGraphic.d.ts +0 -17
- package/dist/components/Brush.d.ts +0 -12
- package/dist/components/DividedLine.d.ts +0 -16
- package/dist/components/FacetController.d.ts +0 -12
- package/dist/components/Frame.d.ts +0 -2
- package/dist/components/InteractionLayer.d.ts +0 -3
- package/dist/components/Legend.d.ts +0 -3
- package/dist/components/Mark/Mark.d.ts +0 -3
- package/dist/components/Mark/Mark.types.d.ts +0 -10
- package/dist/components/Mark/markBehavior/drawing.d.ts +0 -13
- package/dist/components/MiniMap.d.ts +0 -14
- package/dist/components/MinimapXYFrame.d.ts +0 -10
- package/dist/components/NetworkFrame.d.ts +0 -4
- package/dist/components/OrdinalFrame.d.ts +0 -4
- package/dist/components/ResponsiveFrame.d.ts +0 -22
- package/dist/components/ResponsiveMinimapXYFrame.d.ts +0 -6
- package/dist/components/ResponsiveNetworkFrame.d.ts +0 -6
- package/dist/components/ResponsiveOrdinalFrame.d.ts +0 -6
- package/dist/components/ResponsiveXYFrame.d.ts +0 -6
- package/dist/components/SpanOrDiv.d.ts +0 -10
- package/dist/components/SparkFrame.d.ts +0 -14
- package/dist/components/SparkNetworkFrame.d.ts +0 -5
- package/dist/components/SparkOrdinalFrame.d.ts +0 -5
- package/dist/components/SparkXYFrame.d.ts +0 -5
- package/dist/components/TooltipPositioner/index.d.ts +0 -7
- package/dist/components/VisualizationLayer.d.ts +0 -33
- package/dist/components/XYFrame.d.ts +0 -4
- package/dist/components/annotationLayerBehavior/annotationHandling.d.ts +0 -19
- package/dist/components/annotationLayerBehavior/d3labeler.d.ts +0 -9
- package/dist/components/annotationRules/baseRules.d.ts +0 -25
- package/dist/components/annotationRules/networkframeRules.d.ts +0 -48
- package/dist/components/annotationRules/orframeRules.d.ts +0 -105
- package/dist/components/annotationRules/xyframeRules.d.ts +0 -117
- package/dist/components/batchWork.d.ts +0 -6
- package/dist/components/constants/coordinateNames.d.ts +0 -8
- package/dist/components/constants/frame_props.d.ts +0 -4
- package/dist/components/constants/jsx.d.ts +0 -19
- package/dist/components/data/dataFunctions.d.ts +0 -46
- package/dist/components/data/multiAccessorUtils.d.ts +0 -1
- package/dist/components/data/unflowedFunctions.d.ts +0 -1
- package/dist/components/generic_utilities/functions.d.ts +0 -1
- package/dist/components/index.d.ts +0 -125
- package/dist/components/interactionLayerBehavior/InteractionCanvas.d.ts +0 -20
- package/dist/components/processing/InteractionItems.d.ts +0 -12
- package/dist/components/processing/network.d.ts +0 -114
- package/dist/components/processing/ordinal.d.ts +0 -102
- package/dist/components/processing/xyDrawing.d.ts +0 -135
- package/dist/components/semiotic.d.ts +0 -35
- package/dist/components/store/TooltipStore.d.ts +0 -2
- package/dist/components/store/createStore.d.ts +0 -1
- package/dist/components/svg/SvgHelper.d.ts +0 -37
- package/dist/components/svg/areaDrawing.d.ts +0 -31
- package/dist/components/svg/ckmeans.d.ts +0 -69
- package/dist/components/svg/frameFunctions.d.ts +0 -119
- package/dist/components/svg/lineDrawing.d.ts +0 -99
- package/dist/components/svg/networkDrawing.d.ts +0 -134
- package/dist/components/svg/pieceDrawing.d.ts +0 -13
- package/dist/components/svg/pieceLayouts.d.ts +0 -71
- package/dist/components/svg/summaryLayouts.d.ts +0 -74
- package/dist/components/types/annotationTypes.d.ts +0 -140
- package/dist/components/types/canvasTypes.d.ts +0 -9
- package/dist/components/types/generalTypes.d.ts +0 -236
- package/dist/components/types/interactionTypes.d.ts +0 -74
- package/dist/components/types/legendTypes.d.ts +0 -20
- package/dist/components/types/networkTypes.d.ts +0 -165
- package/dist/components/types/ordinalTypes.d.ts +0 -103
- package/dist/components/types/xyTypes.d.ts +0 -118
- package/dist/components/useBoundingRect.d.ts +0 -2
- package/dist/components/useDerivedStateFromProps.d.ts +0 -1
- package/dist/components/useLegacyUnmountCallback.d.ts +0 -1
- package/dist/components/visualizationLayerBehavior/axis.d.ts +0 -38
- package/dist/components/visualizationLayerBehavior/general.d.ts +0 -84
- package/dist/setupTests.d.ts +0 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ckBinsRenderFn = ckBinsRenderFn;
|
|
4
|
+
const d3_scale_1 = require("d3-scale");
|
|
5
|
+
const ckmeans_1 = require("./ckmeans");
|
|
6
|
+
function ckBinsRenderFn(props) {
|
|
7
|
+
const { data, type, renderMode, eventListenersGenerator, styleFn, classFn, projection, adjustedSize } = props;
|
|
8
|
+
const renderedSummaryMarks = [];
|
|
9
|
+
const summaryXYCoords = [];
|
|
10
|
+
const keys = Object.keys(data);
|
|
11
|
+
let maxClusterSize = 0;
|
|
12
|
+
const allBins = [];
|
|
13
|
+
keys.forEach((key, summaryI) => {
|
|
14
|
+
const summary = data[key];
|
|
15
|
+
const eventListeners = eventListenersGenerator(summary, summaryI);
|
|
16
|
+
const columnWidth = summary.width;
|
|
17
|
+
const thisSummaryData = summary.pieceData.sort((a, b) => a.value - b.value);
|
|
18
|
+
const firstElement = thisSummaryData[0];
|
|
19
|
+
const lastElement = thisSummaryData[thisSummaryData.length - 1];
|
|
20
|
+
const binScale = (0, d3_scale_1.scaleLinear)()
|
|
21
|
+
.domain([firstElement.value, lastElement.value])
|
|
22
|
+
.range([firstElement.scaledValue, lastElement.scaledValue]);
|
|
23
|
+
const calculatedSummaryStyle = styleFn(thisSummaryData[0].data, summaryI);
|
|
24
|
+
const calculatedSummaryClass = classFn(thisSummaryData[0].data, summaryI);
|
|
25
|
+
const binData = thisSummaryData.map((d) => d.value);
|
|
26
|
+
const clusters = 5;
|
|
27
|
+
const ckstops = (0, ckmeans_1.ckmeans)(binData, clusters);
|
|
28
|
+
let ckBins = [];
|
|
29
|
+
ckstops.forEach((ckstop, i) => {
|
|
30
|
+
const start = ckstop;
|
|
31
|
+
const end = ckstops[i + 1] ?? lastElement.value;
|
|
32
|
+
ckBins.push({
|
|
33
|
+
start,
|
|
34
|
+
end,
|
|
35
|
+
key,
|
|
36
|
+
summary,
|
|
37
|
+
calculatedSummaryStyle,
|
|
38
|
+
calculatedSummaryClass,
|
|
39
|
+
scaledStart: binScale(start),
|
|
40
|
+
scaledEnd: binScale(end),
|
|
41
|
+
values: []
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
allBins.push(ckBins);
|
|
45
|
+
let binI = 0;
|
|
46
|
+
for (const datapoint of thisSummaryData) {
|
|
47
|
+
if (ckBins[binI].end <= datapoint.value) {
|
|
48
|
+
if (ckBins[binI + 1]) {
|
|
49
|
+
binI++;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
ckBins[binI].values.push(datapoint);
|
|
53
|
+
}
|
|
54
|
+
ckBins.forEach((ckbin) => {
|
|
55
|
+
const clusterSize = ckbin.values.length;
|
|
56
|
+
maxClusterSize = Math.max(clusterSize, maxClusterSize);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
allBins.forEach((ckBins, index) => {
|
|
60
|
+
const CKBinElements = ckBins.map((ckBin) => {
|
|
61
|
+
const { key, summary, calculatedSummaryStyle, calculatedSummaryClass } = ckBin;
|
|
62
|
+
const { fill = "black", stroke = "black" } = calculatedSummaryStyle;
|
|
63
|
+
const lightScale = (0, d3_scale_1.scaleLinear)()
|
|
64
|
+
.domain([1, maxClusterSize])
|
|
65
|
+
.range(["white", fill]);
|
|
66
|
+
return {
|
|
67
|
+
markType: "rect",
|
|
68
|
+
x: ckBin.scaledStart,
|
|
69
|
+
width: ckBin.scaledEnd - ckBin.scaledStart,
|
|
70
|
+
y: ckBin.summary.x,
|
|
71
|
+
height: ckBin.summary.width,
|
|
72
|
+
style: Object.assign({ strokeWidth: 2 }, calculatedSummaryStyle, {
|
|
73
|
+
fill: lightScale(ckBin.values.length),
|
|
74
|
+
strokeWidth: 1,
|
|
75
|
+
stroke
|
|
76
|
+
})
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
renderedSummaryMarks.push({
|
|
80
|
+
containerProps: {
|
|
81
|
+
// className: calculatedSummaryClass,
|
|
82
|
+
transform: "",
|
|
83
|
+
key: `summaryPiece-${index}`,
|
|
84
|
+
role: "img",
|
|
85
|
+
tabIndex: -1
|
|
86
|
+
},
|
|
87
|
+
//These are drawn items
|
|
88
|
+
elements: CKBinElements
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
return { marks: renderedSummaryMarks, xyPoints: summaryXYCoords };
|
|
92
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Ckmeans algorithm from d3-scale-cluster
|
|
4
|
+
*
|
|
5
|
+
* Much of the code that lies within was taken from the simple-statistics library,
|
|
6
|
+
* which offers a javascript implementation of the ckmeans algorithm originally
|
|
7
|
+
* designed by Haizhou Wang and Mingzhou Song
|
|
8
|
+
*
|
|
9
|
+
* https://cran.r-project.org/web/packages/Ckmeans.1d.dp/
|
|
10
|
+
* https://github.com/simple-statistics/simple-statistics
|
|
11
|
+
*
|
|
12
|
+
* The simple-statistics software license is included below
|
|
13
|
+
*
|
|
14
|
+
* --
|
|
15
|
+
*
|
|
16
|
+
* ISC License
|
|
17
|
+
*
|
|
18
|
+
* Copyright (c) 2014, Tom MacWright
|
|
19
|
+
*
|
|
20
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
21
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
22
|
+
* copyright notice and this permission notice appear in all copies.
|
|
23
|
+
*
|
|
24
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
25
|
+
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
26
|
+
* FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
27
|
+
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
28
|
+
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
29
|
+
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
30
|
+
* PERFORMANCE OF THIS SOFTWARE.
|
|
31
|
+
*/
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.ckmeans = ckmeans;
|
|
34
|
+
function numericSort(array) {
|
|
35
|
+
return (array
|
|
36
|
+
// ensure the array is not changed in-place
|
|
37
|
+
.slice()
|
|
38
|
+
// comparator function that treats input as numeric
|
|
39
|
+
.sort(function (a, b) {
|
|
40
|
+
return a - b;
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
function uniqueCountSorted(input) {
|
|
44
|
+
var uniqueValueCount = 0;
|
|
45
|
+
var lastSeenValue;
|
|
46
|
+
for (var i = 0; i < input.length; i++) {
|
|
47
|
+
if (i === 0 || input[i] !== lastSeenValue) {
|
|
48
|
+
lastSeenValue = input[i];
|
|
49
|
+
uniqueValueCount++;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return uniqueValueCount;
|
|
53
|
+
}
|
|
54
|
+
function makeMatrix(columns, rows) {
|
|
55
|
+
var matrix = [];
|
|
56
|
+
for (var i = 0; i < columns; i++) {
|
|
57
|
+
var column = [];
|
|
58
|
+
for (var j = 0; j < rows; j++) {
|
|
59
|
+
column.push(0);
|
|
60
|
+
}
|
|
61
|
+
matrix.push(column);
|
|
62
|
+
}
|
|
63
|
+
return matrix;
|
|
64
|
+
}
|
|
65
|
+
function ssq(j, i, sumX, sumXsq) {
|
|
66
|
+
var sji; // s(j, i)
|
|
67
|
+
if (j > 0) {
|
|
68
|
+
var muji = (sumX[i] - sumX[j - 1]) / (i - j + 1); // mu(j, i)
|
|
69
|
+
sji = sumXsq[i] - sumXsq[j - 1] - (i - j + 1) * muji * muji;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
sji = sumXsq[i] - (sumX[i] * sumX[i]) / (i + 1);
|
|
73
|
+
}
|
|
74
|
+
return sji < 0 ? 0 : sji;
|
|
75
|
+
}
|
|
76
|
+
function fillMatrixColumn(imin, imax, column, matrix, backtrackMatrix, sumX, sumXsq) {
|
|
77
|
+
if (imin > imax) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// Start at midpoint between imin and imax
|
|
81
|
+
var i = Math.floor((imin + imax) / 2);
|
|
82
|
+
// Initialization of S[k][i]:
|
|
83
|
+
matrix[column][i] = matrix[column - 1][i - 1];
|
|
84
|
+
backtrackMatrix[column][i] = i;
|
|
85
|
+
var jlow = column; // the lower end for j
|
|
86
|
+
if (imin > column) {
|
|
87
|
+
jlow = Math.max(jlow, backtrackMatrix[column][imin - 1] || 0);
|
|
88
|
+
}
|
|
89
|
+
jlow = Math.max(jlow, backtrackMatrix[column - 1][i] || 0);
|
|
90
|
+
var jhigh = i - 1; // the upper end for j
|
|
91
|
+
if (imax < matrix[0].length - 1) {
|
|
92
|
+
jhigh = Math.min(jhigh, backtrackMatrix[column][imax + 1] || 0);
|
|
93
|
+
}
|
|
94
|
+
var sji;
|
|
95
|
+
var sjlowi;
|
|
96
|
+
var ssqjlow;
|
|
97
|
+
var ssqj;
|
|
98
|
+
for (var j = jhigh; j >= jlow; --j) {
|
|
99
|
+
// compute s(j,i)
|
|
100
|
+
sji = ssq(j, i, sumX, sumXsq);
|
|
101
|
+
// MS May 11, 2016 Added:
|
|
102
|
+
if (sji + matrix[column - 1][jlow - 1] >= matrix[column][i]) {
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
// Examine the lower bound of the cluster border
|
|
106
|
+
// compute s(jlow, i)
|
|
107
|
+
sjlowi = ssq(jlow, i, sumX, sumXsq);
|
|
108
|
+
ssqjlow = sjlowi + matrix[column - 1][jlow - 1];
|
|
109
|
+
if (ssqjlow < matrix[column][i]) {
|
|
110
|
+
// shrink the lower bound
|
|
111
|
+
matrix[column][i] = ssqjlow;
|
|
112
|
+
backtrackMatrix[column][i] = jlow;
|
|
113
|
+
}
|
|
114
|
+
jlow++;
|
|
115
|
+
ssqj = sji + matrix[column - 1][j - 1];
|
|
116
|
+
if (ssqj < matrix[column][i]) {
|
|
117
|
+
matrix[column][i] = ssqj;
|
|
118
|
+
backtrackMatrix[column][i] = j;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
fillMatrixColumn(imin, i - 1, column, matrix, backtrackMatrix, sumX, sumXsq);
|
|
122
|
+
fillMatrixColumn(i + 1, imax, column, matrix, backtrackMatrix, sumX, sumXsq);
|
|
123
|
+
}
|
|
124
|
+
function fillMatrices(data, matrix, backtrackMatrix) {
|
|
125
|
+
var nValues = matrix[0].length;
|
|
126
|
+
var sumX = new Array(nValues);
|
|
127
|
+
var sumXsq = new Array(nValues);
|
|
128
|
+
// Use the median to shift values of x to improve numerical stability
|
|
129
|
+
var shift = data[Math.floor(nValues / 2)];
|
|
130
|
+
// Initialize first row in matrix & backtrackMatrix
|
|
131
|
+
for (var i = 0; i < nValues; ++i) {
|
|
132
|
+
if (i === 0) {
|
|
133
|
+
sumX[0] = data[0] - shift;
|
|
134
|
+
sumXsq[0] = (data[0] - shift) * (data[0] - shift);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
sumX[i] = sumX[i - 1] + data[i] - shift;
|
|
138
|
+
sumXsq[i] = sumXsq[i - 1] + (data[i] - shift) * (data[i] - shift);
|
|
139
|
+
}
|
|
140
|
+
// Initialize for k = 0
|
|
141
|
+
matrix[0][i] = ssq(0, i, sumX, sumXsq);
|
|
142
|
+
backtrackMatrix[0][i] = 0;
|
|
143
|
+
}
|
|
144
|
+
// Initialize the rest of the columns
|
|
145
|
+
var imin;
|
|
146
|
+
for (var k = 1; k < matrix.length; ++k) {
|
|
147
|
+
if (k < matrix.length - 1) {
|
|
148
|
+
imin = k;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
// No need to compute matrix[K-1][0] ... matrix[K-1][N-2]
|
|
152
|
+
imin = nValues - 1;
|
|
153
|
+
}
|
|
154
|
+
fillMatrixColumn(imin, nValues - 1, k, matrix, backtrackMatrix, sumX, sumXsq);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Ckmeans clustering is an improvement on heuristic-based clustering
|
|
159
|
+
* approaches like Jenks. The algorithm was developed in
|
|
160
|
+
* [Haizhou Wang and Mingzhou Song](http://journal.r-project.org/archive/2011-2/RJournal_2011-2_Wang+Song.pdf)
|
|
161
|
+
* as a [dynamic programming](https://en.wikipedia.org/wiki/Dynamic_programming) approach
|
|
162
|
+
* to the problem of clustering numeric data into groups with the least
|
|
163
|
+
* within-group sum-of-squared-deviations.
|
|
164
|
+
*
|
|
165
|
+
* Minimizing the difference within groups - what Wang & Song refer to as
|
|
166
|
+
* `withinss`, or within sum-of-squares, means that groups are optimally
|
|
167
|
+
* homogenous within and the data is split into representative groups.
|
|
168
|
+
* This is very useful for visualization, where you may want to represent
|
|
169
|
+
* a continuous variable in discrete color or style groups. This function
|
|
170
|
+
* can provide groups that emphasize differences between data.
|
|
171
|
+
*
|
|
172
|
+
* Being a dynamic approach, this algorithm is based on two matrices that
|
|
173
|
+
* store incrementally-computed values for squared deviations and backtracking
|
|
174
|
+
* indexes.
|
|
175
|
+
*
|
|
176
|
+
* Unlike the [original implementation](https://cran.r-project.org/web/packages/Ckmeans.1d.dp/index.html),
|
|
177
|
+
* this implementation does not include any code to automatically determine
|
|
178
|
+
* the optimal number of clusters: this information needs to be explicitly
|
|
179
|
+
* provided.
|
|
180
|
+
*
|
|
181
|
+
* ### References
|
|
182
|
+
* _Ckmeans.1d.dp: Optimal k-means Clustering in One Dimension by Dynamic
|
|
183
|
+
* Programming_ Haizhou Wang and Mingzhou Song ISSN 2073-4859
|
|
184
|
+
*
|
|
185
|
+
* from The R Journal Vol. 3/2, December 2011
|
|
186
|
+
* @param {Array<number>} data input data, as an array of number values
|
|
187
|
+
* @param {number} nClusters number of desired classes. This cannot be
|
|
188
|
+
* greater than the number of values in the data array.
|
|
189
|
+
* @returns {Array<Array<number>>} clustered input
|
|
190
|
+
* @example
|
|
191
|
+
* ckmeans([-1, 2, -1, 2, 4, 5, 6, -1, 2, -1], 3);
|
|
192
|
+
* // The input, clustered into groups of similar numbers.
|
|
193
|
+
* //= [[-1, -1, -1, -1], [2, 2, 2], [4, 5, 6]]);
|
|
194
|
+
*/
|
|
195
|
+
function ckmeans(data, nClusters) {
|
|
196
|
+
if (nClusters > data.length) {
|
|
197
|
+
throw new Error("Cannot generate more classes than there are data values");
|
|
198
|
+
}
|
|
199
|
+
var nValues = data.length;
|
|
200
|
+
var sorted = numericSort(data);
|
|
201
|
+
// we'll use this as the maximum number of clusters
|
|
202
|
+
var uniqueCount = uniqueCountSorted(sorted);
|
|
203
|
+
// if all of the input values are identical, there's one cluster
|
|
204
|
+
// with all of the input in it.
|
|
205
|
+
if (uniqueCount === 1) {
|
|
206
|
+
return [sorted[0]];
|
|
207
|
+
}
|
|
208
|
+
nClusters = Math.min(uniqueCount, nClusters);
|
|
209
|
+
// named 'S' originally
|
|
210
|
+
var matrix = makeMatrix(nClusters, nValues);
|
|
211
|
+
// named 'J' originally
|
|
212
|
+
var backtrackMatrix = makeMatrix(nClusters, nValues);
|
|
213
|
+
// This is a dynamic programming way to solve the problem of minimizing
|
|
214
|
+
// within-cluster sum of squares. It's similar to linear regression
|
|
215
|
+
// in this way, and this calculation incrementally computes the
|
|
216
|
+
// sum of squares that are later read.
|
|
217
|
+
fillMatrices(sorted, matrix, backtrackMatrix);
|
|
218
|
+
// The real work of Ckmeans clustering happens in the matrix generation:
|
|
219
|
+
// the generated matrices encode all possible clustering combinations, and
|
|
220
|
+
// once they're generated we can solve for the best clustering groups
|
|
221
|
+
// very quickly.
|
|
222
|
+
var clusters = [];
|
|
223
|
+
var clusterRight = backtrackMatrix[0].length - 1;
|
|
224
|
+
// Backtrack the clusters from the dynamic programming matrix. This
|
|
225
|
+
// starts at the bottom-right corner of the matrix (if the top-left is 0, 0),
|
|
226
|
+
// and moves the cluster target with the loop.
|
|
227
|
+
for (var cluster = backtrackMatrix.length - 1; cluster >= 0; cluster--) {
|
|
228
|
+
var clusterLeft = backtrackMatrix[cluster][clusterRight];
|
|
229
|
+
// fill the cluster from the sorted input by taking a slice of the
|
|
230
|
+
// array. the backtrack matrix makes this easy - it stores the
|
|
231
|
+
// indexes where the cluster should start and end.
|
|
232
|
+
clusters[cluster] = sorted[clusterLeft];
|
|
233
|
+
if (cluster > 0) {
|
|
234
|
+
clusterRight = clusterLeft - 1;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return clusters;
|
|
238
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.contouring = contouring;
|
|
4
|
+
const d3_contour_1 = require("d3-contour");
|
|
5
|
+
const d3_scale_1 = require("d3-scale");
|
|
6
|
+
function shapeBounds(coordinates) {
|
|
7
|
+
let left = [Infinity, 0];
|
|
8
|
+
let right = [-Infinity, 0];
|
|
9
|
+
let top = [0, Infinity];
|
|
10
|
+
let bottom = [0, -Infinity];
|
|
11
|
+
coordinates.forEach((d) => {
|
|
12
|
+
left = d[0] < left[0] ? d : left;
|
|
13
|
+
right = d[0] > right[0] ? d : right;
|
|
14
|
+
bottom = d[1] > bottom[1] ? d : bottom;
|
|
15
|
+
top = d[1] < top[1] ? d : top;
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
center: [(left[0] + right[0]) / 2, (top[1] + bottom[1]) / 2],
|
|
19
|
+
top,
|
|
20
|
+
left,
|
|
21
|
+
right,
|
|
22
|
+
bottom
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function contouring({ summaryType, data, finalXExtent, finalYExtent }) {
|
|
26
|
+
let projectedSummaries = [];
|
|
27
|
+
if (!summaryType.type) {
|
|
28
|
+
summaryType = { type: summaryType };
|
|
29
|
+
}
|
|
30
|
+
const { resolution = 500, thresholds = 10, bandwidth = 20, neighborhood } = summaryType;
|
|
31
|
+
const xScale = (0, d3_scale_1.scaleLinear)()
|
|
32
|
+
.domain(finalXExtent)
|
|
33
|
+
.rangeRound([0, resolution])
|
|
34
|
+
.nice();
|
|
35
|
+
const yScale = (0, d3_scale_1.scaleLinear)()
|
|
36
|
+
.domain(finalYExtent)
|
|
37
|
+
.rangeRound([resolution, 0])
|
|
38
|
+
.nice();
|
|
39
|
+
data.forEach((contourData) => {
|
|
40
|
+
let contourProjectedSummaries = (0, d3_contour_1.contourDensity)()
|
|
41
|
+
.size([resolution, resolution])
|
|
42
|
+
.x((d) => xScale(d[0]))
|
|
43
|
+
.y((d) => yScale(d[1]))
|
|
44
|
+
.thresholds(thresholds)
|
|
45
|
+
.bandwidth(bandwidth)(contourData._xyfCoordinates);
|
|
46
|
+
if (neighborhood) {
|
|
47
|
+
contourProjectedSummaries = [contourProjectedSummaries[0]];
|
|
48
|
+
}
|
|
49
|
+
const max = Math.max(...contourProjectedSummaries.map((d) => d.value));
|
|
50
|
+
contourProjectedSummaries.forEach((summary) => {
|
|
51
|
+
summary.parentSummary = contourData;
|
|
52
|
+
summary.bounds = [];
|
|
53
|
+
summary.percent = summary.value / max;
|
|
54
|
+
summary.coordinates.forEach((poly) => {
|
|
55
|
+
poly.forEach((subpoly, i) => {
|
|
56
|
+
poly[i] = subpoly.map((coordpair) => {
|
|
57
|
+
coordpair = [
|
|
58
|
+
xScale.invert(coordpair[0]),
|
|
59
|
+
yScale.invert(coordpair[1])
|
|
60
|
+
];
|
|
61
|
+
return coordpair;
|
|
62
|
+
});
|
|
63
|
+
//Only push bounds for the main poly, not its interior rings, otherwise you end up labeling interior cutouts
|
|
64
|
+
if (i === 0) {
|
|
65
|
+
summary.bounds.push(shapeBounds(poly[i]));
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
projectedSummaries = [...projectedSummaries, ...contourProjectedSummaries];
|
|
71
|
+
});
|
|
72
|
+
return projectedSummaries;
|
|
73
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.contourRenderFn = contourRenderFn;
|
|
4
|
+
const areaDrawing_1 = require("../svg/areaDrawing");
|
|
5
|
+
const contourMap = (d) => [d.xy.x, d.xy.y];
|
|
6
|
+
function contourRenderFn({ data, type, renderMode, eventListenersGenerator, styleFn, classFn, adjustedSize }) {
|
|
7
|
+
const keys = Object.keys(data);
|
|
8
|
+
const renderedSummaryMarks = [];
|
|
9
|
+
const summaryXYCoords = [];
|
|
10
|
+
keys.forEach((key, ordsetI) => {
|
|
11
|
+
const ordset = data[key];
|
|
12
|
+
type.thresholds = type.thresholds || 8;
|
|
13
|
+
type.bandwidth = type.bandwidth || 12;
|
|
14
|
+
type.resolution = type.resolution || 1000;
|
|
15
|
+
const projectedOrd = [
|
|
16
|
+
{ id: ordset, _xyfCoordinates: ordset.xyData.map(contourMap) }
|
|
17
|
+
];
|
|
18
|
+
const oContours = (0, areaDrawing_1.contouring)({
|
|
19
|
+
summaryType: type,
|
|
20
|
+
data: projectedOrd,
|
|
21
|
+
finalXExtent: [0, adjustedSize[0]],
|
|
22
|
+
finalYExtent: [0, adjustedSize[1]]
|
|
23
|
+
});
|
|
24
|
+
const contourMarks = [];
|
|
25
|
+
oContours.forEach((d, i) => {
|
|
26
|
+
d.coordinates.forEach((coords, ii) => {
|
|
27
|
+
const eventListeners = eventListenersGenerator(d, i);
|
|
28
|
+
contourMarks.push({
|
|
29
|
+
...eventListeners,
|
|
30
|
+
key: `${i}-${ii}`,
|
|
31
|
+
style: styleFn(ordset.pieceData[0].data, ordsetI),
|
|
32
|
+
className: classFn(ordset.pieceData[0].data, ordsetI),
|
|
33
|
+
markType: "path",
|
|
34
|
+
d: `M${d.coordinates[0].map((p) => p.join(",")).join("L")}Z`
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
renderedSummaryMarks.push({
|
|
39
|
+
containerProps: {
|
|
40
|
+
key: `contour-container-${ordsetI}`,
|
|
41
|
+
role: "img",
|
|
42
|
+
tabIndex: -1,
|
|
43
|
+
"data-o": key,
|
|
44
|
+
"aria-label": `${key} boxplot showing ${summaryXYCoords
|
|
45
|
+
.filter((d) => d.key === key)
|
|
46
|
+
.map((d) => `${d.label} ${d.value}`)}`
|
|
47
|
+
},
|
|
48
|
+
//These are drawn items
|
|
49
|
+
elements: contourMarks
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
return { marks: renderedSummaryMarks, xyPoints: summaryXYCoords };
|
|
53
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.dagreEdgeGenerator = exports.chordEdgeGenerator = exports.sankeyArrowGenerator = exports.arcEdgeGenerator = exports.matrixEdgeGenerator = exports.genericLineGenerator = exports.customEdgeHashD = exports.sigmoidLinks = void 0;
|
|
37
|
+
exports.sankeyEdgeSort = sankeyEdgeSort;
|
|
38
|
+
const React = __importStar(require("react"));
|
|
39
|
+
const react_1 = require("react");
|
|
40
|
+
const d3_selection_1 = require("d3-selection");
|
|
41
|
+
const d3_glyphedge_1 = require("d3-glyphedge");
|
|
42
|
+
const d3_path_arrows_1 = require("d3-path-arrows");
|
|
43
|
+
const d3_shape_1 = require("d3-shape");
|
|
44
|
+
const SvgHelper_1 = require("./SvgHelper");
|
|
45
|
+
const d3_interpolate_1 = require("d3-interpolate");
|
|
46
|
+
const nodeGenerators_1 = require("./nodeGenerators");
|
|
47
|
+
const curvature = 0.5;
|
|
48
|
+
const horizontalDagreLineGenerator = (0, d3_shape_1.line)()
|
|
49
|
+
.curve(d3_shape_1.curveMonotoneX)
|
|
50
|
+
.x((d) => d.x)
|
|
51
|
+
.y((d) => d.y);
|
|
52
|
+
const verticalDagreLineGenerator = (0, d3_shape_1.line)()
|
|
53
|
+
.curve(d3_shape_1.curveMonotoneY)
|
|
54
|
+
.x((d) => d.x)
|
|
55
|
+
.y((d) => d.y);
|
|
56
|
+
function sankeyEdgeSort(a, b, direction) {
|
|
57
|
+
if (a.circular && !b.circular)
|
|
58
|
+
return -1;
|
|
59
|
+
if (b.circular && !a.circular)
|
|
60
|
+
return 1;
|
|
61
|
+
const first = direction === "down" ? "y" : "x";
|
|
62
|
+
const second = direction === "down" ? "x" : "y";
|
|
63
|
+
return a.source[first] === b.source[first]
|
|
64
|
+
? a.sankeyWidth === b.sankeyWidth
|
|
65
|
+
? a.source[second] - b.source[second]
|
|
66
|
+
: b.sankeyWidth - a.sankeyWidth
|
|
67
|
+
: a.source[first] - b.source[first];
|
|
68
|
+
}
|
|
69
|
+
exports.sigmoidLinks = {
|
|
70
|
+
horizontal: (0, d3_shape_1.linkHorizontal)()
|
|
71
|
+
.x((d) => d.x)
|
|
72
|
+
.y((d) => d.y),
|
|
73
|
+
vertical: (0, d3_shape_1.linkVertical)()
|
|
74
|
+
.x((d) => d.x)
|
|
75
|
+
.y((d) => d.y),
|
|
76
|
+
radial: d3_glyphedge_1.d.lineArc
|
|
77
|
+
};
|
|
78
|
+
exports.customEdgeHashD = {
|
|
79
|
+
curve: (d, projection = "vertical") => exports.sigmoidLinks[projection](d),
|
|
80
|
+
linearc: (d) => d3_glyphedge_1.d.lineArc(d),
|
|
81
|
+
ribbon: (d) => d3_glyphedge_1.d.ribbon(d, d.width),
|
|
82
|
+
arrowhead: (d) => d3_glyphedge_1.d.arrowHead(d, d.target.nodeSize, d.width, d.width * 1.5),
|
|
83
|
+
halfarrow: (d) => d3_glyphedge_1.d.halfArrow(d, d.target.nodeSize, d.width, d.width * 1.5),
|
|
84
|
+
nail: (d) => d3_glyphedge_1.d.nail(d, d.source.nodeSize),
|
|
85
|
+
comet: (d) => d3_glyphedge_1.d.comet(d, d.target.nodeSize),
|
|
86
|
+
taffy: (d) => d3_glyphedge_1.d.taffy(d, d.source.nodeSize / 2, d.target.nodeSize / 2, (d.source.nodeSize + d.target.nodeSize) / 4)
|
|
87
|
+
};
|
|
88
|
+
const genericLineGenerator = (d) => `M${d.source.x},${d.source.y}L${d.target.x},${d.target.y}`;
|
|
89
|
+
exports.genericLineGenerator = genericLineGenerator;
|
|
90
|
+
const matrixEdgeGenerator = (size, nodes) => ({ d, i, styleFn, renderMode, key, className }) => {
|
|
91
|
+
const gridSize = Math.min(...size) / nodes.length;
|
|
92
|
+
const style = styleFn(d, i);
|
|
93
|
+
return (React.createElement("g", { key: key },
|
|
94
|
+
React.createElement("rect", { key: key, className: className, transform: `translate(${d.source.y},${d.target.y})`, ...style, style: style, "aria-label": `Connection from ${d.source.id} to ${d.target.id}`, tabIndex: -1, ...(0, nodeGenerators_1.gridProps)(gridSize) })));
|
|
95
|
+
};
|
|
96
|
+
exports.matrixEdgeGenerator = matrixEdgeGenerator;
|
|
97
|
+
const arcEdgeGenerator = (size) => {
|
|
98
|
+
const yAdjust = size[1] / size[0];
|
|
99
|
+
function arcDiagramArc(d) {
|
|
100
|
+
const draw = (0, d3_shape_1.line)().curve(d3_shape_1.curveBasis);
|
|
101
|
+
const midX = (d.source.x + d.target.x) / 2;
|
|
102
|
+
const midY = d.source.x - d.target.x;
|
|
103
|
+
return draw([
|
|
104
|
+
[d.source.x, 0],
|
|
105
|
+
[midX, midY * yAdjust],
|
|
106
|
+
[d.target.x, 0]
|
|
107
|
+
]);
|
|
108
|
+
}
|
|
109
|
+
return ({ d, i, styleFn, renderMode, key, className }) => {
|
|
110
|
+
const style = styleFn(d, i);
|
|
111
|
+
return (React.createElement("path", { key: key, className: className, transform: `translate(0,${size[1] / 2})`, d: arcDiagramArc(d), ...style, style: style, "aria-label": `Connection from ${d.source.id} to ${d.target.id}`, tabIndex: -1 }));
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
exports.arcEdgeGenerator = arcEdgeGenerator;
|
|
115
|
+
const ArrowedPath = (props) => {
|
|
116
|
+
const { d, width, edgeLength, circular } = props;
|
|
117
|
+
const pathRef = (0, react_1.useRef)(null);
|
|
118
|
+
(0, react_1.useEffect)(() => {
|
|
119
|
+
if (pathRef?.current) {
|
|
120
|
+
const circularMod = circular ? width : edgeLength;
|
|
121
|
+
const arrowHeadSize = Math.max(Math.min(width, circularMod) / 5, 2);
|
|
122
|
+
let arrows = (0, d3_path_arrows_1.pathArrows)()
|
|
123
|
+
.arrowLength(arrowHeadSize * 2.5)
|
|
124
|
+
.gapLength(100)
|
|
125
|
+
.arrowHeadSize(arrowHeadSize)
|
|
126
|
+
.path(d);
|
|
127
|
+
(0, d3_selection_1.select)(pathRef.current).selectAll("*").remove();
|
|
128
|
+
(0, d3_selection_1.select)(pathRef.current).call(arrows);
|
|
129
|
+
(0, d3_selection_1.select)(pathRef.current)
|
|
130
|
+
.selectAll(":not(.arrow-head)")
|
|
131
|
+
.style("fill", "none")
|
|
132
|
+
.style("stroke-width", arrowHeadSize / 4)
|
|
133
|
+
.style("stroke", "white");
|
|
134
|
+
(0, d3_selection_1.select)(pathRef.current).selectAll(".arrow-head").style("fill", "white");
|
|
135
|
+
}
|
|
136
|
+
}, [d]);
|
|
137
|
+
return React.createElement("g", { ref: pathRef });
|
|
138
|
+
};
|
|
139
|
+
const sankeyArrowGenerator = (props) => {
|
|
140
|
+
const { d, i, styleFn, renderMode, key, className, generatedPath } = props;
|
|
141
|
+
const { showArrows } = d;
|
|
142
|
+
let arrowPath = "";
|
|
143
|
+
if (d.circular) {
|
|
144
|
+
const { circularPathData } = d;
|
|
145
|
+
const { sourceX, sourceY, leftFullExtent, rightFullExtent, verticalFullExtent, targetX, targetY } = circularPathData;
|
|
146
|
+
arrowPath = `M${sourceX},${sourceY}L${leftFullExtent},${sourceY}L${leftFullExtent},${verticalFullExtent}L${rightFullExtent},${verticalFullExtent}L${rightFullExtent},${targetY}L${targetX},${targetY}`;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
let x0 = d.source.x1, x1 = d.target.x0, xi = (0, d3_interpolate_1.interpolateNumber)(x0, x1), x2 = xi(curvature), x3 = xi(1 - curvature), y0 = d.y0, y1 = d.y1;
|
|
150
|
+
arrowPath = `M${x0},${y0}C${x2},${y0} ${x3},${y1} ${x1},${y1}`;
|
|
151
|
+
}
|
|
152
|
+
return (React.createElement(React.Fragment, { key: key },
|
|
153
|
+
React.createElement("path", { className: className, d: generatedPath, style: styleFn(d, i), "aria-label": `Connection from ${d.source.id} to ${d.target.id}`, tabIndex: -1 }),
|
|
154
|
+
showArrows && (React.createElement(ArrowedPath, { d: arrowPath, width: d.sankeyWidth, edgeLength: Math.abs(d.target.x - d.source.x), circular: d.circular }))));
|
|
155
|
+
};
|
|
156
|
+
exports.sankeyArrowGenerator = sankeyArrowGenerator;
|
|
157
|
+
const chordEdgeGenerator = (size) => ({ d, i, styleFn, renderMode, key, className }) => (React.createElement("path", { key: key, className: className, transform: `translate(${size[0] / 2},${size[1] / 2})`, d: d.d, style: styleFn(d, i), "aria-label": `Connection from ${d.source.id} to ${d.target.id}`, tabIndex: -1 }));
|
|
158
|
+
exports.chordEdgeGenerator = chordEdgeGenerator;
|
|
159
|
+
const dagreEdgeGenerator = (direction) => {
|
|
160
|
+
const dagreLineGenerator = direction === "LR" || direction === "RL"
|
|
161
|
+
? horizontalDagreLineGenerator
|
|
162
|
+
: verticalDagreLineGenerator;
|
|
163
|
+
return ({ d, i, styleFn, renderMode, key, className }) => {
|
|
164
|
+
if (d.ribbon || d.parallelEdges) {
|
|
165
|
+
const ribbonGenerator = (0, SvgHelper_1.linearRibbon)();
|
|
166
|
+
ribbonGenerator.x((p) => p.x);
|
|
167
|
+
ribbonGenerator.y((p) => p.y);
|
|
168
|
+
ribbonGenerator.r(() => d.weight || 1);
|
|
169
|
+
if (d.parallelEdges) {
|
|
170
|
+
const sortedParallelEdges = d.parallelEdges.sort((a, b) => b.weight - a.weight);
|
|
171
|
+
return (React.createElement("g", { key: `${key}` }, ribbonGenerator({
|
|
172
|
+
points: d.points,
|
|
173
|
+
multiple: d.parallelEdges
|
|
174
|
+
}).map((ribbonD, ribbonI) => (React.createElement("path", { key: `${key}-${ribbonI}`, className: className, d: ribbonD, style: styleFn(sortedParallelEdges[ribbonI], i), "aria-label": `Connection from ${d.source.id} to ${d.target.id}`, tabIndex: -1 })))));
|
|
175
|
+
}
|
|
176
|
+
return (React.createElement("path", { key: key, className: className, d: ribbonGenerator(d.points), style: styleFn(d, i), "aria-label": `Connection from ${d.source.id} to ${d.target.id}`, tabIndex: -1 }));
|
|
177
|
+
}
|
|
178
|
+
return (React.createElement("path", { key: key, className: className, d: dagreLineGenerator(d.points), style: styleFn(d, i), "aria-label": `Connection from ${d.source.id} to ${d.target.id}`, tabIndex: -1 }));
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
exports.dagreEdgeGenerator = dagreEdgeGenerator;
|