semiotic 2.0.2 → 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/Annotation.d.ts +3 -0
- package/dist/AnnotationLayer/AnnotationLayer.d.ts +25 -0
- package/dist/Axis/Axis.d.ts +7 -0
- package/dist/Axis/axisTitle.d.ts +10 -0
- package/dist/Axis/index.d.ts +2 -0
- package/dist/Axis/summaryGraphic.d.ts +17 -0
- package/dist/Brush.d.ts +12 -0
- package/dist/DividedLine.d.ts +16 -0
- package/dist/FacetController.d.ts +12 -0
- package/dist/Frame.d.ts +2 -0
- package/dist/InteractionLayer.d.ts +3 -0
- package/dist/Legend.d.ts +3 -0
- package/dist/MiniMap.d.ts +14 -0
- package/dist/MinimapXYFrame.d.ts +10 -0
- package/dist/NetworkFrame.d.ts +8 -0
- package/dist/OrdinalFrame.d.ts +8 -0
- package/dist/ResponsiveFrame.d.ts +22 -0
- package/dist/ResponsiveMinimapXYFrame.d.ts +3 -0
- package/dist/ResponsiveNetworkFrame.d.ts +3 -0
- package/dist/ResponsiveOrdinalFrame.d.ts +3 -0
- package/dist/ResponsiveXYFrame.d.ts +3 -0
- package/dist/SparkFrame.d.ts +14 -0
- package/dist/SparkNetworkFrame.d.ts +5 -0
- package/dist/SparkOrdinalFrame.d.ts +5 -0
- package/dist/SparkXYFrame.d.ts +5 -0
- package/dist/Tooltip/Tooltip.d.ts +141 -0
- package/dist/TooltipPositioner/index.d.ts +7 -0
- package/dist/VisualizationLayer.d.ts +33 -0
- package/dist/XYFrame.d.ts +8 -0
- package/dist/annotationLayerBehavior/annotationHandling.d.ts +19 -0
- package/dist/annotationLayerBehavior/d3labeler.d.ts +9 -0
- package/dist/annotationRules/baseRules.d.ts +25 -0
- package/dist/annotationRules/networkframeRules.d.ts +48 -0
- package/dist/annotationRules/orframeRules.d.ts +103 -0
- package/dist/annotationRules/xyframeRules.d.ts +117 -0
- package/dist/batchWork.d.ts +6 -0
- 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/coordinateNames.d.ts +8 -0
- package/dist/constants/frame_props.d.ts +13 -0
- package/dist/constants/jsx.d.ts +19 -0
- package/dist/data/dataFunctions.d.ts +45 -0
- package/dist/data/multiAccessorUtils.d.ts +1 -0
- package/dist/data/networkPipelineCache.d.ts +27 -0
- package/dist/data/ordinalPipelineCache.d.ts +33 -0
- package/dist/data/unflowedFunctions.d.ts +1 -0
- package/dist/data/xyPipelineCache.d.ts +35 -0
- package/dist/generic_utilities/functions.d.ts +1 -0
- package/dist/index.d.ts +133 -0
- package/dist/interactionLayerBehavior/InteractionCanvas.d.ts +20 -0
- 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 +13 -0
- 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 +111 -0
- package/dist/processing/networkDefaults.d.ts +36 -0
- package/dist/processing/networkLayoutHelpers.d.ts +54 -0
- package/dist/processing/ordinal.d.ts +102 -0
- 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 +140 -0
- 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 +51 -0
- package/dist/semiotic.js +18723 -12996
- package/dist/semiotic.js.map +1 -0
- package/dist/semiotic.min.js +1 -0
- package/dist/semiotic.module.js +18666 -12965
- 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/store/TooltipStore.d.ts +2 -0
- package/dist/store/createStore.d.ts +1 -0
- package/dist/svg/SvgHelper.d.ts +33 -0
- package/dist/svg/areaDrawing.d.ts +21 -0
- 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/ckmeans.d.ts +69 -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 +108 -0
- package/dist/svg/graphAlgorithms.d.ts +14 -0
- package/dist/svg/hexbinLayout.d.ts +7 -0
- package/dist/svg/lineDrawing.d.ts +99 -0
- package/dist/svg/networkDrawing.d.ts +16 -0
- package/dist/svg/nodeGenerators.d.ts +58 -0
- package/dist/svg/pieceDrawing.d.ts +12 -0
- package/dist/svg/pieceLayouts.d.ts +53 -0
- package/dist/svg/sankeyLinks.d.ts +3 -0
- package/dist/svg/summaryAxis.d.ts +6 -0
- package/dist/svg/summaryLayouts.d.ts +53 -0
- package/dist/svg/swarmLayout.d.ts +13 -0
- package/dist/types/annotationTypes.d.ts +135 -0
- package/dist/types/canvasTypes.d.ts +9 -0
- package/dist/types/generalTypes.d.ts +238 -0
- package/dist/types/interactionTypes.d.ts +72 -0
- package/dist/types/legendTypes.d.ts +20 -0
- package/dist/types/networkTypes.d.ts +175 -0
- package/dist/types/ordinalTypes.d.ts +112 -0
- package/dist/types/xyTypes.d.ts +115 -0
- package/dist/useBoundingRect.d.ts +2 -0
- package/dist/useDerivedStateFromProps.d.ts +1 -0
- package/dist/useLegacyUnmountCallback.d.ts +2 -0
- package/dist/visualizationLayerBehavior/axis.d.ts +36 -0
- package/dist/visualizationLayerBehavior/general.d.ts +80 -0
- 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 -65
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.PieChart = PieChart;
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const react_1 = require("react");
|
|
43
|
+
const OrdinalFrame_1 = __importDefault(require("../../OrdinalFrame"));
|
|
44
|
+
const colorUtils_1 = require("../shared/colorUtils");
|
|
45
|
+
const hooks_1 = require("../shared/hooks");
|
|
46
|
+
const legendUtils_1 = require("../shared/legendUtils");
|
|
47
|
+
const Tooltip_1 = require("../../Tooltip/Tooltip");
|
|
48
|
+
const ChartError_1 = __importDefault(require("../shared/ChartError"));
|
|
49
|
+
const validateChartData_1 = require("../shared/validateChartData");
|
|
50
|
+
/**
|
|
51
|
+
* PieChart - Visualize proportions as slices of a circle.
|
|
52
|
+
*
|
|
53
|
+
* A simplified wrapper around OrdinalFrame with radial projection.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```tsx
|
|
57
|
+
* <PieChart
|
|
58
|
+
* data={[
|
|
59
|
+
* {category: 'A', value: 30},
|
|
60
|
+
* {category: 'B', value: 50},
|
|
61
|
+
* {category: 'C', value: 20}
|
|
62
|
+
* ]}
|
|
63
|
+
* />
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
function PieChart(props) {
|
|
67
|
+
const { data, width = 400, height = 400, margin: userMargin, className, title, categoryAccessor = "category", valueAccessor = "value", colorBy, colorScheme = "category10", startAngle = 0, slicePadding = 2, enableHover = true, showLegend = true, tooltip, frameProps = {} } = props;
|
|
68
|
+
const safeData = data || [];
|
|
69
|
+
// Default colorBy to categoryAccessor for pie charts
|
|
70
|
+
const actualColorBy = colorBy || categoryAccessor;
|
|
71
|
+
// Create color scale
|
|
72
|
+
const colorScale = (0, hooks_1.useColorScale)(safeData, actualColorBy, colorScheme);
|
|
73
|
+
// Piece style function
|
|
74
|
+
const pieceStyle = (0, react_1.useMemo)(() => {
|
|
75
|
+
return (d) => {
|
|
76
|
+
const baseStyle = {};
|
|
77
|
+
if (actualColorBy) {
|
|
78
|
+
baseStyle.fill = (0, colorUtils_1.getColor)(d, actualColorBy, colorScale);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
baseStyle.fill = hooks_1.DEFAULT_COLOR;
|
|
82
|
+
}
|
|
83
|
+
return baseStyle;
|
|
84
|
+
};
|
|
85
|
+
}, [actualColorBy, colorScale]);
|
|
86
|
+
// Build legend if needed
|
|
87
|
+
const legend = (0, react_1.useMemo)(() => {
|
|
88
|
+
if (!showLegend)
|
|
89
|
+
return undefined;
|
|
90
|
+
return (0, legendUtils_1.createLegend)({
|
|
91
|
+
data: safeData,
|
|
92
|
+
colorBy: actualColorBy,
|
|
93
|
+
colorScale,
|
|
94
|
+
getColor: colorUtils_1.getColor
|
|
95
|
+
});
|
|
96
|
+
}, [showLegend, safeData, actualColorBy, colorScale]);
|
|
97
|
+
// Adjust margin for legend if present
|
|
98
|
+
const margin = (0, react_1.useMemo)(() => {
|
|
99
|
+
const defaultMargin = { top: 20, bottom: 20, left: 20, right: 20 };
|
|
100
|
+
const finalMargin = { ...defaultMargin, ...userMargin };
|
|
101
|
+
if (legend && finalMargin.right < 120) {
|
|
102
|
+
finalMargin.right = 120;
|
|
103
|
+
}
|
|
104
|
+
return finalMargin;
|
|
105
|
+
}, [userMargin, legend]);
|
|
106
|
+
// Build type config
|
|
107
|
+
const typeConfig = (0, react_1.useMemo)(() => {
|
|
108
|
+
const config = { type: "bar" };
|
|
109
|
+
if (startAngle) {
|
|
110
|
+
config.offsetAngle = startAngle;
|
|
111
|
+
}
|
|
112
|
+
return config;
|
|
113
|
+
}, [startAngle]);
|
|
114
|
+
// Default tooltip
|
|
115
|
+
const defaultTooltipContent = (0, react_1.useMemo)(() => {
|
|
116
|
+
return (d) => {
|
|
117
|
+
const cat = typeof categoryAccessor === "function" ? categoryAccessor(d) : d[categoryAccessor];
|
|
118
|
+
const val = typeof valueAccessor === "function" ? valueAccessor(d) : d[valueAccessor];
|
|
119
|
+
return (React.createElement("div", { className: "semiotic-tooltip", style: Tooltip_1.defaultTooltipStyle },
|
|
120
|
+
React.createElement("div", { style: { fontWeight: "bold" } }, String(cat)),
|
|
121
|
+
React.createElement("div", { style: { marginTop: "4px" } }, typeof val === "number" ? val.toLocaleString() : String(val))));
|
|
122
|
+
};
|
|
123
|
+
}, [categoryAccessor, valueAccessor]);
|
|
124
|
+
// Validate data (after all hooks)
|
|
125
|
+
const error = (0, validateChartData_1.validateArrayData)({
|
|
126
|
+
componentName: "PieChart",
|
|
127
|
+
data: safeData,
|
|
128
|
+
accessors: {
|
|
129
|
+
categoryAccessor,
|
|
130
|
+
valueAccessor,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
if (error)
|
|
134
|
+
return React.createElement(ChartError_1.default, { componentName: "PieChart", message: error, width: width, height: height });
|
|
135
|
+
// Build OrdinalFrame props
|
|
136
|
+
const ordinalFrameProps = {
|
|
137
|
+
size: [width, height],
|
|
138
|
+
data: safeData,
|
|
139
|
+
oAccessor: categoryAccessor,
|
|
140
|
+
rAccessor: valueAccessor,
|
|
141
|
+
type: typeConfig,
|
|
142
|
+
projection: "radial",
|
|
143
|
+
style: pieceStyle,
|
|
144
|
+
hoverAnnotation: enableHover,
|
|
145
|
+
margin,
|
|
146
|
+
oPadding: slicePadding,
|
|
147
|
+
...(legend && { legend }),
|
|
148
|
+
...(className && { className }),
|
|
149
|
+
...(title && { title }),
|
|
150
|
+
tooltipContent: (tooltip ? (0, Tooltip_1.normalizeTooltip)(tooltip) : defaultTooltipContent),
|
|
151
|
+
transition: true,
|
|
152
|
+
...frameProps
|
|
153
|
+
};
|
|
154
|
+
return React.createElement(OrdinalFrame_1.default, { ...ordinalFrameProps });
|
|
155
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.StackedBarChart = StackedBarChart;
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const react_1 = require("react");
|
|
43
|
+
const OrdinalFrame_1 = __importDefault(require("../../OrdinalFrame"));
|
|
44
|
+
const colorUtils_1 = require("../shared/colorUtils");
|
|
45
|
+
const hooks_1 = require("../shared/hooks");
|
|
46
|
+
const legendUtils_1 = require("../shared/legendUtils");
|
|
47
|
+
const Tooltip_1 = require("../../Tooltip/Tooltip");
|
|
48
|
+
const ChartError_1 = __importDefault(require("../shared/ChartError"));
|
|
49
|
+
const validateChartData_1 = require("../shared/validateChartData");
|
|
50
|
+
/**
|
|
51
|
+
* StackedBarChart - Visualize part-to-whole relationships with stacked bars.
|
|
52
|
+
*
|
|
53
|
+
* A simplified wrapper around OrdinalFrame for creating stacked bar charts.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```tsx
|
|
57
|
+
* <StackedBarChart
|
|
58
|
+
* data={[
|
|
59
|
+
* {category: 'Q1', product: 'A', value: 100},
|
|
60
|
+
* {category: 'Q1', product: 'B', value: 150},
|
|
61
|
+
* {category: 'Q2', product: 'A', value: 120},
|
|
62
|
+
* {category: 'Q2', product: 'B', value: 180}
|
|
63
|
+
* ]}
|
|
64
|
+
* stackBy="product"
|
|
65
|
+
* categoryLabel="Quarter"
|
|
66
|
+
* valueLabel="Sales"
|
|
67
|
+
* />
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
function StackedBarChart(props) {
|
|
71
|
+
const { data, width = 600, height = 400, margin: userMargin, className, title, categoryAccessor = "category", stackBy, valueAccessor = "value", orientation = "vertical", categoryLabel, valueLabel, valueFormat, colorBy, colorScheme = "category10", normalize = false, barPadding = 5, enableHover = true, showGrid = false, showLegend = true, tooltip, frameProps = {} } = props;
|
|
72
|
+
const safeData = data || [];
|
|
73
|
+
// Use stackBy as colorBy if not specified
|
|
74
|
+
const actualColorBy = colorBy || stackBy;
|
|
75
|
+
// Get unique stack values for legend
|
|
76
|
+
const stackValues = (0, react_1.useMemo)(() => {
|
|
77
|
+
const getStackValue = (0, hooks_1.resolveAccessor)(stackBy);
|
|
78
|
+
return Array.from(new Set(safeData.map(getStackValue)));
|
|
79
|
+
}, [safeData, stackBy]);
|
|
80
|
+
// Create color scale
|
|
81
|
+
const colorScale = (0, hooks_1.useColorScale)(safeData, actualColorBy, colorScheme);
|
|
82
|
+
// Piece style function
|
|
83
|
+
const pieceStyle = (0, react_1.useMemo)(() => {
|
|
84
|
+
return (d) => {
|
|
85
|
+
const baseStyle = {};
|
|
86
|
+
// Apply color
|
|
87
|
+
if (actualColorBy) {
|
|
88
|
+
baseStyle.fill = (0, colorUtils_1.getColor)(d, actualColorBy, colorScale);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
baseStyle.fill = hooks_1.DEFAULT_COLOR;
|
|
92
|
+
}
|
|
93
|
+
return baseStyle;
|
|
94
|
+
};
|
|
95
|
+
}, [actualColorBy, colorScale]);
|
|
96
|
+
// Build axes configuration
|
|
97
|
+
const axes = (0, react_1.useMemo)(() => {
|
|
98
|
+
const axesConfig = [];
|
|
99
|
+
if (orientation === "vertical") {
|
|
100
|
+
// Vertical bars: category on bottom, value on left
|
|
101
|
+
axesConfig.push({
|
|
102
|
+
orient: "left",
|
|
103
|
+
label: valueLabel,
|
|
104
|
+
tickFormat: valueFormat,
|
|
105
|
+
...(showGrid && { tickLineGenerator: () => null })
|
|
106
|
+
});
|
|
107
|
+
if (categoryLabel) {
|
|
108
|
+
axesConfig.push({
|
|
109
|
+
orient: "bottom",
|
|
110
|
+
label: categoryLabel
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// Horizontal bars: category on left, value on bottom
|
|
116
|
+
if (categoryLabel) {
|
|
117
|
+
axesConfig.push({
|
|
118
|
+
orient: "left",
|
|
119
|
+
label: categoryLabel
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
axesConfig.push({
|
|
123
|
+
orient: "bottom",
|
|
124
|
+
label: valueLabel,
|
|
125
|
+
tickFormat: valueFormat,
|
|
126
|
+
...(showGrid && { tickLineGenerator: () => null })
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return axesConfig;
|
|
130
|
+
}, [orientation, categoryLabel, valueLabel, valueFormat, showGrid]);
|
|
131
|
+
// Build legend if needed
|
|
132
|
+
const legend = (0, react_1.useMemo)(() => {
|
|
133
|
+
if (!showLegend)
|
|
134
|
+
return undefined;
|
|
135
|
+
return (0, legendUtils_1.createLegend)({
|
|
136
|
+
data: safeData,
|
|
137
|
+
colorBy: actualColorBy,
|
|
138
|
+
colorScale,
|
|
139
|
+
getColor: colorUtils_1.getColor
|
|
140
|
+
});
|
|
141
|
+
}, [showLegend, safeData, actualColorBy, colorScale]);
|
|
142
|
+
// Adjust margin for legend if present
|
|
143
|
+
const margin = (0, react_1.useMemo)(() => {
|
|
144
|
+
const defaultMargin = { top: 50, bottom: 60, left: 70, right: 120 };
|
|
145
|
+
const finalMargin = { ...defaultMargin, ...userMargin };
|
|
146
|
+
// If legend is present and right margin is too small, increase it
|
|
147
|
+
if (legend && finalMargin.right < 120) {
|
|
148
|
+
finalMargin.right = 120;
|
|
149
|
+
}
|
|
150
|
+
return finalMargin;
|
|
151
|
+
}, [userMargin, legend]);
|
|
152
|
+
// Default tooltip function for piece hover
|
|
153
|
+
const defaultTooltipContent = (0, react_1.useMemo)(() => {
|
|
154
|
+
const getStack = (0, hooks_1.resolveAccessor)(stackBy);
|
|
155
|
+
const getCat = (0, hooks_1.resolveAccessor)(categoryAccessor);
|
|
156
|
+
const getVal = (0, hooks_1.resolveAccessor)(valueAccessor);
|
|
157
|
+
return (d) => {
|
|
158
|
+
const stackValue = String(getStack(d));
|
|
159
|
+
const cat = String(getCat(d));
|
|
160
|
+
const val = Number(getVal(d));
|
|
161
|
+
const pieces = d.pieces || [];
|
|
162
|
+
const total = pieces.reduce((sum, p) => sum + (Number(getVal(p)) || 0), 0);
|
|
163
|
+
const showTotal = pieces.length > 1;
|
|
164
|
+
return (React.createElement("div", { className: "semiotic-tooltip", style: Tooltip_1.defaultTooltipStyle },
|
|
165
|
+
React.createElement("div", { style: { fontWeight: "bold" } }, stackValue),
|
|
166
|
+
React.createElement("div", { style: { marginTop: "4px" } },
|
|
167
|
+
cat,
|
|
168
|
+
" \u00B7 ",
|
|
169
|
+
val.toLocaleString()),
|
|
170
|
+
showTotal && (React.createElement("div", { style: { marginTop: "2px", opacity: 0.8 } },
|
|
171
|
+
"Total: ",
|
|
172
|
+
total.toLocaleString()))));
|
|
173
|
+
};
|
|
174
|
+
}, [stackBy, categoryAccessor, valueAccessor]);
|
|
175
|
+
// Validate data (after all hooks)
|
|
176
|
+
const error = (0, validateChartData_1.validateArrayData)({
|
|
177
|
+
componentName: "StackedBarChart",
|
|
178
|
+
data: safeData,
|
|
179
|
+
accessors: {
|
|
180
|
+
categoryAccessor,
|
|
181
|
+
valueAccessor,
|
|
182
|
+
},
|
|
183
|
+
requiredProps: { stackBy },
|
|
184
|
+
});
|
|
185
|
+
if (error)
|
|
186
|
+
return React.createElement(ChartError_1.default, { componentName: "StackedBarChart", message: error, width: width, height: height });
|
|
187
|
+
// Build OrdinalFrame props
|
|
188
|
+
const ordinalFrameProps = {
|
|
189
|
+
size: [width, height],
|
|
190
|
+
data: safeData,
|
|
191
|
+
oAccessor: categoryAccessor,
|
|
192
|
+
rAccessor: valueAccessor,
|
|
193
|
+
type: "bar",
|
|
194
|
+
projection: orientation === "horizontal" ? "horizontal" : "vertical",
|
|
195
|
+
style: pieceStyle,
|
|
196
|
+
axes: axes,
|
|
197
|
+
hoverAnnotation: enableHover,
|
|
198
|
+
margin,
|
|
199
|
+
oPadding: barPadding,
|
|
200
|
+
// Configure stacking
|
|
201
|
+
pieceIDAccessor: stackBy,
|
|
202
|
+
...(normalize && { rExtent: [0, 1] }),
|
|
203
|
+
...(legend && { legend }),
|
|
204
|
+
...(className && { className }),
|
|
205
|
+
...(title && { title }),
|
|
206
|
+
// Add tooltip support
|
|
207
|
+
tooltipContent: (tooltip ? (0, Tooltip_1.normalizeTooltip)(tooltip) : defaultTooltipContent),
|
|
208
|
+
// Allow frameProps to override defaults
|
|
209
|
+
transition: true,
|
|
210
|
+
...frameProps
|
|
211
|
+
};
|
|
212
|
+
return React.createElement(OrdinalFrame_1.default, { ...ordinalFrameProps });
|
|
213
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.SwarmPlot = SwarmPlot;
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const react_1 = require("react");
|
|
43
|
+
const OrdinalFrame_1 = __importDefault(require("../../OrdinalFrame"));
|
|
44
|
+
const colorUtils_1 = require("../shared/colorUtils");
|
|
45
|
+
const hooks_1 = require("../shared/hooks");
|
|
46
|
+
const legendUtils_1 = require("../shared/legendUtils");
|
|
47
|
+
const Tooltip_1 = require("../../Tooltip/Tooltip");
|
|
48
|
+
const ChartError_1 = __importDefault(require("../shared/ChartError"));
|
|
49
|
+
const validateChartData_1 = require("../shared/validateChartData");
|
|
50
|
+
/**
|
|
51
|
+
* SwarmPlot - Visualize distributions with non-overlapping points.
|
|
52
|
+
*
|
|
53
|
+
* A simplified wrapper around OrdinalFrame for creating swarm plots (beeswarm plots).
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```tsx
|
|
57
|
+
* <SwarmPlot
|
|
58
|
+
* data={[
|
|
59
|
+
* {category: 'Group A', value: 10},
|
|
60
|
+
* {category: 'Group A', value: 12},
|
|
61
|
+
* {category: 'Group A', value: 11},
|
|
62
|
+
* {category: 'Group B', value: 15},
|
|
63
|
+
* {category: 'Group B', value: 14}
|
|
64
|
+
* ]}
|
|
65
|
+
* categoryLabel="Group"
|
|
66
|
+
* valueLabel="Value"
|
|
67
|
+
* />
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
function SwarmPlot(props) {
|
|
71
|
+
const { data, width = 600, height = 400, margin: userMargin, className, title, categoryAccessor = "category", valueAccessor = "value", orientation = "vertical", categoryLabel, valueLabel, valueFormat, colorBy, colorScheme = "category10", sizeBy, sizeRange = [3, 8], pointRadius = 4, pointOpacity = 0.7, categoryPadding = 20, enableHover = true, showGrid = false, showLegend, tooltip, frameProps = {} } = props;
|
|
72
|
+
const safeData = data || [];
|
|
73
|
+
// Create color scale if colorBy is specified
|
|
74
|
+
const colorScale = (0, hooks_1.useColorScale)(safeData, colorBy, colorScheme);
|
|
75
|
+
// Calculate size domain if sizeBy is specified
|
|
76
|
+
const sizeDomain = (0, react_1.useMemo)(() => {
|
|
77
|
+
if (!sizeBy)
|
|
78
|
+
return undefined;
|
|
79
|
+
const sizes = safeData.map((d) => {
|
|
80
|
+
if (typeof sizeBy === "function") {
|
|
81
|
+
return sizeBy(d);
|
|
82
|
+
}
|
|
83
|
+
return d[sizeBy];
|
|
84
|
+
});
|
|
85
|
+
return [Math.min(...sizes), Math.max(...sizes)];
|
|
86
|
+
}, [safeData, sizeBy]);
|
|
87
|
+
// Point style function
|
|
88
|
+
const pieceStyle = (0, react_1.useMemo)(() => {
|
|
89
|
+
return (d) => {
|
|
90
|
+
const baseStyle = {
|
|
91
|
+
fillOpacity: pointOpacity
|
|
92
|
+
};
|
|
93
|
+
// Apply color
|
|
94
|
+
if (colorBy) {
|
|
95
|
+
baseStyle.fill = (0, colorUtils_1.getColor)(d, colorBy, colorScale);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
baseStyle.fill = hooks_1.DEFAULT_COLOR;
|
|
99
|
+
}
|
|
100
|
+
// Apply size
|
|
101
|
+
if (sizeBy) {
|
|
102
|
+
baseStyle.r = (0, colorUtils_1.getSize)(d, sizeBy, sizeRange, sizeDomain);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
baseStyle.r = pointRadius;
|
|
106
|
+
}
|
|
107
|
+
return baseStyle;
|
|
108
|
+
};
|
|
109
|
+
}, [colorBy, colorScale, sizeBy, sizeRange, sizeDomain, pointRadius, pointOpacity]);
|
|
110
|
+
// Build axes configuration
|
|
111
|
+
const axes = (0, react_1.useMemo)(() => {
|
|
112
|
+
const axesConfig = [];
|
|
113
|
+
if (orientation === "vertical") {
|
|
114
|
+
// Vertical: category on bottom, value on left
|
|
115
|
+
axesConfig.push({
|
|
116
|
+
orient: "left",
|
|
117
|
+
label: valueLabel,
|
|
118
|
+
tickFormat: valueFormat,
|
|
119
|
+
...(showGrid && { tickLineGenerator: () => null })
|
|
120
|
+
});
|
|
121
|
+
if (categoryLabel) {
|
|
122
|
+
axesConfig.push({
|
|
123
|
+
orient: "bottom",
|
|
124
|
+
label: categoryLabel
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
// Horizontal: category on left, value on bottom
|
|
130
|
+
if (categoryLabel) {
|
|
131
|
+
axesConfig.push({
|
|
132
|
+
orient: "left",
|
|
133
|
+
label: categoryLabel
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
axesConfig.push({
|
|
137
|
+
orient: "bottom",
|
|
138
|
+
label: valueLabel,
|
|
139
|
+
tickFormat: valueFormat,
|
|
140
|
+
...(showGrid && { tickLineGenerator: () => null })
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return axesConfig;
|
|
144
|
+
}, [orientation, categoryLabel, valueLabel, valueFormat, showGrid]);
|
|
145
|
+
// Determine if we should show legend
|
|
146
|
+
const shouldShowLegend = showLegend !== undefined ? showLegend : !!colorBy;
|
|
147
|
+
// Build legend if needed
|
|
148
|
+
const legend = (0, react_1.useMemo)(() => {
|
|
149
|
+
if (!shouldShowLegend || !colorBy)
|
|
150
|
+
return undefined;
|
|
151
|
+
return (0, legendUtils_1.createLegend)({
|
|
152
|
+
data: safeData,
|
|
153
|
+
colorBy,
|
|
154
|
+
colorScale,
|
|
155
|
+
getColor: colorUtils_1.getColor
|
|
156
|
+
});
|
|
157
|
+
}, [shouldShowLegend, colorBy, safeData, colorScale]);
|
|
158
|
+
// Adjust margin for legend if present
|
|
159
|
+
const margin = (0, react_1.useMemo)(() => {
|
|
160
|
+
const defaultMargin = { top: 50, bottom: 60, left: 70, right: 40 };
|
|
161
|
+
const finalMargin = { ...defaultMargin, ...userMargin };
|
|
162
|
+
// If legend is present and right margin is too small, increase it
|
|
163
|
+
if (legend && finalMargin.right < 120) {
|
|
164
|
+
finalMargin.right = 120;
|
|
165
|
+
}
|
|
166
|
+
return finalMargin;
|
|
167
|
+
}, [userMargin, legend]);
|
|
168
|
+
// Default tooltip function for piece hover
|
|
169
|
+
const defaultTooltipContent = (0, react_1.useMemo)(() => {
|
|
170
|
+
const getVal = (0, hooks_1.resolveAccessor)(valueAccessor);
|
|
171
|
+
const getCat = (0, hooks_1.resolveAccessor)(categoryAccessor);
|
|
172
|
+
return (d) => {
|
|
173
|
+
const cat = getCat(d);
|
|
174
|
+
const val = getVal(d);
|
|
175
|
+
const pieces = d.pieces || [];
|
|
176
|
+
const showCount = pieces.length > 1;
|
|
177
|
+
return (React.createElement("div", { className: "semiotic-tooltip", style: Tooltip_1.defaultTooltipStyle },
|
|
178
|
+
React.createElement("div", { style: { fontWeight: "bold" } }, String(cat)),
|
|
179
|
+
React.createElement("div", { style: { marginTop: "4px" } }, typeof val === "number" ? val.toLocaleString() : String(val)),
|
|
180
|
+
showCount && (React.createElement("div", { style: { marginTop: "2px", opacity: 0.8 } },
|
|
181
|
+
pieces.length,
|
|
182
|
+
" points in group"))));
|
|
183
|
+
};
|
|
184
|
+
}, [categoryAccessor, valueAccessor]);
|
|
185
|
+
// Validate data (after all hooks)
|
|
186
|
+
const error = (0, validateChartData_1.validateArrayData)({
|
|
187
|
+
componentName: "SwarmPlot",
|
|
188
|
+
data: safeData,
|
|
189
|
+
accessors: {
|
|
190
|
+
categoryAccessor,
|
|
191
|
+
valueAccessor,
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
if (error)
|
|
195
|
+
return React.createElement(ChartError_1.default, { componentName: "SwarmPlot", message: error, width: width, height: height });
|
|
196
|
+
// Build OrdinalFrame props
|
|
197
|
+
const ordinalFrameProps = {
|
|
198
|
+
size: [width, height],
|
|
199
|
+
data: safeData,
|
|
200
|
+
oAccessor: categoryAccessor,
|
|
201
|
+
rAccessor: valueAccessor,
|
|
202
|
+
type: "swarm",
|
|
203
|
+
projection: orientation === "horizontal" ? "horizontal" : "vertical",
|
|
204
|
+
style: pieceStyle,
|
|
205
|
+
axes: axes,
|
|
206
|
+
pieceHoverAnnotation: enableHover,
|
|
207
|
+
margin,
|
|
208
|
+
oPadding: categoryPadding,
|
|
209
|
+
...(legend && { legend }),
|
|
210
|
+
...(className && { className }),
|
|
211
|
+
...(title && { title }),
|
|
212
|
+
// Add tooltip support
|
|
213
|
+
tooltipContent: (tooltip ? (0, Tooltip_1.normalizeTooltip)(tooltip) : defaultTooltipContent),
|
|
214
|
+
// Allow frameProps to override defaults
|
|
215
|
+
transition: true,
|
|
216
|
+
...frameProps
|
|
217
|
+
};
|
|
218
|
+
return React.createElement(OrdinalFrame_1.default, { ...ordinalFrameProps });
|
|
219
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.RealtimeBarChart = void 0;
|
|
40
|
+
const React = __importStar(require("react"));
|
|
41
|
+
const react_1 = require("react");
|
|
42
|
+
const RealtimeFrame_1 = __importDefault(require("../../realtime/RealtimeFrame"));
|
|
43
|
+
/**
|
|
44
|
+
* RealtimeBarChart - Simplified wrapper for streaming temporal histograms.
|
|
45
|
+
*
|
|
46
|
+
* Wraps RealtimeFrame with `chartType="bar"` and exposes bar styling as
|
|
47
|
+
* top-level props. Supports both simple and stacked (categorical) modes.
|
|
48
|
+
*
|
|
49
|
+
* Edge bins that only partially fall within the visible time window are
|
|
50
|
+
* rendered at proportionally narrower widths (Datadog-style).
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* // Simple histogram
|
|
55
|
+
* <RealtimeBarChart
|
|
56
|
+
* ref={ref}
|
|
57
|
+
* binSize={20}
|
|
58
|
+
* fill="#007bff"
|
|
59
|
+
* enableHover
|
|
60
|
+
* />
|
|
61
|
+
*
|
|
62
|
+
* // Stacked by category
|
|
63
|
+
* <RealtimeBarChart
|
|
64
|
+
* ref={ref}
|
|
65
|
+
* binSize={25}
|
|
66
|
+
* categoryAccessor="category"
|
|
67
|
+
* colors={{ errors: "#dc3545", warnings: "#fd7e14", info: "#007bff" }}
|
|
68
|
+
* enableHover
|
|
69
|
+
* />
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
exports.RealtimeBarChart = (0, react_1.forwardRef)(function RealtimeBarChart(props, ref) {
|
|
73
|
+
const { binSize, size = [500, 300], margin, className, arrowOfTime = "right", windowMode = "sliding", windowSize = 200, data, timeAccessor, valueAccessor, timeExtent, valueExtent, extentPadding, categoryAccessor, colors, fill, stroke, strokeWidth, gap, showAxes = true, background, enableHover, tooltipContent, onHover, annotations, svgAnnotationRules, tickFormatTime, tickFormatValue } = props;
|
|
74
|
+
const frameRef = (0, react_1.useRef)(null);
|
|
75
|
+
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
76
|
+
push: (point) => frameRef.current?.push(point),
|
|
77
|
+
pushMany: (points) => frameRef.current?.pushMany(points),
|
|
78
|
+
clear: () => frameRef.current?.clear(),
|
|
79
|
+
getData: () => frameRef.current?.getData() ?? []
|
|
80
|
+
}));
|
|
81
|
+
const barStyle = {};
|
|
82
|
+
if (fill != null)
|
|
83
|
+
barStyle.fill = fill;
|
|
84
|
+
if (stroke != null)
|
|
85
|
+
barStyle.stroke = stroke;
|
|
86
|
+
if (strokeWidth != null)
|
|
87
|
+
barStyle.strokeWidth = strokeWidth;
|
|
88
|
+
if (gap != null)
|
|
89
|
+
barStyle.gap = gap;
|
|
90
|
+
return (React.createElement(RealtimeFrame_1.default, { ref: frameRef, chartType: "bar", size: size, margin: margin, className: className, arrowOfTime: arrowOfTime, windowMode: windowMode, windowSize: windowSize, data: data, timeAccessor: timeAccessor, valueAccessor: valueAccessor, timeExtent: timeExtent, valueExtent: valueExtent, extentPadding: extentPadding, binSize: binSize, categoryAccessor: categoryAccessor, barColors: colors, barStyle: barStyle, showAxes: showAxes, background: background, hoverAnnotation: enableHover, tooltipContent: tooltipContent, customHoverBehavior: onHover, annotations: annotations, svgAnnotationRules: svgAnnotationRules, tickFormatTime: tickFormatTime, tickFormatValue: tickFormatValue }));
|
|
91
|
+
});
|