@cronus-ui/ui 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +262 -0
- package/dist/charts/animation.d.ts +11 -0
- package/dist/charts/animation.js +29 -0
- package/dist/charts/area-chart-loading.d.ts +34 -0
- package/dist/charts/area-chart-loading.js +22 -0
- package/dist/charts/area-chart.d.ts +48 -0
- package/dist/charts/area-chart.js +57 -0
- package/dist/charts/area-gradient-defs.d.ts +20 -0
- package/dist/charts/area-gradient-defs.js +15 -0
- package/dist/charts/area.d.ts +76 -0
- package/dist/charts/area.js +104 -0
- package/dist/charts/background.d.ts +27 -0
- package/dist/charts/background.js +68 -0
- package/dist/charts/bar-chart-loading.d.ts +17 -0
- package/dist/charts/bar-chart-loading.js +14 -0
- package/dist/charts/bar-chart.d.ts +55 -0
- package/dist/charts/bar-chart.js +432 -0
- package/dist/charts/bar-depth-geometry.d.ts +33 -0
- package/dist/charts/bar-depth-geometry.js +38 -0
- package/dist/charts/bar-depth.d.ts +157 -0
- package/dist/charts/bar-depth.js +586 -0
- package/dist/charts/bar-squares-layout.d.ts +28 -0
- package/dist/charts/bar-squares-layout.js +47 -0
- package/dist/charts/bar-squares.d.ts +49 -0
- package/dist/charts/bar-squares.js +207 -0
- package/dist/charts/bar-x-axis.d.ts +14 -0
- package/dist/charts/bar-x-axis.js +73 -0
- package/dist/charts/bar-y-axis.d.ts +12 -0
- package/dist/charts/bar-y-axis.js +64 -0
- package/dist/charts/bar.d.ts +41 -0
- package/dist/charts/bar.js +208 -0
- package/dist/charts/candlestick-chart.d.ts +46 -0
- package/dist/charts/candlestick-chart.js +203 -0
- package/dist/charts/candlestick.d.ts +24 -0
- package/dist/charts/candlestick.js +139 -0
- package/dist/charts/chart-brush-handle.d.ts +15 -0
- package/dist/charts/chart-brush-handle.js +47 -0
- package/dist/charts/chart-brush-layout.d.ts +27 -0
- package/dist/charts/chart-brush-layout.js +42 -0
- package/dist/charts/chart-brush-selection-overlay.d.ts +19 -0
- package/dist/charts/chart-brush-selection-overlay.js +44 -0
- package/dist/charts/chart-brush-track-overlay.d.ts +23 -0
- package/dist/charts/chart-brush-track-overlay.js +65 -0
- package/dist/charts/chart-brush.d.ts +32 -0
- package/dist/charts/chart-brush.js +116 -0
- package/dist/charts/chart-center-typography.d.ts +12 -0
- package/dist/charts/chart-center-typography.js +12 -0
- package/dist/charts/chart-child-passthrough.d.ts +17 -0
- package/dist/charts/chart-child-passthrough.js +74 -0
- package/dist/charts/chart-config-context.d.ts +26 -0
- package/dist/charts/chart-config-context.js +47 -0
- package/dist/charts/chart-context.d.ts +199 -0
- package/dist/charts/chart-context.js +201 -0
- package/dist/charts/chart-defs.d.ts +13 -0
- package/dist/charts/chart-defs.js +49 -0
- package/dist/charts/chart-formatters.d.ts +10 -0
- package/dist/charts/chart-formatters.js +28 -0
- package/dist/charts/chart-legend-hover.d.ts +13 -0
- package/dist/charts/chart-legend-hover.js +18 -0
- package/dist/charts/chart-legend.d.ts +55 -0
- package/dist/charts/chart-legend.js +30 -0
- package/dist/charts/chart-loading-label.d.ts +10 -0
- package/dist/charts/chart-loading-label.js +21 -0
- package/dist/charts/chart-phase.d.ts +31 -0
- package/dist/charts/chart-phase.js +21 -0
- package/dist/charts/chart-reveal-clip.d.ts +24 -0
- package/dist/charts/chart-reveal-clip.js +24 -0
- package/dist/charts/chart-scale.d.ts +12 -0
- package/dist/charts/chart-scale.js +17 -0
- package/dist/charts/chart-stat-flow.d.ts +36 -0
- package/dist/charts/chart-stat-flow.js +23 -0
- package/dist/charts/choropleth/choropleth-chart.d.ts +43 -0
- package/dist/charts/choropleth/choropleth-chart.js +218 -0
- package/dist/charts/choropleth/choropleth-context.d.ts +86 -0
- package/dist/charts/choropleth/choropleth-context.js +106 -0
- package/dist/charts/choropleth/choropleth-feature.d.ts +13 -0
- package/dist/charts/choropleth/choropleth-feature.js +125 -0
- package/dist/charts/choropleth/choropleth-graticule.d.ts +11 -0
- package/dist/charts/choropleth/choropleth-graticule.js +12 -0
- package/dist/charts/choropleth/choropleth-tooltip.d.ts +31 -0
- package/dist/charts/choropleth/choropleth-tooltip.js +50 -0
- package/dist/charts/choropleth/index.d.ts +7 -0
- package/dist/charts/choropleth/index.js +6 -0
- package/dist/charts/composed-chart.d.ts +36 -0
- package/dist/charts/composed-chart.js +152 -0
- package/dist/charts/dash-tail-stroke.d.ts +18 -0
- package/dist/charts/dash-tail-stroke.js +13 -0
- package/dist/charts/decimate-time-series.d.ts +10 -0
- package/dist/charts/decimate-time-series.js +112 -0
- package/dist/charts/fade-edges.d.ts +34 -0
- package/dist/charts/fade-edges.js +35 -0
- package/dist/charts/filter-data-by-x-domain.d.ts +5 -0
- package/dist/charts/filter-data-by-x-domain.js +42 -0
- package/dist/charts/funnel-chart.d.ts +91 -0
- package/dist/charts/funnel-chart.js +302 -0
- package/dist/charts/gauge-label-layout.d.ts +22 -0
- package/dist/charts/gauge-label-layout.js +44 -0
- package/dist/charts/gauge.d.ts +56 -0
- package/dist/charts/gauge.js +307 -0
- package/dist/charts/generate-chart-skeleton-data.d.ts +16 -0
- package/dist/charts/generate-chart-skeleton-data.js +25 -0
- package/dist/charts/grid.d.ts +58 -0
- package/dist/charts/grid.js +80 -0
- package/dist/charts/heatmap/generate-heatmap-skeleton-data.d.ts +4 -0
- package/dist/charts/heatmap/generate-heatmap-skeleton-data.js +12 -0
- package/dist/charts/heatmap/heatmap-animation.d.ts +41 -0
- package/dist/charts/heatmap/heatmap-animation.js +85 -0
- package/dist/charts/heatmap/heatmap-cells.d.ts +21 -0
- package/dist/charts/heatmap/heatmap-cells.js +265 -0
- package/dist/charts/heatmap/heatmap-chart-loading.d.ts +21 -0
- package/dist/charts/heatmap/heatmap-chart-loading.js +14 -0
- package/dist/charts/heatmap/heatmap-chart.d.ts +80 -0
- package/dist/charts/heatmap/heatmap-chart.js +275 -0
- package/dist/charts/heatmap/heatmap-colors.d.ts +70 -0
- package/dist/charts/heatmap/heatmap-colors.js +113 -0
- package/dist/charts/heatmap/heatmap-context.d.ts +109 -0
- package/dist/charts/heatmap/heatmap-context.js +69 -0
- package/dist/charts/heatmap/heatmap-legend-gradient.d.ts +20 -0
- package/dist/charts/heatmap/heatmap-legend-gradient.js +44 -0
- package/dist/charts/heatmap/heatmap-legend-swatch.d.ts +8 -0
- package/dist/charts/heatmap/heatmap-legend-swatch.js +26 -0
- package/dist/charts/heatmap/heatmap-legend.d.ts +41 -0
- package/dist/charts/heatmap/heatmap-legend.js +68 -0
- package/dist/charts/heatmap/heatmap-pattern-defs.d.ts +5 -0
- package/dist/charts/heatmap/heatmap-pattern-defs.js +25 -0
- package/dist/charts/heatmap/heatmap-resolve-separator.d.ts +8 -0
- package/dist/charts/heatmap/heatmap-resolve-separator.js +82 -0
- package/dist/charts/heatmap/heatmap-separator.d.ts +63 -0
- package/dist/charts/heatmap/heatmap-separator.js +71 -0
- package/dist/charts/heatmap/heatmap-tooltip.d.ts +30 -0
- package/dist/charts/heatmap/heatmap-tooltip.js +20 -0
- package/dist/charts/heatmap/heatmap-utils.d.ts +175 -0
- package/dist/charts/heatmap/heatmap-utils.js +595 -0
- package/dist/charts/heatmap/heatmap-x-axis.d.ts +7 -0
- package/dist/charts/heatmap/heatmap-x-axis.js +54 -0
- package/dist/charts/heatmap/heatmap-y-axis.d.ts +14 -0
- package/dist/charts/heatmap/heatmap-y-axis.js +37 -0
- package/dist/charts/heatmap/index.d.ts +15 -0
- package/dist/charts/heatmap/index.js +15 -0
- package/dist/charts/heatmap/use-delayed-tooltip-data.d.ts +3 -0
- package/dist/charts/heatmap/use-delayed-tooltip-data.js +53 -0
- package/dist/charts/highlight-segment-bounds.d.ts +18 -0
- package/dist/charts/highlight-segment-bounds.js +36 -0
- package/dist/charts/highlight-segment.d.ts +22 -0
- package/dist/charts/highlight-segment.js +14 -0
- package/dist/charts/index.d.ts +106 -0
- package/dist/charts/index.js +133 -0
- package/dist/charts/indicator-fade.d.ts +15 -0
- package/dist/charts/indicator-fade.js +42 -0
- package/dist/charts/legend/index.d.ts +8 -0
- package/dist/charts/legend/index.js +10 -0
- package/dist/charts/legend/legend-context.d.ts +48 -0
- package/dist/charts/legend/legend-context.js +34 -0
- package/dist/charts/legend/legend-item.d.ts +12 -0
- package/dist/charts/legend/legend-item.js +11 -0
- package/dist/charts/legend/legend-label.d.ts +9 -0
- package/dist/charts/legend/legend-label.js +10 -0
- package/dist/charts/legend/legend-marker.d.ts +9 -0
- package/dist/charts/legend/legend-marker.js +11 -0
- package/dist/charts/legend/legend-progress.d.ts +13 -0
- package/dist/charts/legend/legend-progress.js +15 -0
- package/dist/charts/legend/legend-value.d.ts +17 -0
- package/dist/charts/legend/legend-value.js +11 -0
- package/dist/charts/legend/legend.d.ts +23 -0
- package/dist/charts/legend/legend.js +43 -0
- package/dist/charts/line-chart-loading.d.ts +34 -0
- package/dist/charts/line-chart-loading.js +22 -0
- package/dist/charts/line-chart.d.ts +46 -0
- package/dist/charts/line-chart.js +91 -0
- package/dist/charts/line-loading-pulse.d.ts +20 -0
- package/dist/charts/line-loading-pulse.js +124 -0
- package/dist/charts/line-loading-timing.d.ts +10 -0
- package/dist/charts/line-loading-timing.js +10 -0
- package/dist/charts/line-series-terminal-marker.d.ts +16 -0
- package/dist/charts/line-series-terminal-marker.js +46 -0
- package/dist/charts/line.d.ts +64 -0
- package/dist/charts/line.js +96 -0
- package/dist/charts/live-line-chart.d.ts +35 -0
- package/dist/charts/live-line-chart.js +374 -0
- package/dist/charts/live-line.d.ts +39 -0
- package/dist/charts/live-line.js +78 -0
- package/dist/charts/live-x-axis.d.ts +12 -0
- package/dist/charts/live-x-axis.js +85 -0
- package/dist/charts/live-y-axis.d.ts +16 -0
- package/dist/charts/live-y-axis.js +137 -0
- package/dist/charts/loading-sweep.d.ts +66 -0
- package/dist/charts/loading-sweep.js +174 -0
- package/dist/charts/markers/chart-markers.d.ts +25 -0
- package/dist/charts/markers/chart-markers.js +87 -0
- package/dist/charts/markers/index.d.ts +3 -0
- package/dist/charts/markers/index.js +3 -0
- package/dist/charts/markers/marker-group.d.ts +88 -0
- package/dist/charts/markers/marker-group.js +171 -0
- package/dist/charts/motion-utils.d.ts +9 -0
- package/dist/charts/motion-utils.js +28 -0
- package/dist/charts/notch-gauge-shared.d.ts +49 -0
- package/dist/charts/notch-gauge-shared.js +103 -0
- package/dist/charts/path-stroke-utils.d.ts +20 -0
- package/dist/charts/path-stroke-utils.js +55 -0
- package/dist/charts/pattern-area.d.ts +21 -0
- package/dist/charts/pattern-area.js +19 -0
- package/dist/charts/pattern-preset.d.ts +26 -0
- package/dist/charts/pattern-preset.js +83 -0
- package/dist/charts/pie-center-shell.d.ts +24 -0
- package/dist/charts/pie-center-shell.js +109 -0
- package/dist/charts/pie-center.d.ts +46 -0
- package/dist/charts/pie-center.js +46 -0
- package/dist/charts/pie-chart.d.ts +50 -0
- package/dist/charts/pie-chart.js +248 -0
- package/dist/charts/pie-context.d.ts +74 -0
- package/dist/charts/pie-context.js +95 -0
- package/dist/charts/pie-slice.d.ts +28 -0
- package/dist/charts/pie-slice.js +180 -0
- package/dist/charts/profit-loss-legend-hover.d.ts +11 -0
- package/dist/charts/profit-loss-legend-hover.js +12 -0
- package/dist/charts/profit-loss-legend.d.ts +17 -0
- package/dist/charts/profit-loss-legend.js +18 -0
- package/dist/charts/profit-loss-line.d.ts +27 -0
- package/dist/charts/profit-loss-line.js +77 -0
- package/dist/charts/profit-loss-segments.d.ts +12 -0
- package/dist/charts/profit-loss-segments.js +86 -0
- package/dist/charts/projection-config.d.ts +11 -0
- package/dist/charts/projection-config.js +80 -0
- package/dist/charts/projection-line-end-marker.d.ts +15 -0
- package/dist/charts/projection-line-end-marker.js +27 -0
- package/dist/charts/projection-line.d.ts +40 -0
- package/dist/charts/projection-line.js +79 -0
- package/dist/charts/projection-utils.d.ts +46 -0
- package/dist/charts/projection-utils.js +253 -0
- package/dist/charts/radar-area.d.ts +17 -0
- package/dist/charts/radar-area.js +84 -0
- package/dist/charts/radar-axis.d.ts +14 -0
- package/dist/charts/radar-axis.js +24 -0
- package/dist/charts/radar-chart.d.ts +36 -0
- package/dist/charts/radar-chart.js +89 -0
- package/dist/charts/radar-context.d.ts +68 -0
- package/dist/charts/radar-context.js +87 -0
- package/dist/charts/radar-grid.d.ts +16 -0
- package/dist/charts/radar-grid.js +40 -0
- package/dist/charts/radar-labels.d.ts +16 -0
- package/dist/charts/radar-labels.js +29 -0
- package/dist/charts/reference-area-config.d.ts +10 -0
- package/dist/charts/reference-area-config.js +39 -0
- package/dist/charts/reference-area-geometry.d.ts +23 -0
- package/dist/charts/reference-area-geometry.js +68 -0
- package/dist/charts/reference-area-registration-context.d.ts +8 -0
- package/dist/charts/reference-area-registration-context.js +7 -0
- package/dist/charts/reference-area.d.ts +52 -0
- package/dist/charts/reference-area.js +101 -0
- package/dist/charts/ring-center.d.ts +46 -0
- package/dist/charts/ring-center.js +41 -0
- package/dist/charts/ring-chart.d.ts +41 -0
- package/dist/charts/ring-chart.js +212 -0
- package/dist/charts/ring-context.d.ts +66 -0
- package/dist/charts/ring-context.js +92 -0
- package/dist/charts/ring.d.ts +11 -0
- package/dist/charts/ring.js +104 -0
- package/dist/charts/sankey/index.d.ts +6 -0
- package/dist/charts/sankey/index.js +6 -0
- package/dist/charts/sankey/sankey-chart.d.ts +39 -0
- package/dist/charts/sankey/sankey-chart.js +117 -0
- package/dist/charts/sankey/sankey-context.d.ts +69 -0
- package/dist/charts/sankey/sankey-context.js +23 -0
- package/dist/charts/sankey/sankey-link.d.ts +26 -0
- package/dist/charts/sankey/sankey-link.js +155 -0
- package/dist/charts/sankey/sankey-node.d.ts +29 -0
- package/dist/charts/sankey/sankey-node.js +200 -0
- package/dist/charts/sankey/sankey-tooltip.d.ts +24 -0
- package/dist/charts/sankey/sankey-tooltip.js +70 -0
- package/dist/charts/scatter-chart-shell.d.ts +21 -0
- package/dist/charts/scatter-chart-shell.js +152 -0
- package/dist/charts/scatter-chart.d.ts +32 -0
- package/dist/charts/scatter-chart.js +56 -0
- package/dist/charts/scatter-svg.d.ts +6 -0
- package/dist/charts/scatter-svg.js +16 -0
- package/dist/charts/scatter.d.ts +21 -0
- package/dist/charts/scatter.js +30 -0
- package/dist/charts/segment.d.ts +26 -0
- package/dist/charts/segment.js +42 -0
- package/dist/charts/series-bar-layout.d.ts +18 -0
- package/dist/charts/series-bar-layout.js +31 -0
- package/dist/charts/series-bar.d.ts +20 -0
- package/dist/charts/series-bar.js +120 -0
- package/dist/charts/series-dash-tail-overlay.d.ts +17 -0
- package/dist/charts/series-dash-tail-overlay.js +39 -0
- package/dist/charts/series-highlight-layer.d.ts +23 -0
- package/dist/charts/series-highlight-layer.js +21 -0
- package/dist/charts/series-hover-dim.d.ts +29 -0
- package/dist/charts/series-hover-dim.js +26 -0
- package/dist/charts/series-markers.d.ts +14 -0
- package/dist/charts/series-markers.js +98 -0
- package/dist/charts/series-path-utils.d.ts +19 -0
- package/dist/charts/series-path-utils.js +60 -0
- package/dist/charts/series-point-marker.d.ts +48 -0
- package/dist/charts/series-point-marker.js +48 -0
- package/dist/charts/shimmering-text.d.ts +23 -0
- package/dist/charts/shimmering-text.js +31 -0
- package/dist/charts/static-chart-preview-context.d.ts +7 -0
- package/dist/charts/static-chart-preview-context.js +12 -0
- package/dist/charts/sunburst-breadcrumb.d.ts +16 -0
- package/dist/charts/sunburst-breadcrumb.js +26 -0
- package/dist/charts/sunburst-center.d.ts +5 -0
- package/dist/charts/sunburst-center.js +17 -0
- package/dist/charts/sunburst-chart.d.ts +30 -0
- package/dist/charts/sunburst-chart.js +263 -0
- package/dist/charts/sunburst-context.d.ts +61 -0
- package/dist/charts/sunburst-context.js +112 -0
- package/dist/charts/sunburst-data.d.ts +9 -0
- package/dist/charts/sunburst-data.js +2 -0
- package/dist/charts/sunburst-hint.d.ts +13 -0
- package/dist/charts/sunburst-hint.js +31 -0
- package/dist/charts/sunburst-labels.d.ts +9 -0
- package/dist/charts/sunburst-labels.js +63 -0
- package/dist/charts/sunburst-segment.d.ts +11 -0
- package/dist/charts/sunburst-segment.js +78 -0
- package/dist/charts/sunburst.d.ts +101 -0
- package/dist/charts/sunburst.js +396 -0
- package/dist/charts/time-series-chart-shell.d.ts +47 -0
- package/dist/charts/time-series-chart-shell.js +390 -0
- package/dist/charts/tooltip/chart-tooltip.d.ts +76 -0
- package/dist/charts/tooltip/chart-tooltip.js +150 -0
- package/dist/charts/tooltip/date-ticker.d.ts +11 -0
- package/dist/charts/tooltip/date-ticker.js +77 -0
- package/dist/charts/tooltip/index.d.ts +7 -0
- package/dist/charts/tooltip/index.js +7 -0
- package/dist/charts/tooltip/tooltip-box.d.ts +48 -0
- package/dist/charts/tooltip/tooltip-box.js +114 -0
- package/dist/charts/tooltip/tooltip-content.d.ts +18 -0
- package/dist/charts/tooltip/tooltip-content.js +9 -0
- package/dist/charts/tooltip/tooltip-dot.d.ts +28 -0
- package/dist/charts/tooltip/tooltip-dot.js +54 -0
- package/dist/charts/tooltip/tooltip-indicator.d.ts +45 -0
- package/dist/charts/tooltip/tooltip-indicator.js +65 -0
- package/dist/charts/use-animated-series-path.d.ts +19 -0
- package/dist/charts/use-animated-series-path.js +93 -0
- package/dist/charts/use-animated-y-domains.d.ts +14 -0
- package/dist/charts/use-animated-y-domains.js +150 -0
- package/dist/charts/use-chart-interaction.d.ts +41 -0
- package/dist/charts/use-chart-interaction.js +244 -0
- package/dist/charts/use-chart-phase-orchestrator.d.ts +23 -0
- package/dist/charts/use-chart-phase-orchestrator.js +139 -0
- package/dist/charts/use-enter-complete.d.ts +8 -0
- package/dist/charts/use-enter-complete.js +23 -0
- package/dist/charts/use-grid-shimmer.d.ts +16 -0
- package/dist/charts/use-grid-shimmer.js +63 -0
- package/dist/charts/use-highlight-segment.d.ts +14 -0
- package/dist/charts/use-highlight-segment.js +34 -0
- package/dist/charts/use-mount-progress.d.ts +4 -0
- package/dist/charts/use-mount-progress.js +22 -0
- package/dist/charts/use-scatter-chart-interaction.d.ts +35 -0
- package/dist/charts/use-scatter-chart-interaction.js +228 -0
- package/dist/charts/use-scheduled-tooltip.d.ts +9 -0
- package/dist/charts/use-scheduled-tooltip.js +76 -0
- package/dist/charts/visx-pattern.d.ts +19 -0
- package/dist/charts/visx-pattern.js +20 -0
- package/dist/charts/x-axis.d.ts +27 -0
- package/dist/charts/x-axis.js +415 -0
- package/dist/charts/y-axis-scales.d.ts +26 -0
- package/dist/charts/y-axis-scales.js +72 -0
- package/dist/charts/y-axis-ticks.d.ts +12 -0
- package/dist/charts/y-axis-ticks.js +24 -0
- package/dist/charts/y-axis.d.ts +22 -0
- package/dist/charts/y-axis.js +80 -0
- package/dist/charts/y-domain-utils.d.ts +27 -0
- package/dist/charts/y-domain-utils.js +88 -0
- package/dist/components/accordion.d.ts +6 -0
- package/dist/components/accordion.js +20 -0
- package/dist/components/alert-dialog.d.ts +18 -0
- package/dist/components/alert-dialog.js +41 -0
- package/dist/components/alert.d.ts +24 -0
- package/dist/components/alert.js +46 -0
- package/dist/components/animated-button.d.ts +5 -0
- package/dist/components/animated-button.js +16 -0
- package/dist/components/animated-list.d.ts +26 -0
- package/dist/components/animated-list.js +25 -0
- package/dist/components/animated-number.d.ts +67 -0
- package/dist/components/animated-number.js +131 -0
- package/dist/components/app-shell.d.ts +27 -0
- package/dist/components/app-shell.js +18 -0
- package/dist/components/area-chart.d.ts +11 -0
- package/dist/components/area-chart.js +12 -0
- package/dist/components/aspect-ratio.d.ts +16 -0
- package/dist/components/aspect-ratio.js +14 -0
- package/dist/components/aurora-background.d.ts +3 -0
- package/dist/components/aurora-background.js +8 -0
- package/dist/components/autocomplete.d.ts +55 -0
- package/dist/components/autocomplete.js +279 -0
- package/dist/components/avatar-group.d.ts +39 -0
- package/dist/components/avatar-group.js +50 -0
- package/dist/components/avatar.d.ts +5 -0
- package/dist/components/avatar.js +17 -0
- package/dist/components/badge.d.ts +10 -0
- package/dist/components/badge.js +35 -0
- package/dist/components/banner.d.ts +45 -0
- package/dist/components/banner.js +80 -0
- package/dist/components/bar-chart.d.ts +11 -0
- package/dist/components/bar-chart.js +9 -0
- package/dist/components/border-beam.d.ts +45 -0
- package/dist/components/border-beam.js +48 -0
- package/dist/components/breadcrumb.d.ts +12 -0
- package/dist/components/breadcrumb.js +35 -0
- package/dist/components/button-group.d.ts +7 -0
- package/dist/components/button-group.js +10 -0
- package/dist/components/button.d.ts +12 -0
- package/dist/components/button.js +39 -0
- package/dist/components/calendar.d.ts +7 -0
- package/dist/components/calendar.js +71 -0
- package/dist/components/candlestick-chart.d.ts +13 -0
- package/dist/components/candlestick-chart.js +66 -0
- package/dist/components/card-stack.d.ts +28 -0
- package/dist/components/card-stack.js +47 -0
- package/dist/components/card.d.ts +9 -0
- package/dist/components/card.js +32 -0
- package/dist/components/carousel.d.ts +82 -0
- package/dist/components/carousel.js +310 -0
- package/dist/components/chart.d.ts +100 -0
- package/dist/components/chart.js +210 -0
- package/dist/components/checkbox.d.ts +3 -0
- package/dist/components/checkbox.js +11 -0
- package/dist/components/chip.d.ts +80 -0
- package/dist/components/chip.js +186 -0
- package/dist/components/choropleth-chart.d.ts +12 -0
- package/dist/components/choropleth-chart.js +31 -0
- package/dist/components/click-spark.d.ts +19 -0
- package/dist/components/click-spark.js +51 -0
- package/dist/components/code-block.d.ts +13 -0
- package/dist/components/code-block.js +20 -0
- package/dist/components/code-tabs.d.ts +51 -0
- package/dist/components/code-tabs.js +150 -0
- package/dist/components/collapsible.d.ts +5 -0
- package/dist/components/collapsible.js +12 -0
- package/dist/components/color-picker.d.ts +30 -0
- package/dist/components/color-picker.js +300 -0
- package/dist/components/combobox.d.ts +33 -0
- package/dist/components/combobox.js +32 -0
- package/dist/components/command.d.ts +87 -0
- package/dist/components/command.js +44 -0
- package/dist/components/comparison-slider.d.ts +17 -0
- package/dist/components/comparison-slider.js +81 -0
- package/dist/components/composed-chart.d.ts +13 -0
- package/dist/components/composed-chart.js +22 -0
- package/dist/components/confetti.d.ts +21 -0
- package/dist/components/confetti.js +111 -0
- package/dist/components/confirmation-dialog.d.ts +46 -0
- package/dist/components/confirmation-dialog.js +102 -0
- package/dist/components/context-menu.d.ts +28 -0
- package/dist/components/context-menu.js +52 -0
- package/dist/components/copy-button.d.ts +13 -0
- package/dist/components/copy-button.js +72 -0
- package/dist/components/countdown.d.ts +58 -0
- package/dist/components/countdown.js +106 -0
- package/dist/components/credit-card-input.d.ts +62 -0
- package/dist/components/credit-card-input.js +211 -0
- package/dist/components/currency-input.d.ts +86 -0
- package/dist/components/currency-input.js +215 -0
- package/dist/components/data-table.d.ts +232 -0
- package/dist/components/data-table.js +359 -0
- package/dist/components/date-picker.d.ts +66 -0
- package/dist/components/date-picker.js +55 -0
- package/dist/components/date-range-picker.d.ts +59 -0
- package/dist/components/date-range-picker.js +59 -0
- package/dist/components/description-list.d.ts +84 -0
- package/dist/components/description-list.js +138 -0
- package/dist/components/dialog.d.ts +26 -0
- package/dist/components/dialog.js +35 -0
- package/dist/components/dock.d.ts +34 -0
- package/dist/components/dock.js +61 -0
- package/dist/components/dot-pattern.d.ts +24 -0
- package/dist/components/dot-pattern.js +19 -0
- package/dist/components/drawer.d.ts +22 -0
- package/dist/components/drawer.js +37 -0
- package/dist/components/dropdown-menu.d.ts +32 -0
- package/dist/components/dropdown-menu.js +56 -0
- package/dist/components/dynamic-island.d.ts +26 -0
- package/dist/components/dynamic-island.js +31 -0
- package/dist/components/empty.d.ts +7 -0
- package/dist/components/empty.js +24 -0
- package/dist/components/expandable-tabs.d.ts +24 -0
- package/dist/components/expandable-tabs.js +30 -0
- package/dist/components/fab.d.ts +35 -0
- package/dist/components/fab.js +36 -0
- package/dist/components/field.d.ts +6 -0
- package/dist/components/field.js +22 -0
- package/dist/components/file-dropzone.d.ts +28 -0
- package/dist/components/file-dropzone.js +59 -0
- package/dist/components/flickering-grid.d.ts +25 -0
- package/dist/components/flickering-grid.js +30 -0
- package/dist/components/flip-card.d.ts +70 -0
- package/dist/components/flip-card.js +117 -0
- package/dist/components/floating-label-input.d.ts +34 -0
- package/dist/components/floating-label-input.js +25 -0
- package/dist/components/form.d.ts +25 -0
- package/dist/components/form.js +68 -0
- package/dist/components/frame.d.ts +12 -0
- package/dist/components/frame.js +10 -0
- package/dist/components/funnel-chart.d.ts +11 -0
- package/dist/components/funnel-chart.js +16 -0
- package/dist/components/gauge-chart.d.ts +8 -0
- package/dist/components/gauge-chart.js +10 -0
- package/dist/components/glare-hover.d.ts +15 -0
- package/dist/components/glare-hover.js +64 -0
- package/dist/components/glass-card.d.ts +3 -0
- package/dist/components/glass-card.js +8 -0
- package/dist/components/gradient-border.d.ts +7 -0
- package/dist/components/gradient-border.js +8 -0
- package/dist/components/gradient-text.d.ts +6 -0
- package/dist/components/gradient-text.js +10 -0
- package/dist/components/grid-pattern.d.ts +23 -0
- package/dist/components/grid-pattern.js +18 -0
- package/dist/components/heatmap-chart.d.ts +6 -0
- package/dist/components/heatmap-chart.js +8 -0
- package/dist/components/heatmap.d.ts +28 -0
- package/dist/components/heatmap.js +41 -0
- package/dist/components/highlighter.d.ts +20 -0
- package/dist/components/highlighter.js +19 -0
- package/dist/components/hover-card.d.ts +5 -0
- package/dist/components/hover-card.js +12 -0
- package/dist/components/image-zoom.d.ts +47 -0
- package/dist/components/image-zoom.js +125 -0
- package/dist/components/input-group.d.ts +10 -0
- package/dist/components/input-group.js +12 -0
- package/dist/components/input-otp.d.ts +18 -0
- package/dist/components/input-otp.js +38 -0
- package/dist/components/input.d.ts +6 -0
- package/dist/components/input.js +8 -0
- package/dist/components/json-viewer.d.ts +43 -0
- package/dist/components/json-viewer.js +313 -0
- package/dist/components/kanban.d.ts +31 -0
- package/dist/components/kanban.js +143 -0
- package/dist/components/kbd.d.ts +3 -0
- package/dist/components/kbd.js +8 -0
- package/dist/components/label.d.ts +3 -0
- package/dist/components/label.js +9 -0
- package/dist/components/light-rays.d.ts +19 -0
- package/dist/components/light-rays.js +20 -0
- package/dist/components/lightbox.d.ts +24 -0
- package/dist/components/lightbox.js +68 -0
- package/dist/components/line-chart.d.ts +10 -0
- package/dist/components/line-chart.js +9 -0
- package/dist/components/live-line-chart.d.ts +12 -0
- package/dist/components/live-line-chart.js +42 -0
- package/dist/components/logo-carousel.d.ts +27 -0
- package/dist/components/logo-carousel.js +101 -0
- package/dist/components/magnetic.d.ts +44 -0
- package/dist/components/magnetic.js +172 -0
- package/dist/components/marquee.d.ts +71 -0
- package/dist/components/marquee.js +141 -0
- package/dist/components/masonry.d.ts +16 -0
- package/dist/components/masonry.js +84 -0
- package/dist/components/menubar.d.ts +33 -0
- package/dist/components/menubar.js +56 -0
- package/dist/components/meteors.d.ts +20 -0
- package/dist/components/meteors.js +39 -0
- package/dist/components/metric.d.ts +9 -0
- package/dist/components/metric.js +35 -0
- package/dist/components/mode-toggle.d.ts +32 -0
- package/dist/components/mode-toggle.js +40 -0
- package/dist/components/morphing-popover.d.ts +91 -0
- package/dist/components/morphing-popover.js +194 -0
- package/dist/components/motion-presets.d.ts +9 -0
- package/dist/components/motion-presets.js +20 -0
- package/dist/components/multi-select.d.ts +54 -0
- package/dist/components/multi-select.js +0 -0
- package/dist/components/navigation-menu.d.ts +12 -0
- package/dist/components/navigation-menu.js +42 -0
- package/dist/components/noise.d.ts +19 -0
- package/dist/components/noise.js +18 -0
- package/dist/components/notification-center.d.ts +68 -0
- package/dist/components/notification-center.js +57 -0
- package/dist/components/number-input.d.ts +45 -0
- package/dist/components/number-input.js +148 -0
- package/dist/components/orbit.d.ts +77 -0
- package/dist/components/orbit.js +100 -0
- package/dist/components/pagination.d.ts +16 -0
- package/dist/components/pagination.js +34 -0
- package/dist/components/particles.d.ts +18 -0
- package/dist/components/particles.js +92 -0
- package/dist/components/password-input.d.ts +16 -0
- package/dist/components/password-input.js +49 -0
- package/dist/components/phone-input.d.ts +67 -0
- package/dist/components/phone-input.js +225 -0
- package/dist/components/pie-chart.d.ts +12 -0
- package/dist/components/pie-chart.js +13 -0
- package/dist/components/pill-nav.d.ts +25 -0
- package/dist/components/pill-nav.js +66 -0
- package/dist/components/popover.d.ts +7 -0
- package/dist/components/popover.js +15 -0
- package/dist/components/profit-loss-chart.d.ts +10 -0
- package/dist/components/profit-loss-chart.js +8 -0
- package/dist/components/progress.d.ts +10 -0
- package/dist/components/progress.js +17 -0
- package/dist/components/progressive-blur.d.ts +24 -0
- package/dist/components/progressive-blur.js +43 -0
- package/dist/components/radar-chart.d.ts +9 -0
- package/dist/components/radar-chart.js +9 -0
- package/dist/components/radio-group.d.ts +4 -0
- package/dist/components/radio-group.js +15 -0
- package/dist/components/rating.d.ts +29 -0
- package/dist/components/rating.js +94 -0
- package/dist/components/resizable.d.ts +57 -0
- package/dist/components/resizable.js +73 -0
- package/dist/components/retro-grid.d.ts +25 -0
- package/dist/components/retro-grid.js +26 -0
- package/dist/components/reveal.d.ts +9 -0
- package/dist/components/reveal.js +14 -0
- package/dist/components/rich-text-editor.d.ts +28 -0
- package/dist/components/rich-text-editor.js +83 -0
- package/dist/components/ring-chart.d.ts +13 -0
- package/dist/components/ring-chart.js +16 -0
- package/dist/components/ripple.d.ts +25 -0
- package/dist/components/ripple.js +26 -0
- package/dist/components/sankey-chart.d.ts +16 -0
- package/dist/components/sankey-chart.js +8 -0
- package/dist/components/scatter-chart.d.ts +12 -0
- package/dist/components/scatter-chart.js +9 -0
- package/dist/components/scheduler.d.ts +50 -0
- package/dist/components/scheduler.js +93 -0
- package/dist/components/scramble-text.d.ts +39 -0
- package/dist/components/scramble-text.js +78 -0
- package/dist/components/scroll-area.d.ts +13 -0
- package/dist/components/scroll-area.js +14 -0
- package/dist/components/scroll-progress.d.ts +19 -0
- package/dist/components/scroll-progress.js +67 -0
- package/dist/components/segmented-control.d.ts +48 -0
- package/dist/components/segmented-control.js +222 -0
- package/dist/components/select.d.ts +12 -0
- package/dist/components/select.js +43 -0
- package/dist/components/separator.d.ts +3 -0
- package/dist/components/separator.js +9 -0
- package/dist/components/sheet.d.ts +25 -0
- package/dist/components/sheet.js +47 -0
- package/dist/components/shimmer.d.ts +3 -0
- package/dist/components/shimmer.js +8 -0
- package/dist/components/shiny-text.d.ts +20 -0
- package/dist/components/shiny-text.js +24 -0
- package/dist/components/sidebar.d.ts +92 -0
- package/dist/components/sidebar.js +290 -0
- package/dist/components/signature-pad.d.ts +44 -0
- package/dist/components/signature-pad.js +317 -0
- package/dist/components/skeleton.d.ts +3 -0
- package/dist/components/skeleton.js +8 -0
- package/dist/components/slider.d.ts +10 -0
- package/dist/components/slider.js +27 -0
- package/dist/components/sonner.d.ts +9 -0
- package/dist/components/sonner.js +17 -0
- package/dist/components/sparkles-text.d.ts +19 -0
- package/dist/components/sparkles-text.js +36 -0
- package/dist/components/sparkline.d.ts +22 -0
- package/dist/components/sparkline.js +100 -0
- package/dist/components/spinner.d.ts +10 -0
- package/dist/components/spinner.js +20 -0
- package/dist/components/spinning-text.d.ts +29 -0
- package/dist/components/spinning-text.js +40 -0
- package/dist/components/split-button.d.ts +71 -0
- package/dist/components/split-button.js +30 -0
- package/dist/components/spotlight-card.d.ts +11 -0
- package/dist/components/spotlight-card.js +63 -0
- package/dist/components/star-border.d.ts +19 -0
- package/dist/components/star-border.js +18 -0
- package/dist/components/status-dot.d.ts +60 -0
- package/dist/components/status-dot.js +76 -0
- package/dist/components/stepper.d.ts +98 -0
- package/dist/components/stepper.js +164 -0
- package/dist/components/sunburst-chart.d.ts +11 -0
- package/dist/components/sunburst-chart.js +45 -0
- package/dist/components/switch.d.ts +3 -0
- package/dist/components/switch.js +10 -0
- package/dist/components/table-of-contents.d.ts +64 -0
- package/dist/components/table-of-contents.js +0 -0
- package/dist/components/table.d.ts +10 -0
- package/dist/components/table.js +38 -0
- package/dist/components/tabs.d.ts +6 -0
- package/dist/components/tabs.js +22 -0
- package/dist/components/tags-input.d.ts +39 -0
- package/dist/components/tags-input.js +86 -0
- package/dist/components/terminal.d.ts +86 -0
- package/dist/components/terminal.js +182 -0
- package/dist/components/text-effect.d.ts +71 -0
- package/dist/components/text-effect.js +166 -0
- package/dist/components/textarea.d.ts +6 -0
- package/dist/components/textarea.js +8 -0
- package/dist/components/tilt-card.d.ts +30 -0
- package/dist/components/tilt-card.js +84 -0
- package/dist/components/time-picker.d.ts +58 -0
- package/dist/components/time-picker.js +245 -0
- package/dist/components/timeline.d.ts +81 -0
- package/dist/components/timeline.js +165 -0
- package/dist/components/toggle-group.d.ts +12 -0
- package/dist/components/toggle-group.js +23 -0
- package/dist/components/toggle.d.ts +12 -0
- package/dist/components/toggle.js +25 -0
- package/dist/components/toolbar.d.ts +14 -0
- package/dist/components/toolbar.js +89 -0
- package/dist/components/tooltip.d.ts +29 -0
- package/dist/components/tooltip.js +48 -0
- package/dist/components/tree-view.d.ts +45 -0
- package/dist/components/tree-view.js +197 -0
- package/dist/components/typing-text.d.ts +49 -0
- package/dist/components/typing-text.js +90 -0
- package/dist/components/usage-meter.d.ts +30 -0
- package/dist/components/usage-meter.js +90 -0
- package/dist/components/video-player.d.ts +48 -0
- package/dist/components/video-player.js +216 -0
- package/dist/components/word-rotate.d.ts +40 -0
- package/dist/components/word-rotate.js +34 -0
- package/dist/index.d.ts +306 -0
- package/dist/index.js +179 -0
- package/dist/lib/cn.d.ts +7 -0
- package/dist/lib/cn.js +10 -0
- package/dist/lib/demo-saas.d.ts +171 -0
- package/dist/lib/demo-saas.js +210 -0
- package/dist/lib/demo-store.d.ts +157 -0
- package/dist/lib/demo-store.js +353 -0
- package/dist/testing/index.d.ts +76 -0
- package/dist/testing/index.js +116 -0
- package/package.json +941 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { motion } from "motion/react";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { useChartStable, useYScale } from "./chart-context.js";
|
|
6
|
+
import { StaticSeriesPointMarker } from "./series-point-marker.js";
|
|
7
|
+
function isTerminalMarkerPhaseVisible(phase) {
|
|
8
|
+
return phase === "ready" || phase === "exitingReady";
|
|
9
|
+
}
|
|
10
|
+
/** Hollow ring at the last data point — shared anchor for projection lines. */
|
|
11
|
+
export function LineSeriesTerminalMarker({ dataKey, yAxisId, fill = "transparent", stroke = "var(--chart-1)", radius = 5, ringGap = 0, strokeWidth = 1.5, }) {
|
|
12
|
+
const { data, xScale, xAccessor, chartPhase, revealEpoch, enterTransition } = useChartStable();
|
|
13
|
+
const yScale = useYScale(yAxisId);
|
|
14
|
+
const point = useMemo(() => {
|
|
15
|
+
const lastRow = data.at(-1);
|
|
16
|
+
if (!lastRow) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const value = lastRow[dataKey];
|
|
20
|
+
if (typeof value !== "number") {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
cx: xScale(xAccessor(lastRow)) ?? 0,
|
|
25
|
+
cy: yScale(value) ?? 0,
|
|
26
|
+
};
|
|
27
|
+
}, [data, dataKey, xAccessor, xScale, yScale]);
|
|
28
|
+
const visible = isTerminalMarkerPhaseVisible(chartPhase);
|
|
29
|
+
const fadeTransition = enterTransition && typeof enterTransition === "object"
|
|
30
|
+
? enterTransition
|
|
31
|
+
: { duration: 0.28, ease: [0.22, 1, 0.36, 1] };
|
|
32
|
+
if (!point) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return (_jsx(motion.g, { animate: {
|
|
36
|
+
opacity: visible ? 1 : 0,
|
|
37
|
+
scale: visible ? 1 : 0.55,
|
|
38
|
+
}, initial: { opacity: 0, scale: 0.55 }, style: {
|
|
39
|
+
transformBox: "fill-box",
|
|
40
|
+
transformOrigin: `${point.cx}px ${point.cy}px`,
|
|
41
|
+
}, transition: fadeTransition, children: _jsx(StaticSeriesPointMarker, { cx: point.cx, cy: point.cy, fill: fill, radius: radius, ringGap: ringGap, stroke: stroke, strokeWidth: strokeWidth }) }, revealEpoch ?? 0));
|
|
42
|
+
}
|
|
43
|
+
LineSeriesTerminalMarker.displayName = "LineSeriesTerminalMarker";
|
|
44
|
+
LineSeriesTerminalMarker.__isPostOverlay = true;
|
|
45
|
+
export default LineSeriesTerminalMarker;
|
|
46
|
+
//# sourceMappingURL=line-series-terminal-marker.js.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
type CurveFactory = any;
|
|
2
|
+
import type { LoadingStyle } from "./chart-phase.js";
|
|
3
|
+
import { type FadeEdges } from "./fade-edges.js";
|
|
4
|
+
import { type LineLoadingPulseMode } from "./line-loading-pulse.js";
|
|
5
|
+
import type { SeriesPointMarkerStyle } from "./series-point-marker.js";
|
|
6
|
+
export interface LineProps {
|
|
7
|
+
/** Key in data to use for y values */
|
|
8
|
+
dataKey: string;
|
|
9
|
+
/** Y-scale group id (Recharts `yAxisId`). Default: `"left"`. */
|
|
10
|
+
yAxisId?: string | number;
|
|
11
|
+
/** Stroke color. Default: var(--chart-line-primary) */
|
|
12
|
+
stroke?: string;
|
|
13
|
+
/** Stroke width. Default: 2.5 */
|
|
14
|
+
strokeWidth?: number;
|
|
15
|
+
/** Curve function. Default: curveNatural */
|
|
16
|
+
curve?: CurveFactory;
|
|
17
|
+
/** Whether to animate the line. Default: true */
|
|
18
|
+
animate?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Fade the line stroke toward transparent at the chart edges.
|
|
21
|
+
* - `true` fades both edges, `false` disables the fade entirely.
|
|
22
|
+
* - `"left"` / `"right"` fades only that side.
|
|
23
|
+
* Default: true
|
|
24
|
+
*/
|
|
25
|
+
fadeEdges?: FadeEdges;
|
|
26
|
+
/** Whether to show highlight segment on hover. Default: true */
|
|
27
|
+
showHighlight?: boolean;
|
|
28
|
+
/** Render scatter-style circle markers at each data point. Default: false */
|
|
29
|
+
showMarkers?: boolean;
|
|
30
|
+
/** Marker styling (same options as Scatter). */
|
|
31
|
+
markers?: SeriesPointMarkerStyle;
|
|
32
|
+
/**
|
|
33
|
+
* Data index from which the line stroke becomes dashed (inclusive).
|
|
34
|
+
* Useful for projecting incomplete periods, e.g. dashed from yesterday through today.
|
|
35
|
+
*/
|
|
36
|
+
dashFromIndex?: number;
|
|
37
|
+
/** Dash pattern for the tail segment when `dashFromIndex` is set. Default: "6,4" */
|
|
38
|
+
dashArray?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Show the loading pulse overlay. Default: follows chart loading phase.
|
|
41
|
+
* Set `false` to disable even during loading.
|
|
42
|
+
*/
|
|
43
|
+
loading?: boolean;
|
|
44
|
+
/** Stroke color for the loading pulse overlay. Default: var(--foreground) */
|
|
45
|
+
loadingStroke?: string;
|
|
46
|
+
/** Loading pulse stroke opacity. Default: 0.5 */
|
|
47
|
+
loadingStrokeOpacity?: number;
|
|
48
|
+
/** Override pulse animation mode (loop / exit / enter). */
|
|
49
|
+
loadingPulseMode?: LineLoadingPulseMode;
|
|
50
|
+
/** Called when a loop-mode pulse cycle completes. */
|
|
51
|
+
onLoadingPulseCycleComplete?: () => void;
|
|
52
|
+
/**
|
|
53
|
+
* Loading animation while the chart is in loading status: the default
|
|
54
|
+
* traveling `"pulse"`, or a diagonal `"sweep"` shimmer across the skeleton
|
|
55
|
+
* line. Default: `"pulse"`.
|
|
56
|
+
*/
|
|
57
|
+
loadingStyle?: LoadingStyle;
|
|
58
|
+
}
|
|
59
|
+
export declare function Line({ dataKey, yAxisId, stroke, strokeWidth, curve, animate, fadeEdges, showHighlight, showMarkers, markers, dashFromIndex, dashArray, loading, loadingStroke, loadingStrokeOpacity, loadingPulseMode, onLoadingPulseCycleComplete, loadingStyle, }: LineProps): import("react").JSX.Element;
|
|
60
|
+
export declare namespace Line {
|
|
61
|
+
var displayName: string;
|
|
62
|
+
}
|
|
63
|
+
export default Line;
|
|
64
|
+
//# sourceMappingURL=line.d.ts.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { curveNatural } from "@visx/curve";
|
|
4
|
+
import { LinePath } from "@visx/shape";
|
|
5
|
+
import { useCallback, useId, useMemo, useRef, useState } from "react";
|
|
6
|
+
import { chartCssVars, useChartStable, useYScale } from "./chart-context.js";
|
|
7
|
+
import { fadeGradientStops, resolveFadeSides, viewportFadeGradientAttrs, } from "./fade-edges.js";
|
|
8
|
+
import { LineLoadingPulseStroke, resolveLineLoadingPulseMode, } from "./line-loading-pulse.js";
|
|
9
|
+
import { LINE_LOADING_LOOP_PAUSE_MS } from "./line-loading-timing.js";
|
|
10
|
+
import { LineLoadingSweep } from "./loading-sweep.js";
|
|
11
|
+
import { resolveDashTailBounds, usePathStrokeMetrics } from "./path-stroke-utils.js";
|
|
12
|
+
import { SeriesDashTailOverlay } from "./series-dash-tail-overlay.js";
|
|
13
|
+
import { SeriesHighlightLayer } from "./series-highlight-layer.js";
|
|
14
|
+
import { SeriesHoverDim } from "./series-hover-dim.js";
|
|
15
|
+
import { SeriesMarkers } from "./series-markers.js";
|
|
16
|
+
import { useAnimatedSeriesPath } from "./use-animated-series-path.js";
|
|
17
|
+
function LineSeriesStroke({ animatedPathD, curve, getY, pathRef, renderData, strokeWidth, useDataTransitionPath, visibleStroke, xAccessor, xScale, }) {
|
|
18
|
+
if (useDataTransitionPath && animatedPathD) {
|
|
19
|
+
return (_jsx("path", { d: animatedPathD, fill: "none", ref: pathRef, stroke: visibleStroke, strokeLinecap: "round", strokeWidth: strokeWidth }));
|
|
20
|
+
}
|
|
21
|
+
return (_jsx(LinePath, { curve: curve, data: renderData, innerRef: pathRef, stroke: visibleStroke, strokeLinecap: "round", strokeWidth: strokeWidth, x: (d) => xScale(xAccessor(d)) ?? 0, y: getY }));
|
|
22
|
+
}
|
|
23
|
+
function LineLoadingOverlays({ curve, handleLoadingPulseComplete, innerWidth, loadingStroke, loadingStrokeOpacity, loadingStyle, pathD, pulseEpoch, pulseMode, showLoadingPulse, strokeWidth, }) {
|
|
24
|
+
const sweepLoading = showLoadingPulse && innerWidth > 0 && loadingStyle === "sweep";
|
|
25
|
+
const pulseLoading = showLoadingPulse && innerWidth > 0 && !sweepLoading;
|
|
26
|
+
return (_jsxs(_Fragment, { children: [sweepLoading ? (_jsx(LineLoadingSweep, { curve: curve, mode: pulseMode ?? "loop", onTransitionComplete: handleLoadingPulseComplete, stroke: loadingStroke, strokeOpacity: loadingStrokeOpacity, strokeWidth: strokeWidth }, "loading-sweep")) : null, pulseLoading && pathD ? (_jsx(LineLoadingPulseStroke, { loopEpoch: pulseEpoch, mode: pulseMode ?? undefined, onCycleComplete: handleLoadingPulseComplete, pathD: pathD, stroke: loadingStroke, strokeOpacity: loadingStrokeOpacity, strokeWidth: strokeWidth }, "loading-pulse")) : null] }));
|
|
27
|
+
}
|
|
28
|
+
export function Line({ dataKey, yAxisId, stroke = chartCssVars.linePrimary, strokeWidth = 2.5, curve = curveNatural, animate = true, fadeEdges = true, showHighlight = true, showMarkers = false, markers, dashFromIndex, dashArray = "6,4", loading, loadingStroke = chartCssVars.foreground, loadingStrokeOpacity = 0.5, loadingPulseMode, onLoadingPulseCycleComplete, loadingStyle = "pulse", }) {
|
|
29
|
+
// Stable slice only: hover state lives inside `<SeriesHoverDim>` and
|
|
30
|
+
// `<SeriesHighlightLayer>` so this component (and its expensive
|
|
31
|
+
// <SeriesDashTailOverlay> child) does not re-render on cursor motion.
|
|
32
|
+
// The reveal-clip is now a single shared clipPath at the chart-shell
|
|
33
|
+
// level (`time-series-chart-shell.tsx`); we no longer render a per-line
|
|
34
|
+
// `<ChartRevealClip>` or read `revealEpoch` here.
|
|
35
|
+
const { data, renderData, xScale, innerHeight, innerWidth, xAccessor, lines, chartPhase, notifyLoadingPulseComplete, yDomainTweenDuration, } = useChartStable();
|
|
36
|
+
const yScale = useYScale(yAxisId);
|
|
37
|
+
const useDataTransitionPath = animate && chartPhase === "ready";
|
|
38
|
+
const { pathD: animatedPathD } = useAnimatedSeriesPath({
|
|
39
|
+
chartPhase,
|
|
40
|
+
curve,
|
|
41
|
+
dataKey,
|
|
42
|
+
durationMs: yDomainTweenDuration,
|
|
43
|
+
enabled: useDataTransitionPath,
|
|
44
|
+
innerWidth,
|
|
45
|
+
renderData,
|
|
46
|
+
xAccessor,
|
|
47
|
+
xScale,
|
|
48
|
+
yScale,
|
|
49
|
+
});
|
|
50
|
+
const phasePulseMode = resolveLineLoadingPulseMode(chartPhase);
|
|
51
|
+
const pulseMode = loading === false ? null : (loadingPulseMode ?? (loading === true ? "loop" : phasePulseMode));
|
|
52
|
+
const showLoadingPulse = pulseMode != null;
|
|
53
|
+
const [pulseEpoch, setPulseEpoch] = useState(0);
|
|
54
|
+
const effectiveShowHighlight = showHighlight && !showLoadingPulse;
|
|
55
|
+
const handleLoadingPulseComplete = useCallback(() => {
|
|
56
|
+
onLoadingPulseCycleComplete?.();
|
|
57
|
+
if (pulseMode === "loop") {
|
|
58
|
+
window.setTimeout(() => {
|
|
59
|
+
setPulseEpoch((epoch) => epoch + 1);
|
|
60
|
+
}, LINE_LOADING_LOOP_PAUSE_MS);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
notifyLoadingPulseComplete?.();
|
|
64
|
+
}, [notifyLoadingPulseComplete, onLoadingPulseCycleComplete, pulseMode]);
|
|
65
|
+
const seriesIndex = useMemo(() => {
|
|
66
|
+
const index = lines.findIndex((line) => line.dataKey === dataKey);
|
|
67
|
+
return index >= 0 ? index : 0;
|
|
68
|
+
}, [lines, dataKey]);
|
|
69
|
+
const pathRef = useRef(null);
|
|
70
|
+
const { pathLength, pathD } = usePathStrokeMetrics(pathRef, [
|
|
71
|
+
renderData,
|
|
72
|
+
innerWidth,
|
|
73
|
+
dashFromIndex,
|
|
74
|
+
animate,
|
|
75
|
+
useDataTransitionPath ? animatedPathD : null,
|
|
76
|
+
]);
|
|
77
|
+
const reactId = useId();
|
|
78
|
+
const gradientId = `line-gradient-${dataKey}-${reactId}`;
|
|
79
|
+
const getY = useCallback((d) => {
|
|
80
|
+
const value = d[dataKey];
|
|
81
|
+
return typeof value === "number" ? (yScale(value) ?? 0) : 0;
|
|
82
|
+
}, [dataKey, yScale]);
|
|
83
|
+
const hasDashTail = resolveDashTailBounds(dashFromIndex, data.length);
|
|
84
|
+
const fadeSides = resolveFadeSides(fadeEdges);
|
|
85
|
+
const lineStroke = fadeSides.any ? `url(#${gradientId})` : stroke;
|
|
86
|
+
const fadeStops = fadeSides.any ? fadeGradientStops(fadeSides) : null;
|
|
87
|
+
const showSeriesStroke = chartPhase === "revealing" || chartPhase === "ready" || chartPhase === "exitingReady";
|
|
88
|
+
let visibleStroke = "transparent";
|
|
89
|
+
if (showSeriesStroke && !hasDashTail) {
|
|
90
|
+
visibleStroke = lineStroke;
|
|
91
|
+
}
|
|
92
|
+
return (_jsxs(_Fragment, { children: [fadeStops ? (_jsx("defs", { children: _jsx("linearGradient", { id: gradientId, ...viewportFadeGradientAttrs(innerWidth), children: fadeStops.map((stop) => (_jsx("stop", { offset: stop.offset, style: { stopColor: stroke, stopOpacity: stop.opacity } }, stop.offset))) }) })) : null, _jsxs(SeriesHoverDim, { dimOpacity: 0.3, enabled: effectiveShowHighlight, seriesIndex: seriesIndex, children: [_jsx(LineSeriesStroke, { animatedPathD: animatedPathD, curve: curve, getY: getY, pathRef: pathRef, renderData: renderData, strokeWidth: strokeWidth, useDataTransitionPath: useDataTransitionPath, visibleStroke: visibleStroke, xAccessor: xAccessor, xScale: xScale }), _jsx(SeriesDashTailOverlay, { dashArray: dashArray, dashFromIndex: dashFromIndex, data: data, innerHeight: innerHeight, innerWidth: innerWidth, pathD: pathD, pathLength: pathLength, stroke: lineStroke, strokeWidth: strokeWidth, xAccessor: xAccessor, xScale: xScale })] }), showMarkers ? (_jsx(SeriesMarkers, { animate: animate, dataKey: dataKey, ...markers, fill: markers?.fill ?? stroke, stroke: markers?.stroke ?? markers?.fill ?? stroke })) : null, _jsx(SeriesHighlightLayer, { enabled: effectiveShowHighlight, height: innerHeight, pathRef: pathRef, stroke: stroke, strokeWidth: strokeWidth }), _jsx(LineLoadingOverlays, { curve: curve, handleLoadingPulseComplete: handleLoadingPulseComplete, innerWidth: innerWidth, loadingStroke: loadingStroke, loadingStrokeOpacity: loadingStrokeOpacity, loadingStyle: loadingStyle, pathD: pathD, pulseEpoch: pulseEpoch, pulseMode: pulseMode, showLoadingPulse: showLoadingPulse, strokeWidth: strokeWidth })] }));
|
|
93
|
+
}
|
|
94
|
+
Line.displayName = "Line";
|
|
95
|
+
export default Line;
|
|
96
|
+
//# sourceMappingURL=line.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type Margin } from "./chart-context.js";
|
|
3
|
+
export interface LiveLinePoint {
|
|
4
|
+
time: number;
|
|
5
|
+
value: number;
|
|
6
|
+
}
|
|
7
|
+
export interface LiveLineChartProps {
|
|
8
|
+
/** Streaming data — array of { time: unixSeconds, value } */
|
|
9
|
+
data: LiveLinePoint[];
|
|
10
|
+
/** Latest value (smoothly interpolated to) */
|
|
11
|
+
value: number;
|
|
12
|
+
/** Key used for the value field in context data. Default: "value" */
|
|
13
|
+
dataKey?: string;
|
|
14
|
+
/** Visible time window in seconds. Default: 30 */
|
|
15
|
+
window?: number;
|
|
16
|
+
/** Number of X-axis ticks (used to compute leading offset). Default: 5 */
|
|
17
|
+
numXTicks?: number;
|
|
18
|
+
/** Leading offset in X-tick units (0 = now at right edge). Default: 0 */
|
|
19
|
+
nowOffsetUnits?: number;
|
|
20
|
+
/** Tight Y-axis. Default: false */
|
|
21
|
+
exaggerate?: boolean;
|
|
22
|
+
/** Interpolation speed (0–1). Default: 0.08 */
|
|
23
|
+
lerpSpeed?: number;
|
|
24
|
+
/** Chart margins */
|
|
25
|
+
margin?: Partial<Margin>;
|
|
26
|
+
/** Freeze chart scrolling. Default: false */
|
|
27
|
+
paused?: boolean;
|
|
28
|
+
/** Child components (LiveLine, Grid, ChartTooltip, LiveXAxis, LiveYAxis, etc.) */
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
className?: string;
|
|
31
|
+
style?: React.CSSProperties;
|
|
32
|
+
}
|
|
33
|
+
export declare function LiveLineChart({ data, value, dataKey, window: windowSecs, numXTicks, nowOffsetUnits, exaggerate, lerpSpeed, margin: marginProp, paused, children, className, style, }: LiveLineChartProps): import("react").JSX.Element;
|
|
34
|
+
export default LiveLineChart;
|
|
35
|
+
//# sourceMappingURL=live-line-chart.d.ts.map
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { localPoint } from "@visx/event";
|
|
4
|
+
import { ParentSize } from "@visx/responsive";
|
|
5
|
+
import { scaleLinear, scaleTime } from "@visx/scale";
|
|
6
|
+
import { bisector } from "d3-array";
|
|
7
|
+
import { Children, isValidElement, memo, startTransition, useCallback, useEffect, useMemo, useRef, useState, } from "react";
|
|
8
|
+
import { cn } from "../lib/cn.js";
|
|
9
|
+
import { isClipExcludedComponent, isUnderlayComponent } from "./chart-child-passthrough.js";
|
|
10
|
+
import { ChartProvider } from "./chart-context.js";
|
|
11
|
+
import { hmsTimeFmt } from "./chart-formatters.js";
|
|
12
|
+
import { DEFAULT_CHART_LIFECYCLE } from "./chart-phase.js";
|
|
13
|
+
import { extractReferenceAreaConfigs } from "./reference-area-config.js";
|
|
14
|
+
import { wrapSingleYScale } from "./y-axis-scales.js";
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// Helpers
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
const LERP_SPEED = 0.08;
|
|
19
|
+
const DEFAULT_MARGIN = { top: 16, right: 80, bottom: 40, left: 56 };
|
|
20
|
+
/** React commit interval for the live animation loop (~30fps). */
|
|
21
|
+
const LIVE_FRAME_COMMIT_MS = 32;
|
|
22
|
+
function computeTargetRange(data, value, exaggerate) {
|
|
23
|
+
if (data.length === 0) {
|
|
24
|
+
return { yMin: 0, yMax: 100 };
|
|
25
|
+
}
|
|
26
|
+
let min = Number.POSITIVE_INFINITY;
|
|
27
|
+
let max = Number.NEGATIVE_INFINITY;
|
|
28
|
+
for (const d of data) {
|
|
29
|
+
if (d.value < min) {
|
|
30
|
+
min = d.value;
|
|
31
|
+
}
|
|
32
|
+
if (d.value > max) {
|
|
33
|
+
max = d.value;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (value < min) {
|
|
37
|
+
min = value;
|
|
38
|
+
}
|
|
39
|
+
if (value > max) {
|
|
40
|
+
max = value;
|
|
41
|
+
}
|
|
42
|
+
const rawRange = max - min;
|
|
43
|
+
const paddingFactor = exaggerate ? 0.03 : 0.15;
|
|
44
|
+
const rangePad = rawRange * paddingFactor || (exaggerate ? 0.04 : 10);
|
|
45
|
+
return { yMin: min - rangePad, yMax: max + rangePad };
|
|
46
|
+
}
|
|
47
|
+
function nextAnimFrame(prev, targetRange, targetValue, speed, isPaused) {
|
|
48
|
+
const nextNow = isPaused ? prev.now : Date.now();
|
|
49
|
+
const nextYMin = targetRange.yMin < prev.yMin
|
|
50
|
+
? targetRange.yMin
|
|
51
|
+
: prev.yMin + (targetRange.yMin - prev.yMin) * speed;
|
|
52
|
+
const nextYMax = targetRange.yMax > prev.yMax
|
|
53
|
+
? targetRange.yMax
|
|
54
|
+
: prev.yMax + (targetRange.yMax - prev.yMax) * speed;
|
|
55
|
+
const nextValue = prev.displayValue + (targetValue - prev.displayValue) * speed;
|
|
56
|
+
return {
|
|
57
|
+
now: nextNow,
|
|
58
|
+
yMin: nextYMin,
|
|
59
|
+
yMax: nextYMax,
|
|
60
|
+
displayValue: nextValue,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function interpolateAtTime(points, timeSec) {
|
|
64
|
+
if (points.length === 0) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
const firstPt = points[0];
|
|
68
|
+
const lastPt = points.at(-1);
|
|
69
|
+
if (timeSec <= firstPt.time) {
|
|
70
|
+
return firstPt.value;
|
|
71
|
+
}
|
|
72
|
+
if (timeSec >= lastPt.time) {
|
|
73
|
+
return lastPt.value;
|
|
74
|
+
}
|
|
75
|
+
let lo = 0;
|
|
76
|
+
let hi = points.length - 1;
|
|
77
|
+
while (hi - lo > 1) {
|
|
78
|
+
const mid = Math.floor((lo + hi) / 2);
|
|
79
|
+
const midPt = points[mid];
|
|
80
|
+
if (midPt && midPt.time <= timeSec) {
|
|
81
|
+
lo = mid;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
hi = mid;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const p1 = points[lo];
|
|
88
|
+
if (!p1) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const p2 = points[hi];
|
|
92
|
+
if (!p2) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const dt = p2.time - p1.time;
|
|
96
|
+
if (dt === 0) {
|
|
97
|
+
return p1.value;
|
|
98
|
+
}
|
|
99
|
+
const t = (timeSec - p1.time) / dt;
|
|
100
|
+
return p1.value + (p2.value - p1.value) * t;
|
|
101
|
+
}
|
|
102
|
+
const bisectTime = bisector((d) => d.time).left;
|
|
103
|
+
function extractLiveLineConfigs(children) {
|
|
104
|
+
const configs = [];
|
|
105
|
+
Children.forEach(children, (child) => {
|
|
106
|
+
if (!isValidElement(child)) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const childType = child.type;
|
|
110
|
+
const name = typeof child.type === "function" ? childType.displayName || childType.name || "" : "";
|
|
111
|
+
const props = child.props;
|
|
112
|
+
if ((name === "LiveLine" || (props && "dataKey" in props)) && props?.dataKey) {
|
|
113
|
+
configs.push({
|
|
114
|
+
dataKey: props.dataKey,
|
|
115
|
+
stroke: props.stroke || "var(--chart-line-primary)",
|
|
116
|
+
strokeWidth: props.strokeWidth || 2,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
return configs;
|
|
121
|
+
}
|
|
122
|
+
// ---------------------------------------------------------------------------
|
|
123
|
+
// Inner chart
|
|
124
|
+
// ---------------------------------------------------------------------------
|
|
125
|
+
function liveTooltipKey(tooltip, dataKey) {
|
|
126
|
+
if (!tooltip) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
return `${Math.round(tooltip.x)}:${Math.round(tooltip.yPositions[dataKey] ?? 0)}`;
|
|
130
|
+
}
|
|
131
|
+
function resolveLiveTooltip(cursorX, innerWidth, innerHeight, frame, leadingMs, windowMs, xTickUnitMs, data, dataKey) {
|
|
132
|
+
if (cursorX === null || innerWidth <= 0 || innerHeight <= 0) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
const domainEndMs = frame.now + leadingMs;
|
|
136
|
+
const xScaleNext = scaleTime({
|
|
137
|
+
domain: [new Date(domainEndMs - windowMs), new Date(domainEndMs)],
|
|
138
|
+
range: [0, innerWidth],
|
|
139
|
+
});
|
|
140
|
+
const yScaleNext = scaleLinear({
|
|
141
|
+
domain: [frame.yMin, frame.yMax],
|
|
142
|
+
range: [innerHeight, 0],
|
|
143
|
+
nice: true,
|
|
144
|
+
});
|
|
145
|
+
const timeMs = xScaleNext.invert(cursorX).getTime();
|
|
146
|
+
const timeSec = timeMs / 1000;
|
|
147
|
+
const visible = data.filter((p) => p.time >= (domainEndMs - windowMs) / 1000);
|
|
148
|
+
visible.push({ time: frame.now / 1000, value: frame.displayValue });
|
|
149
|
+
visible.push({
|
|
150
|
+
time: (frame.now + xTickUnitMs) / 1000,
|
|
151
|
+
value: frame.displayValue,
|
|
152
|
+
});
|
|
153
|
+
const val = interpolateAtTime(visible, timeSec);
|
|
154
|
+
if (val === null) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
point: { date: new Date(timeMs), [dataKey]: val },
|
|
159
|
+
index: 0,
|
|
160
|
+
x: cursorX,
|
|
161
|
+
yPositions: { [dataKey]: yScaleNext(val) ?? 0 },
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function shouldCommitLiveUpdates(now, lastFrameCommit, tooltipKey, lastTooltipKey) {
|
|
165
|
+
const commitFrame = now - lastFrameCommit >= LIVE_FRAME_COMMIT_MS;
|
|
166
|
+
const commitTooltip = tooltipKey !== lastTooltipKey;
|
|
167
|
+
return { commitFrame, commitTooltip };
|
|
168
|
+
}
|
|
169
|
+
function LiveLineChartInner(props) {
|
|
170
|
+
const { width, height, margin } = props;
|
|
171
|
+
const innerWidth = width - margin.left - margin.right;
|
|
172
|
+
const innerHeight = height - margin.top - margin.bottom;
|
|
173
|
+
if (innerWidth <= 0 || innerHeight <= 0) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
return _jsx(LiveLineChartCore, { ...props });
|
|
177
|
+
}
|
|
178
|
+
const LiveLineChartCore = memo(function LiveLineChartCore({ data, value, dataKey, windowSecs, numXTicks, nowOffsetUnits, exaggerate, lerpSpeed, margin, paused, width, height, containerRef, children, }) {
|
|
179
|
+
const windowMs = windowSecs * 1000;
|
|
180
|
+
const innerWidth = width - margin.left - margin.right;
|
|
181
|
+
const innerHeight = height - margin.top - margin.bottom;
|
|
182
|
+
// ---- Animation state ----
|
|
183
|
+
const animRef = useRef({
|
|
184
|
+
now: Date.now(),
|
|
185
|
+
yMin: 0,
|
|
186
|
+
yMax: 100,
|
|
187
|
+
displayValue: value,
|
|
188
|
+
});
|
|
189
|
+
const [frame, setFrame] = useState({
|
|
190
|
+
now: Date.now(),
|
|
191
|
+
yMin: 0,
|
|
192
|
+
yMax: 100,
|
|
193
|
+
displayValue: value,
|
|
194
|
+
});
|
|
195
|
+
const pausedRef = useRef(paused);
|
|
196
|
+
const dataRef = useRef(data);
|
|
197
|
+
const dataKeyRef = useRef(dataKey);
|
|
198
|
+
dataRef.current = data;
|
|
199
|
+
dataKeyRef.current = dataKey;
|
|
200
|
+
useEffect(() => {
|
|
201
|
+
pausedRef.current = paused;
|
|
202
|
+
}, [paused]);
|
|
203
|
+
const targetRange = useMemo(() => computeTargetRange(data, value, exaggerate), [data, value, exaggerate]);
|
|
204
|
+
const lines = useMemo(() => extractLiveLineConfigs(children), [children]);
|
|
205
|
+
// Leading offset (used in rAF for tooltip)
|
|
206
|
+
const xTickUnitMs = windowMs / (numXTicks - 1);
|
|
207
|
+
const leadingMs = nowOffsetUnits * xTickUnitMs;
|
|
208
|
+
// ---- rAF loop: update frame and tooltip in one place to avoid effect→setState loops ----
|
|
209
|
+
const cursorXRef = useRef(null);
|
|
210
|
+
const [tooltipData, setTooltipData] = useState(null);
|
|
211
|
+
const lastFrameCommitRef = useRef(0);
|
|
212
|
+
const lastTooltipKeyRef = useRef(null);
|
|
213
|
+
useEffect(() => {
|
|
214
|
+
let raf;
|
|
215
|
+
const tick = () => {
|
|
216
|
+
const next = nextAnimFrame(animRef.current, targetRange, value, lerpSpeed, pausedRef.current);
|
|
217
|
+
animRef.current = next;
|
|
218
|
+
const nextTooltip = resolveLiveTooltip(cursorXRef.current, innerWidth, innerHeight, next, leadingMs, windowMs, xTickUnitMs, dataRef.current, dataKeyRef.current);
|
|
219
|
+
const now = performance.now();
|
|
220
|
+
const tooltipKey = liveTooltipKey(nextTooltip, dataKeyRef.current);
|
|
221
|
+
const { commitFrame, commitTooltip } = shouldCommitLiveUpdates(now, lastFrameCommitRef.current, tooltipKey, lastTooltipKeyRef.current);
|
|
222
|
+
if (!(commitFrame || commitTooltip)) {
|
|
223
|
+
raf = requestAnimationFrame(tick);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
if (commitFrame) {
|
|
227
|
+
lastFrameCommitRef.current = now;
|
|
228
|
+
}
|
|
229
|
+
if (commitTooltip) {
|
|
230
|
+
lastTooltipKeyRef.current = tooltipKey;
|
|
231
|
+
}
|
|
232
|
+
startTransition(() => {
|
|
233
|
+
if (commitFrame) {
|
|
234
|
+
setFrame(next);
|
|
235
|
+
}
|
|
236
|
+
if (commitTooltip) {
|
|
237
|
+
setTooltipData(nextTooltip);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
raf = requestAnimationFrame(tick);
|
|
241
|
+
};
|
|
242
|
+
raf = requestAnimationFrame(tick);
|
|
243
|
+
return () => cancelAnimationFrame(raf);
|
|
244
|
+
}, [targetRange, value, lerpSpeed, leadingMs, windowMs, xTickUnitMs, innerWidth, innerHeight]);
|
|
245
|
+
const domainEndMs = frame.now + leadingMs;
|
|
246
|
+
// ---- Scales ----
|
|
247
|
+
const xScale = useMemo(() => scaleTime({
|
|
248
|
+
domain: [new Date(domainEndMs - windowMs), new Date(domainEndMs)],
|
|
249
|
+
range: [0, innerWidth],
|
|
250
|
+
}), [domainEndMs, windowMs, innerWidth]);
|
|
251
|
+
const yScale = useMemo(() => scaleLinear({
|
|
252
|
+
domain: [frame.yMin, frame.yMax],
|
|
253
|
+
range: [innerHeight, 0],
|
|
254
|
+
nice: true,
|
|
255
|
+
}), [frame.yMin, frame.yMax, innerHeight]);
|
|
256
|
+
// ---- Build context-compatible data ----
|
|
257
|
+
// Convert LiveLinePoint[] to Record<string, unknown>[] with 2 virtual points:
|
|
258
|
+
// 1. At "now" — the live tip where the dot sits
|
|
259
|
+
// 2. At "now + 1 unit" — a queued point that the line fades into
|
|
260
|
+
const contextData = useMemo(() => {
|
|
261
|
+
const windowStart = domainEndMs - windowMs;
|
|
262
|
+
let startIdx = bisectTime(data, windowStart / 1000, 0);
|
|
263
|
+
if (startIdx > 0) {
|
|
264
|
+
startIdx--;
|
|
265
|
+
}
|
|
266
|
+
const sliced = data.slice(startIdx);
|
|
267
|
+
const records = sliced.map((p) => ({
|
|
268
|
+
date: new Date(p.time * 1000),
|
|
269
|
+
[dataKey]: p.value,
|
|
270
|
+
}));
|
|
271
|
+
// Virtual point 1: the "now" position (where the live dot sits)
|
|
272
|
+
records.push({
|
|
273
|
+
date: new Date(frame.now),
|
|
274
|
+
[dataKey]: frame.displayValue,
|
|
275
|
+
});
|
|
276
|
+
// Virtual point 2: queued ahead (the line extends and fades into this)
|
|
277
|
+
records.push({
|
|
278
|
+
date: new Date(frame.now + xTickUnitMs),
|
|
279
|
+
[dataKey]: frame.displayValue,
|
|
280
|
+
});
|
|
281
|
+
return records;
|
|
282
|
+
}, [data, frame.now, frame.displayValue, domainEndMs, windowMs, dataKey, xTickUnitMs]);
|
|
283
|
+
// ---- X accessor ----
|
|
284
|
+
const xAccessor = useCallback((d) => d.date instanceof Date ? d.date : new Date(d.date), []);
|
|
285
|
+
const handleMouseMove = useCallback((event) => {
|
|
286
|
+
const coords = localPoint(event);
|
|
287
|
+
if (!coords) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const x = coords.x - margin.left;
|
|
291
|
+
cursorXRef.current = x >= 0 && x <= innerWidth ? x : null;
|
|
292
|
+
}, [margin.left, innerWidth]);
|
|
293
|
+
const handleMouseLeave = useCallback(() => {
|
|
294
|
+
cursorXRef.current = null;
|
|
295
|
+
lastTooltipKeyRef.current = null;
|
|
296
|
+
setTooltipData(null);
|
|
297
|
+
}, []);
|
|
298
|
+
// Date labels (for ChartTooltip's DateTicker — not used in live but needed for context)
|
|
299
|
+
const dateLabels = useMemo(() => contextData.map((d) => hmsTimeFmt.format(xAccessor(d))), [contextData, xAccessor]);
|
|
300
|
+
const columnWidth = useMemo(() => {
|
|
301
|
+
if (contextData.length < 2) {
|
|
302
|
+
return 0;
|
|
303
|
+
}
|
|
304
|
+
return innerWidth / (contextData.length - 1);
|
|
305
|
+
}, [innerWidth, contextData.length]);
|
|
306
|
+
const clipExcludedChildren = [];
|
|
307
|
+
const underlayChildren = [];
|
|
308
|
+
const seriesChildren = [];
|
|
309
|
+
Children.forEach(children, (child) => {
|
|
310
|
+
if (!isValidElement(child)) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
if (isClipExcludedComponent(child)) {
|
|
314
|
+
clipExcludedChildren.push(child);
|
|
315
|
+
}
|
|
316
|
+
else if (isUnderlayComponent(child)) {
|
|
317
|
+
underlayChildren.push(child);
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
seriesChildren.push(child);
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
const referenceAreas = useMemo(() => extractReferenceAreaConfigs(children), [children]);
|
|
324
|
+
const contextValue = useMemo(() => ({
|
|
325
|
+
...DEFAULT_CHART_LIFECYCLE,
|
|
326
|
+
data: contextData,
|
|
327
|
+
renderData: contextData,
|
|
328
|
+
xScale,
|
|
329
|
+
yScale,
|
|
330
|
+
yScales: wrapSingleYScale(yScale),
|
|
331
|
+
width,
|
|
332
|
+
height,
|
|
333
|
+
innerWidth,
|
|
334
|
+
innerHeight,
|
|
335
|
+
margin,
|
|
336
|
+
columnWidth,
|
|
337
|
+
tooltipData,
|
|
338
|
+
setTooltipData,
|
|
339
|
+
containerRef,
|
|
340
|
+
lines,
|
|
341
|
+
referenceAreas,
|
|
342
|
+
isLoaded: true,
|
|
343
|
+
animationDuration: 0,
|
|
344
|
+
xAccessor,
|
|
345
|
+
dateLabels,
|
|
346
|
+
}), [
|
|
347
|
+
contextData,
|
|
348
|
+
xScale,
|
|
349
|
+
yScale,
|
|
350
|
+
width,
|
|
351
|
+
height,
|
|
352
|
+
innerWidth,
|
|
353
|
+
innerHeight,
|
|
354
|
+
margin,
|
|
355
|
+
columnWidth,
|
|
356
|
+
tooltipData,
|
|
357
|
+
containerRef,
|
|
358
|
+
lines,
|
|
359
|
+
referenceAreas,
|
|
360
|
+
xAccessor,
|
|
361
|
+
dateLabels,
|
|
362
|
+
]);
|
|
363
|
+
return (_jsx(ChartProvider, { value: contextValue, children: _jsx("svg", { "aria-hidden": "true", className: "overflow-visible", height: height, width: width, children: _jsxs("g", { onMouseLeave: handleMouseLeave, onMouseMove: handleMouseMove, style: { cursor: "crosshair" }, transform: `translate(${margin.left},${margin.top})`, children: [_jsx("rect", { fill: "transparent", height: innerHeight, width: innerWidth, x: 0, y: 0 }), clipExcludedChildren, underlayChildren, seriesChildren] }) }) }));
|
|
364
|
+
});
|
|
365
|
+
// ---------------------------------------------------------------------------
|
|
366
|
+
// Public component
|
|
367
|
+
// ---------------------------------------------------------------------------
|
|
368
|
+
export function LiveLineChart({ data, value, dataKey = "value", window: windowSecs = 30, numXTicks = 5, nowOffsetUnits = 0, exaggerate = false, lerpSpeed = LERP_SPEED, margin: marginProp, paused = false, children, className, style, }) {
|
|
369
|
+
const containerRef = useRef(null);
|
|
370
|
+
const margin = { ...DEFAULT_MARGIN, ...marginProp };
|
|
371
|
+
return (_jsx("div", { "data-slot": "live-line-chart", className: cn("relative w-full", className), ref: containerRef, style: { height: 300, touchAction: "none", ...style }, children: _jsx(ParentSize, { debounceTime: 10, children: ({ width, height }) => (_jsx(LiveLineChartInner, { containerRef: containerRef, data: data, dataKey: dataKey, exaggerate: exaggerate, height: height, lerpSpeed: lerpSpeed, margin: margin, nowOffsetUnits: nowOffsetUnits, numXTicks: numXTicks, paused: paused, value: value, width: width, windowSecs: windowSecs, children: children })) }) }));
|
|
372
|
+
}
|
|
373
|
+
export default LiveLineChart;
|
|
374
|
+
//# sourceMappingURL=live-line-chart.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
type CurveFactory = any;
|
|
2
|
+
export type Momentum = "up" | "down" | "flat";
|
|
3
|
+
export interface MomentumColors {
|
|
4
|
+
up: string;
|
|
5
|
+
down: string;
|
|
6
|
+
flat: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function detectMomentum(data: Record<string, unknown>[], dataKey: string, lookback?: number): Momentum;
|
|
9
|
+
export interface LiveLineProps {
|
|
10
|
+
/** Key in data to use for y values */
|
|
11
|
+
dataKey: string;
|
|
12
|
+
/** Stroke color. Default: var(--chart-line-primary) */
|
|
13
|
+
stroke?: string;
|
|
14
|
+
/** Stroke width. Default: 2 */
|
|
15
|
+
strokeWidth?: number;
|
|
16
|
+
/** Curve function. Default: curveMonotoneX */
|
|
17
|
+
curve?: CurveFactory;
|
|
18
|
+
/** Show gradient fill under the curve. Default: true */
|
|
19
|
+
fill?: boolean;
|
|
20
|
+
/** Show pulsing live dot at the right edge. Default: true */
|
|
21
|
+
pulse?: boolean;
|
|
22
|
+
/** Radius of the live dot. Default: 4 */
|
|
23
|
+
dotSize?: number;
|
|
24
|
+
/** Show value badge pill at the live tip. Default: true */
|
|
25
|
+
badge?: boolean;
|
|
26
|
+
/** Value label formatter for the badge */
|
|
27
|
+
formatValue?: (v: number) => string;
|
|
28
|
+
/**
|
|
29
|
+
* When set, the line/fill color changes based on momentum direction.
|
|
30
|
+
* Overrides `stroke` for the line and fill (dot always uses momentum colors).
|
|
31
|
+
*/
|
|
32
|
+
momentumColors?: MomentumColors;
|
|
33
|
+
}
|
|
34
|
+
export declare function LiveLine({ dataKey, stroke, strokeWidth, curve, fill, pulse, dotSize, badge, formatValue, momentumColors, }: LiveLineProps): import("react").JSX.Element;
|
|
35
|
+
export declare namespace LiveLine {
|
|
36
|
+
var displayName: string;
|
|
37
|
+
}
|
|
38
|
+
export default LiveLine;
|
|
39
|
+
//# sourceMappingURL=live-line.d.ts.map
|