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,302 @@
|
|
|
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.LineChart = LineChart;
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const react_1 = require("react");
|
|
43
|
+
const d3_shape_1 = require("d3-shape");
|
|
44
|
+
const XYFrame_1 = __importDefault(require("../../XYFrame"));
|
|
45
|
+
const colorUtils_1 = require("../shared/colorUtils");
|
|
46
|
+
const hooks_1 = require("../shared/hooks");
|
|
47
|
+
const legendUtils_1 = require("../shared/legendUtils");
|
|
48
|
+
const Tooltip_1 = require("../../Tooltip/Tooltip");
|
|
49
|
+
const ChartError_1 = __importDefault(require("../shared/ChartError"));
|
|
50
|
+
const validateChartData_1 = require("../shared/validateChartData");
|
|
51
|
+
/** Map of curve name strings to d3-shape curve functions */
|
|
52
|
+
const CURVE_MAP = {
|
|
53
|
+
linear: d3_shape_1.curveLinear,
|
|
54
|
+
monotoneX: d3_shape_1.curveMonotoneX,
|
|
55
|
+
monotoneY: d3_shape_1.curveMonotoneY,
|
|
56
|
+
step: d3_shape_1.curveStep,
|
|
57
|
+
stepAfter: d3_shape_1.curveStepAfter,
|
|
58
|
+
stepBefore: d3_shape_1.curveStepBefore,
|
|
59
|
+
basis: d3_shape_1.curveBasis,
|
|
60
|
+
cardinal: d3_shape_1.curveCardinal,
|
|
61
|
+
catmullRom: d3_shape_1.curveCatmullRom
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* LineChart - Visualize trends and time series data with lines
|
|
65
|
+
*
|
|
66
|
+
* A simplified wrapper around XYFrame for creating line charts. Perfect for
|
|
67
|
+
* showing trends, comparisons, and temporal patterns in your data.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```tsx
|
|
71
|
+
* // Simple line chart
|
|
72
|
+
* <LineChart
|
|
73
|
+
* data={[
|
|
74
|
+
* {x: 1, y: 10},
|
|
75
|
+
* {x: 2, y: 20},
|
|
76
|
+
* {x: 3, y: 15}
|
|
77
|
+
* ]}
|
|
78
|
+
* xLabel="Time"
|
|
79
|
+
* yLabel="Value"
|
|
80
|
+
* />
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```tsx
|
|
85
|
+
* // Multiple lines with grouping
|
|
86
|
+
* <LineChart
|
|
87
|
+
* data={[
|
|
88
|
+
* {x: 1, y: 10, series: 'A'},
|
|
89
|
+
* {x: 2, y: 20, series: 'A'},
|
|
90
|
+
* {x: 1, y: 15, series: 'B'},
|
|
91
|
+
* {x: 2, y: 25, series: 'B'}
|
|
92
|
+
* ]}
|
|
93
|
+
* lineBy="series"
|
|
94
|
+
* colorBy="series"
|
|
95
|
+
* xLabel="Time"
|
|
96
|
+
* yLabel="Value"
|
|
97
|
+
* />
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```tsx
|
|
102
|
+
* // Area chart with custom curve
|
|
103
|
+
* <LineChart
|
|
104
|
+
* data={data}
|
|
105
|
+
* curve="monotoneX"
|
|
106
|
+
* fillArea={true}
|
|
107
|
+
* areaOpacity={0.3}
|
|
108
|
+
* showPoints={true}
|
|
109
|
+
* />
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```tsx
|
|
114
|
+
* // Advanced: Override XYFrame props
|
|
115
|
+
* <LineChart
|
|
116
|
+
* data={data}
|
|
117
|
+
* frameProps={{
|
|
118
|
+
* lineType: { type: "line", interpolator: d3.curveCardinal },
|
|
119
|
+
* customLineMark: ({ d }) => <path stroke="red" />
|
|
120
|
+
* }}
|
|
121
|
+
* />
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* @remarks
|
|
125
|
+
* This component wraps {@link XYFrame} with sensible defaults for line charts.
|
|
126
|
+
* For more advanced features like custom marks, annotations, or complex interactions,
|
|
127
|
+
* use XYFrame directly.
|
|
128
|
+
*
|
|
129
|
+
* **Breadcrumb to advanced usage:**
|
|
130
|
+
* - Use the `frameProps` prop to pass any XYFrame prop
|
|
131
|
+
* - See XYFrame documentation: https://semiotic.nteract.io/guides/xy-frame
|
|
132
|
+
* - All XYFrame props are available via `frameProps`
|
|
133
|
+
*
|
|
134
|
+
* @param props - LineChart configuration
|
|
135
|
+
* @returns Rendered line chart
|
|
136
|
+
*/
|
|
137
|
+
function LineChart(props) {
|
|
138
|
+
const { data, width = 600, height = 400, margin: userMargin, className, title, xLabel, yLabel, xFormat, yFormat, xAccessor = "x", yAccessor = "y", lineBy, lineDataAccessor = "coordinates", colorBy, colorScheme = "category10", curve = "linear", showPoints = false, pointRadius = 3, fillArea = false, areaOpacity = 0.3, lineWidth = 2, enableHover = true, showGrid = false, showLegend, tooltip, frameProps = {} } = props;
|
|
139
|
+
const safeData = data || [];
|
|
140
|
+
// Check if data is in line objects format (has lineDataAccessor field)
|
|
141
|
+
const isLineObjectFormat = safeData[0]?.[lineDataAccessor] !== undefined;
|
|
142
|
+
// Transform data to line format if needed
|
|
143
|
+
const lineData = (0, react_1.useMemo)(() => {
|
|
144
|
+
if (isLineObjectFormat) {
|
|
145
|
+
// Data is already in line objects format
|
|
146
|
+
return safeData;
|
|
147
|
+
}
|
|
148
|
+
if (lineBy) {
|
|
149
|
+
// Group data by lineBy field
|
|
150
|
+
const grouped = safeData.reduce((acc, d) => {
|
|
151
|
+
const key = typeof lineBy === "function" ? lineBy(d) : d[lineBy];
|
|
152
|
+
if (!acc[key]) {
|
|
153
|
+
const lineObj = { [lineDataAccessor]: [] };
|
|
154
|
+
// Add the grouping field
|
|
155
|
+
if (typeof lineBy === "string") {
|
|
156
|
+
lineObj[lineBy] = key;
|
|
157
|
+
}
|
|
158
|
+
acc[key] = lineObj;
|
|
159
|
+
}
|
|
160
|
+
acc[key][lineDataAccessor].push(d);
|
|
161
|
+
return acc;
|
|
162
|
+
}, {});
|
|
163
|
+
return Object.values(grouped);
|
|
164
|
+
}
|
|
165
|
+
// Single line - wrap in line object
|
|
166
|
+
return [{ [lineDataAccessor]: safeData }];
|
|
167
|
+
}, [safeData, lineBy, lineDataAccessor, isLineObjectFormat]);
|
|
168
|
+
// Create color scale if colorBy is specified
|
|
169
|
+
const colorScale = (0, hooks_1.useColorScale)(safeData, colorBy, colorScheme);
|
|
170
|
+
// Curve function from module-level map
|
|
171
|
+
const curveFunction = CURVE_MAP[curve] || d3_shape_1.curveLinear;
|
|
172
|
+
// Line style function
|
|
173
|
+
const lineStyle = (0, react_1.useMemo)(() => {
|
|
174
|
+
return (d) => {
|
|
175
|
+
const baseStyle = {
|
|
176
|
+
strokeWidth: lineWidth
|
|
177
|
+
};
|
|
178
|
+
// Apply color
|
|
179
|
+
if (colorBy) {
|
|
180
|
+
baseStyle.stroke = (0, colorUtils_1.getColor)(d, colorBy, colorScale);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
baseStyle.stroke = hooks_1.DEFAULT_COLOR;
|
|
184
|
+
}
|
|
185
|
+
// Apply fill for area chart
|
|
186
|
+
if (fillArea) {
|
|
187
|
+
baseStyle.fill = baseStyle.stroke;
|
|
188
|
+
baseStyle.fillOpacity = areaOpacity;
|
|
189
|
+
}
|
|
190
|
+
return baseStyle;
|
|
191
|
+
};
|
|
192
|
+
}, [colorBy, colorScale, lineWidth, fillArea, areaOpacity]);
|
|
193
|
+
// Point style function (if showPoints is true)
|
|
194
|
+
const pointStyle = (0, react_1.useMemo)(() => {
|
|
195
|
+
if (!showPoints)
|
|
196
|
+
return undefined;
|
|
197
|
+
return (d) => {
|
|
198
|
+
const baseStyle = {
|
|
199
|
+
r: pointRadius,
|
|
200
|
+
fillOpacity: 1
|
|
201
|
+
};
|
|
202
|
+
// Match line color
|
|
203
|
+
if (colorBy) {
|
|
204
|
+
baseStyle.fill = (0, colorUtils_1.getColor)(d.parentLine || d, colorBy, colorScale);
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
baseStyle.fill = hooks_1.DEFAULT_COLOR;
|
|
208
|
+
}
|
|
209
|
+
return baseStyle;
|
|
210
|
+
};
|
|
211
|
+
}, [showPoints, pointRadius, colorBy, colorScale]);
|
|
212
|
+
// Build axes configuration
|
|
213
|
+
const axes = (0, react_1.useMemo)(() => {
|
|
214
|
+
const axesConfig = [];
|
|
215
|
+
// Y axis (left)
|
|
216
|
+
axesConfig.push({
|
|
217
|
+
orient: "left",
|
|
218
|
+
label: yLabel,
|
|
219
|
+
tickFormat: yFormat,
|
|
220
|
+
...(showGrid && { tickLineGenerator: () => null })
|
|
221
|
+
});
|
|
222
|
+
// X axis (bottom)
|
|
223
|
+
axesConfig.push({
|
|
224
|
+
orient: "bottom",
|
|
225
|
+
label: xLabel,
|
|
226
|
+
tickFormat: xFormat,
|
|
227
|
+
...(showGrid && { tickLineGenerator: () => null })
|
|
228
|
+
});
|
|
229
|
+
return axesConfig;
|
|
230
|
+
}, [xLabel, yLabel, xFormat, yFormat, showGrid]);
|
|
231
|
+
// Determine line type
|
|
232
|
+
const lineType = (0, react_1.useMemo)(() => {
|
|
233
|
+
const lineTypeConfig = {
|
|
234
|
+
type: fillArea ? "area" : "line",
|
|
235
|
+
interpolator: curveFunction
|
|
236
|
+
};
|
|
237
|
+
if (fillArea) {
|
|
238
|
+
lineTypeConfig.simpleLine = false;
|
|
239
|
+
}
|
|
240
|
+
return lineTypeConfig;
|
|
241
|
+
}, [fillArea, curveFunction]);
|
|
242
|
+
// Determine if we should show legend
|
|
243
|
+
const shouldShowLegend = showLegend !== undefined ? showLegend : lineData.length > 1;
|
|
244
|
+
// Build legend if needed
|
|
245
|
+
const legend = (0, react_1.useMemo)(() => {
|
|
246
|
+
if (!shouldShowLegend || !colorBy)
|
|
247
|
+
return undefined;
|
|
248
|
+
return (0, legendUtils_1.createLegend)({
|
|
249
|
+
data: lineData,
|
|
250
|
+
colorBy,
|
|
251
|
+
colorScale,
|
|
252
|
+
getColor: colorUtils_1.getColor
|
|
253
|
+
});
|
|
254
|
+
}, [shouldShowLegend, colorBy, lineData, colorScale]);
|
|
255
|
+
// Adjust margin for legend if present
|
|
256
|
+
const margin = (0, react_1.useMemo)(() => {
|
|
257
|
+
const defaultMargin = { top: 50, bottom: 60, left: 70, right: 40 };
|
|
258
|
+
const finalMargin = { ...defaultMargin, ...userMargin };
|
|
259
|
+
// If legend is present and right margin is too small, increase it
|
|
260
|
+
if (legend && finalMargin.right < 120) {
|
|
261
|
+
finalMargin.right = 120;
|
|
262
|
+
}
|
|
263
|
+
return finalMargin;
|
|
264
|
+
}, [userMargin, legend]);
|
|
265
|
+
// Validate data (after all hooks)
|
|
266
|
+
const error = (0, validateChartData_1.validateArrayData)({
|
|
267
|
+
componentName: "LineChart",
|
|
268
|
+
data: safeData,
|
|
269
|
+
accessors: {
|
|
270
|
+
xAccessor,
|
|
271
|
+
yAccessor,
|
|
272
|
+
},
|
|
273
|
+
});
|
|
274
|
+
if (error)
|
|
275
|
+
return React.createElement(ChartError_1.default, { componentName: "LineChart", message: error, width: width, height: height });
|
|
276
|
+
// Build XYFrame props
|
|
277
|
+
const xyFrameProps = {
|
|
278
|
+
size: [width, height],
|
|
279
|
+
lines: lineData,
|
|
280
|
+
xAccessor,
|
|
281
|
+
yAccessor,
|
|
282
|
+
lineDataAccessor,
|
|
283
|
+
lineType,
|
|
284
|
+
lineStyle,
|
|
285
|
+
axes: axes,
|
|
286
|
+
hoverAnnotation: enableHover,
|
|
287
|
+
margin,
|
|
288
|
+
...(showPoints && {
|
|
289
|
+
showLinePoints: true,
|
|
290
|
+
pointStyle
|
|
291
|
+
}),
|
|
292
|
+
...(legend && { legend }),
|
|
293
|
+
...(className && { className }),
|
|
294
|
+
...(title && { title }),
|
|
295
|
+
// Add tooltip support
|
|
296
|
+
...(tooltip && { tooltipContent: (0, Tooltip_1.normalizeTooltip)(tooltip) }),
|
|
297
|
+
// Allow frameProps to override defaults
|
|
298
|
+
transition: true,
|
|
299
|
+
...frameProps
|
|
300
|
+
};
|
|
301
|
+
return React.createElement(XYFrame_1.default, { ...xyFrameProps });
|
|
302
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
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.Scatterplot = Scatterplot;
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const react_1 = require("react");
|
|
43
|
+
const XYFrame_1 = __importDefault(require("../../XYFrame"));
|
|
44
|
+
const colorUtils_1 = require("../shared/colorUtils");
|
|
45
|
+
const legendUtils_1 = require("../shared/legendUtils");
|
|
46
|
+
const Tooltip_1 = require("../../Tooltip/Tooltip");
|
|
47
|
+
const hooks_1 = require("../shared/hooks");
|
|
48
|
+
const ChartError_1 = __importDefault(require("../shared/ChartError"));
|
|
49
|
+
const validateChartData_1 = require("../shared/validateChartData");
|
|
50
|
+
/**
|
|
51
|
+
* Scatterplot - Visualize relationships between two continuous variables
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```tsx
|
|
55
|
+
* <Scatterplot
|
|
56
|
+
* data={[{x: 1, y: 10}, {x: 2, y: 20}]}
|
|
57
|
+
* xLabel="Time"
|
|
58
|
+
* yLabel="Value"
|
|
59
|
+
* />
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
function Scatterplot(props) {
|
|
63
|
+
const { data, width = 600, height = 400, margin: userMargin, className, title, xLabel, yLabel, xFormat, yFormat, xAccessor = "x", yAccessor = "y", colorBy, colorScheme = "category10", sizeBy, sizeRange = [3, 15], pointRadius = 5, pointOpacity = 0.8, enableHover = true, showGrid = false, showLegend, tooltip, frameProps = {} } = props;
|
|
64
|
+
const safeData = data || [];
|
|
65
|
+
const colorScale = (0, hooks_1.useColorScale)(safeData, colorBy, colorScheme);
|
|
66
|
+
const sizeDomain = (0, react_1.useMemo)(() => {
|
|
67
|
+
if (!sizeBy || safeData.length === 0)
|
|
68
|
+
return undefined;
|
|
69
|
+
const sizes = safeData.map((d) => typeof sizeBy === "function" ? sizeBy(d) : d[sizeBy]);
|
|
70
|
+
return [Math.min(...sizes), Math.max(...sizes)];
|
|
71
|
+
}, [safeData, sizeBy]);
|
|
72
|
+
const pointStyle = (0, react_1.useMemo)(() => {
|
|
73
|
+
return (d) => {
|
|
74
|
+
const baseStyle = { fillOpacity: pointOpacity };
|
|
75
|
+
baseStyle.fill = colorBy ? (0, colorUtils_1.getColor)(d, colorBy, colorScale) : hooks_1.DEFAULT_COLOR;
|
|
76
|
+
baseStyle.r = sizeBy
|
|
77
|
+
? (0, colorUtils_1.getSize)(d, sizeBy, sizeRange, sizeDomain)
|
|
78
|
+
: pointRadius;
|
|
79
|
+
return baseStyle;
|
|
80
|
+
};
|
|
81
|
+
}, [colorBy, colorScale, sizeBy, sizeRange, sizeDomain, pointRadius, pointOpacity]);
|
|
82
|
+
const axes = (0, react_1.useMemo)(() => [
|
|
83
|
+
{
|
|
84
|
+
orient: "left",
|
|
85
|
+
label: yLabel,
|
|
86
|
+
tickFormat: yFormat,
|
|
87
|
+
...(showGrid && { tickLineGenerator: () => null })
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
orient: "bottom",
|
|
91
|
+
label: xLabel,
|
|
92
|
+
tickFormat: xFormat,
|
|
93
|
+
...(showGrid && { tickLineGenerator: () => null })
|
|
94
|
+
}
|
|
95
|
+
], [xLabel, yLabel, xFormat, yFormat, showGrid]);
|
|
96
|
+
const shouldShowLegend = showLegend !== undefined ? showLegend : !!colorBy;
|
|
97
|
+
const legend = (0, react_1.useMemo)(() => {
|
|
98
|
+
if (!shouldShowLegend || !colorBy)
|
|
99
|
+
return undefined;
|
|
100
|
+
return (0, legendUtils_1.createLegend)({ data: safeData, colorBy, colorScale, getColor: colorUtils_1.getColor });
|
|
101
|
+
}, [shouldShowLegend, colorBy, safeData, colorScale]);
|
|
102
|
+
const margin = (0, react_1.useMemo)(() => {
|
|
103
|
+
const finalMargin = { top: 50, bottom: 60, left: 70, right: 40, ...userMargin };
|
|
104
|
+
if (legend && finalMargin.right < 120)
|
|
105
|
+
finalMargin.right = 120;
|
|
106
|
+
return finalMargin;
|
|
107
|
+
}, [userMargin, legend]);
|
|
108
|
+
// Validate data (after all hooks)
|
|
109
|
+
const error = (0, validateChartData_1.validateArrayData)({
|
|
110
|
+
componentName: "Scatterplot",
|
|
111
|
+
data: safeData,
|
|
112
|
+
accessors: {
|
|
113
|
+
xAccessor,
|
|
114
|
+
yAccessor,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
if (error)
|
|
118
|
+
return React.createElement(ChartError_1.default, { componentName: "Scatterplot", message: error, width: width, height: height });
|
|
119
|
+
const xyFrameProps = {
|
|
120
|
+
size: [width, height],
|
|
121
|
+
points: safeData,
|
|
122
|
+
xAccessor,
|
|
123
|
+
yAccessor,
|
|
124
|
+
pointStyle,
|
|
125
|
+
axes: axes,
|
|
126
|
+
hoverAnnotation: enableHover,
|
|
127
|
+
margin,
|
|
128
|
+
...(legend && { legend }),
|
|
129
|
+
...(className && { className }),
|
|
130
|
+
...(title && { title }),
|
|
131
|
+
...(tooltip && { tooltipContent: (0, Tooltip_1.normalizeTooltip)(tooltip) }),
|
|
132
|
+
transition: true,
|
|
133
|
+
...frameProps
|
|
134
|
+
};
|
|
135
|
+
return React.createElement(XYFrame_1.default, { ...xyFrameProps });
|
|
136
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
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.StackedAreaChart = StackedAreaChart;
|
|
41
|
+
const React = __importStar(require("react"));
|
|
42
|
+
const react_1 = require("react");
|
|
43
|
+
const d3_shape_1 = require("d3-shape");
|
|
44
|
+
const XYFrame_1 = __importDefault(require("../../XYFrame"));
|
|
45
|
+
const colorUtils_1 = require("../shared/colorUtils");
|
|
46
|
+
const hooks_1 = require("../shared/hooks");
|
|
47
|
+
const legendUtils_1 = require("../shared/legendUtils");
|
|
48
|
+
const Tooltip_1 = require("../../Tooltip/Tooltip");
|
|
49
|
+
const ChartError_1 = __importDefault(require("../shared/ChartError"));
|
|
50
|
+
const validateChartData_1 = require("../shared/validateChartData");
|
|
51
|
+
/** Map of curve name strings to d3-shape curve functions */
|
|
52
|
+
const CURVE_MAP = {
|
|
53
|
+
linear: d3_shape_1.curveLinear,
|
|
54
|
+
monotoneX: d3_shape_1.curveMonotoneX,
|
|
55
|
+
monotoneY: d3_shape_1.curveMonotoneY,
|
|
56
|
+
step: d3_shape_1.curveStep,
|
|
57
|
+
stepAfter: d3_shape_1.curveStepAfter,
|
|
58
|
+
stepBefore: d3_shape_1.curveStepBefore,
|
|
59
|
+
basis: d3_shape_1.curveBasis,
|
|
60
|
+
cardinal: d3_shape_1.curveCardinal,
|
|
61
|
+
catmullRom: d3_shape_1.curveCatmullRom
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* StackedAreaChart - Visualize quantities stacked on top of each other over continuous intervals
|
|
65
|
+
*
|
|
66
|
+
* Each series is stacked so that the total height represents the sum of all series.
|
|
67
|
+
* Use `normalize` for 100% stacked (proportional) areas.
|
|
68
|
+
*
|
|
69
|
+
* For overlapping (non-stacked) areas use {@link AreaChart}.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```tsx
|
|
73
|
+
* <StackedAreaChart
|
|
74
|
+
* data={[
|
|
75
|
+
* {x: 1, y: 10, category: 'A'},
|
|
76
|
+
* {x: 2, y: 20, category: 'A'},
|
|
77
|
+
* {x: 1, y: 15, category: 'B'},
|
|
78
|
+
* {x: 2, y: 25, category: 'B'}
|
|
79
|
+
* ]}
|
|
80
|
+
* areaBy="category"
|
|
81
|
+
* colorBy="category"
|
|
82
|
+
* xLabel="Time"
|
|
83
|
+
* yLabel="Value"
|
|
84
|
+
* />
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
function StackedAreaChart(props) {
|
|
88
|
+
const { data, width = 600, height = 400, margin: userMargin, className, title, xLabel, yLabel, xFormat, yFormat, xAccessor = "x", yAccessor = "y", areaBy, lineDataAccessor = "coordinates", colorBy, colorScheme = "category10", curve = "monotoneX", areaOpacity = 0.7, showLine = true, lineWidth = 2, normalize = false, enableHover = true, showGrid = false, showLegend, tooltip, frameProps = {} } = props;
|
|
89
|
+
const safeData = data || [];
|
|
90
|
+
// Check if data is in area objects format (has lineDataAccessor field)
|
|
91
|
+
const isAreaObjectFormat = safeData[0]?.[lineDataAccessor] !== undefined;
|
|
92
|
+
// Transform data to line/area format if needed
|
|
93
|
+
const areaData = (0, react_1.useMemo)(() => {
|
|
94
|
+
if (isAreaObjectFormat) {
|
|
95
|
+
// Data is already in area objects format
|
|
96
|
+
return safeData;
|
|
97
|
+
}
|
|
98
|
+
if (areaBy) {
|
|
99
|
+
// Group data by areaBy field
|
|
100
|
+
const grouped = safeData.reduce((acc, d) => {
|
|
101
|
+
const key = typeof areaBy === "function" ? areaBy(d) : d[areaBy];
|
|
102
|
+
if (!acc[key]) {
|
|
103
|
+
const areaObj = { [lineDataAccessor]: [] };
|
|
104
|
+
// Add the grouping field
|
|
105
|
+
if (typeof areaBy === "string") {
|
|
106
|
+
areaObj[areaBy] = key;
|
|
107
|
+
}
|
|
108
|
+
acc[key] = areaObj;
|
|
109
|
+
}
|
|
110
|
+
acc[key][lineDataAccessor].push(d);
|
|
111
|
+
return acc;
|
|
112
|
+
}, {});
|
|
113
|
+
return Object.values(grouped);
|
|
114
|
+
}
|
|
115
|
+
// Single area - wrap in area object
|
|
116
|
+
return [{ [lineDataAccessor]: safeData }];
|
|
117
|
+
}, [safeData, areaBy, lineDataAccessor, isAreaObjectFormat]);
|
|
118
|
+
// Create color scale if colorBy is specified
|
|
119
|
+
const colorScale = (0, hooks_1.useColorScale)(safeData, colorBy, colorScheme);
|
|
120
|
+
// Curve function from module-level map
|
|
121
|
+
const curveFunction = CURVE_MAP[curve] || d3_shape_1.curveMonotoneX;
|
|
122
|
+
// Area/line style function
|
|
123
|
+
const lineStyle = (0, react_1.useMemo)(() => {
|
|
124
|
+
return (d) => {
|
|
125
|
+
const baseStyle = {};
|
|
126
|
+
// Apply color
|
|
127
|
+
const color = colorBy ? (0, colorUtils_1.getColor)(d, colorBy, colorScale) : hooks_1.DEFAULT_COLOR;
|
|
128
|
+
baseStyle.fill = color;
|
|
129
|
+
baseStyle.fillOpacity = areaOpacity;
|
|
130
|
+
if (showLine) {
|
|
131
|
+
baseStyle.stroke = color;
|
|
132
|
+
baseStyle.strokeWidth = lineWidth;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
baseStyle.stroke = "none";
|
|
136
|
+
}
|
|
137
|
+
return baseStyle;
|
|
138
|
+
};
|
|
139
|
+
}, [colorBy, colorScale, areaOpacity, showLine, lineWidth]);
|
|
140
|
+
// Build axes configuration
|
|
141
|
+
const axes = (0, react_1.useMemo)(() => {
|
|
142
|
+
const axesConfig = [];
|
|
143
|
+
// Y axis (left)
|
|
144
|
+
axesConfig.push({
|
|
145
|
+
orient: "left",
|
|
146
|
+
label: yLabel,
|
|
147
|
+
tickFormat: yFormat,
|
|
148
|
+
...(showGrid && { tickLineGenerator: () => null })
|
|
149
|
+
});
|
|
150
|
+
// X axis (bottom)
|
|
151
|
+
axesConfig.push({
|
|
152
|
+
orient: "bottom",
|
|
153
|
+
label: xLabel,
|
|
154
|
+
tickFormat: xFormat,
|
|
155
|
+
...(showGrid && { tickLineGenerator: () => null })
|
|
156
|
+
});
|
|
157
|
+
return axesConfig;
|
|
158
|
+
}, [xLabel, yLabel, xFormat, yFormat, showGrid]);
|
|
159
|
+
// Stacked area line type
|
|
160
|
+
const lineType = (0, react_1.useMemo)(() => ({
|
|
161
|
+
type: normalize ? "stackedpercent-area" : "stackedarea",
|
|
162
|
+
interpolator: curveFunction
|
|
163
|
+
}), [curveFunction, normalize]);
|
|
164
|
+
// Determine if we should show legend
|
|
165
|
+
const shouldShowLegend = showLegend !== undefined ? showLegend : areaData.length > 1;
|
|
166
|
+
// Build legend if needed
|
|
167
|
+
const legend = (0, react_1.useMemo)(() => {
|
|
168
|
+
if (!shouldShowLegend || !colorBy)
|
|
169
|
+
return undefined;
|
|
170
|
+
return (0, legendUtils_1.createLegend)({
|
|
171
|
+
data: areaData,
|
|
172
|
+
colorBy,
|
|
173
|
+
colorScale,
|
|
174
|
+
getColor: colorUtils_1.getColor
|
|
175
|
+
});
|
|
176
|
+
}, [shouldShowLegend, colorBy, areaData, colorScale]);
|
|
177
|
+
// Adjust margin for legend if present
|
|
178
|
+
const margin = (0, react_1.useMemo)(() => {
|
|
179
|
+
const defaultMargin = { top: 50, bottom: 60, left: 70, right: 40 };
|
|
180
|
+
const finalMargin = { ...defaultMargin, ...userMargin };
|
|
181
|
+
// If legend is present and right margin is too small, increase it
|
|
182
|
+
if (legend && finalMargin.right < 120) {
|
|
183
|
+
finalMargin.right = 120;
|
|
184
|
+
}
|
|
185
|
+
return finalMargin;
|
|
186
|
+
}, [userMargin, legend]);
|
|
187
|
+
// Validate data (after all hooks)
|
|
188
|
+
const error = (0, validateChartData_1.validateArrayData)({
|
|
189
|
+
componentName: "StackedAreaChart",
|
|
190
|
+
data: safeData,
|
|
191
|
+
accessors: {
|
|
192
|
+
xAccessor,
|
|
193
|
+
yAccessor,
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
if (error)
|
|
197
|
+
return React.createElement(ChartError_1.default, { componentName: "StackedAreaChart", message: error, width: width, height: height });
|
|
198
|
+
// Build XYFrame props
|
|
199
|
+
const xyFrameProps = {
|
|
200
|
+
size: [width, height],
|
|
201
|
+
lines: areaData,
|
|
202
|
+
xAccessor,
|
|
203
|
+
yAccessor,
|
|
204
|
+
lineDataAccessor,
|
|
205
|
+
lineType,
|
|
206
|
+
lineStyle,
|
|
207
|
+
axes: axes,
|
|
208
|
+
hoverAnnotation: enableHover,
|
|
209
|
+
margin,
|
|
210
|
+
...(legend && { legend }),
|
|
211
|
+
...(className && { className }),
|
|
212
|
+
...(title && { title }),
|
|
213
|
+
// Add tooltip support
|
|
214
|
+
...(tooltip && { tooltipContent: (0, Tooltip_1.normalizeTooltip)(tooltip) }),
|
|
215
|
+
// Allow frameProps to override defaults
|
|
216
|
+
transition: true,
|
|
217
|
+
...frameProps
|
|
218
|
+
};
|
|
219
|
+
return React.createElement(XYFrame_1.default, { ...xyFrameProps });
|
|
220
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.projectedXBottom = exports.projectedXTop = exports.projectedXMiddle = exports.projectedYBottom = exports.projectedYTop = exports.projectedYMiddle = exports.projectedY = exports.projectedX = void 0;
|
|
4
|
+
exports.projectedX = "x";
|
|
5
|
+
exports.projectedY = "y";
|
|
6
|
+
exports.projectedYMiddle = "yMiddle";
|
|
7
|
+
exports.projectedYTop = "yTop";
|
|
8
|
+
exports.projectedYBottom = "yBottom";
|
|
9
|
+
exports.projectedXMiddle = "xMiddle";
|
|
10
|
+
exports.projectedXTop = "xTop";
|
|
11
|
+
exports.projectedXBottom = "xBottom";
|