@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,415 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { memo, useEffect, useMemo, useState } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { useChart, useChartStable } from "./chart-context.js";
|
|
7
|
+
import { shortDateFmt } from "./chart-formatters.js";
|
|
8
|
+
import { DEFAULT_Y_DOMAIN_TWEEN_MS } from "./chart-phase.js";
|
|
9
|
+
import { LINE_LOADING_PULSE_EASE } from "./line-loading-timing.js";
|
|
10
|
+
const X_AXIS_POSITION_TWEEN_MS = DEFAULT_Y_DOMAIN_TWEEN_MS;
|
|
11
|
+
function XAxisLabel({ label, x, crosshairX, hoveredLabel, isHovering, tickerHalfWidth, animatePosition, }) {
|
|
12
|
+
const fadeBuffer = 20;
|
|
13
|
+
const fadeRadius = tickerHalfWidth + fadeBuffer;
|
|
14
|
+
let opacity = 1;
|
|
15
|
+
if (isHovering && crosshairX !== null) {
|
|
16
|
+
const distance = Math.abs(x - crosshairX);
|
|
17
|
+
if (distance < tickerHalfWidth) {
|
|
18
|
+
opacity = 0;
|
|
19
|
+
}
|
|
20
|
+
else if (hoveredLabel && label === hoveredLabel) {
|
|
21
|
+
opacity = 0;
|
|
22
|
+
}
|
|
23
|
+
else if (distance < fadeRadius) {
|
|
24
|
+
opacity = (distance - tickerHalfWidth) / fadeBuffer;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return (_jsx("div", { className: "absolute", style: {
|
|
28
|
+
left: x,
|
|
29
|
+
bottom: 12,
|
|
30
|
+
width: 0,
|
|
31
|
+
display: "flex",
|
|
32
|
+
justifyContent: "center",
|
|
33
|
+
transition: animatePosition
|
|
34
|
+
? `left ${X_AXIS_POSITION_TWEEN_MS}ms cubic-bezier(${LINE_LOADING_PULSE_EASE.join(", ")})`
|
|
35
|
+
: undefined,
|
|
36
|
+
}, children: _jsx("span", { className: cn("whitespace-nowrap text-chart-label text-xs"), style: {
|
|
37
|
+
opacity,
|
|
38
|
+
transition: "opacity 0.4s ease-in-out",
|
|
39
|
+
}, children: label }) }));
|
|
40
|
+
}
|
|
41
|
+
const MAX_GAP_LAYOUTS = 400;
|
|
42
|
+
function binomial(n, k) {
|
|
43
|
+
if (k < 0 || k > n) {
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
let result = 1;
|
|
47
|
+
for (let i = 0; i < k; i++) {
|
|
48
|
+
result = (result * (n - i)) / (i + 1);
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
/** All ways to split `span` into `parts` positive integer gaps. */
|
|
53
|
+
function composePositiveSum(sum, parts) {
|
|
54
|
+
if (parts === 1) {
|
|
55
|
+
return sum >= 1 ? [[sum]] : [];
|
|
56
|
+
}
|
|
57
|
+
const layouts = [];
|
|
58
|
+
for (let gap = 1; gap <= sum - (parts - 1); gap++) {
|
|
59
|
+
for (const tail of composePositiveSum(sum - gap, parts - 1)) {
|
|
60
|
+
layouts.push([gap, ...tail]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return layouts;
|
|
64
|
+
}
|
|
65
|
+
function gapsToIndices(gaps) {
|
|
66
|
+
const indices = [0];
|
|
67
|
+
let position = 0;
|
|
68
|
+
for (const gap of gaps) {
|
|
69
|
+
position += gap;
|
|
70
|
+
indices.push(position);
|
|
71
|
+
}
|
|
72
|
+
return indices;
|
|
73
|
+
}
|
|
74
|
+
function indicesForTickCount(length, tickCount) {
|
|
75
|
+
const span = length - 1;
|
|
76
|
+
if (span <= 0) {
|
|
77
|
+
return [0];
|
|
78
|
+
}
|
|
79
|
+
const rawIndices = Array.from({ length: tickCount }, (_, index) => Math.round((index / (tickCount - 1)) * span));
|
|
80
|
+
const indices = [...new Set(rawIndices)].sort((a, b) => a - b);
|
|
81
|
+
if (indices[0] !== 0) {
|
|
82
|
+
indices.unshift(0);
|
|
83
|
+
}
|
|
84
|
+
if (indices.at(-1) !== span) {
|
|
85
|
+
indices.push(span);
|
|
86
|
+
}
|
|
87
|
+
return [...new Set(indices)].sort((a, b) => a - b);
|
|
88
|
+
}
|
|
89
|
+
function allIndexLayouts(length, tickCount) {
|
|
90
|
+
const span = length - 1;
|
|
91
|
+
if (span <= 0) {
|
|
92
|
+
return [[0]];
|
|
93
|
+
}
|
|
94
|
+
const gapCount = tickCount - 1;
|
|
95
|
+
if (gapCount <= 0) {
|
|
96
|
+
return [[0]];
|
|
97
|
+
}
|
|
98
|
+
const layoutCount = binomial(span - 1, gapCount - 1);
|
|
99
|
+
if (layoutCount > MAX_GAP_LAYOUTS) {
|
|
100
|
+
return [indicesForTickCount(length, tickCount)];
|
|
101
|
+
}
|
|
102
|
+
return composePositiveSum(span, gapCount).map(gapsToIndices);
|
|
103
|
+
}
|
|
104
|
+
function dedupeIndicesByLabel(indices, data, dateLabels, xAccessor) {
|
|
105
|
+
const seenLabels = new Set();
|
|
106
|
+
const deduped = [];
|
|
107
|
+
for (const index of indices) {
|
|
108
|
+
const point = data[index];
|
|
109
|
+
if (!point) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const label = dateLabels[index] ?? shortDateFmt.format(xAccessor(point));
|
|
113
|
+
if (seenLabels.has(label)) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
seenLabels.add(label);
|
|
117
|
+
deduped.push(index);
|
|
118
|
+
}
|
|
119
|
+
return deduped;
|
|
120
|
+
}
|
|
121
|
+
function indexGaps(indices) {
|
|
122
|
+
const gaps = [];
|
|
123
|
+
for (let i = 1; i < indices.length; i++) {
|
|
124
|
+
const current = indices[i];
|
|
125
|
+
const previous = indices[i - 1];
|
|
126
|
+
if (current == null || previous == null) {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
gaps.push(current - previous);
|
|
130
|
+
}
|
|
131
|
+
return gaps;
|
|
132
|
+
}
|
|
133
|
+
function smallestGapEdgePreference(indices) {
|
|
134
|
+
const gaps = indexGaps(indices);
|
|
135
|
+
const smallestGap = Math.min(...gaps);
|
|
136
|
+
const smallestGapIndex = gaps.indexOf(smallestGap);
|
|
137
|
+
if (smallestGapIndex === gaps.length - 1) {
|
|
138
|
+
return 0;
|
|
139
|
+
}
|
|
140
|
+
if (smallestGapIndex === 0) {
|
|
141
|
+
return 1;
|
|
142
|
+
}
|
|
143
|
+
return 2;
|
|
144
|
+
}
|
|
145
|
+
function scoreTickLayout(indices, resolveXPx, targetCount) {
|
|
146
|
+
if (indices.length < 2) {
|
|
147
|
+
return {
|
|
148
|
+
score: Number.POSITIVE_INFINITY,
|
|
149
|
+
symmetryPenalty: Number.POSITIVE_INFINITY,
|
|
150
|
+
countDistance: Number.POSITIVE_INFINITY,
|
|
151
|
+
edgePreference: Number.POSITIVE_INFINITY,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
const pixelGaps = [];
|
|
155
|
+
for (let i = 1; i < indices.length; i++) {
|
|
156
|
+
const current = indices[i];
|
|
157
|
+
const previous = indices[i - 1];
|
|
158
|
+
if (current == null || previous == null) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
pixelGaps.push(resolveXPx(current) - resolveXPx(previous));
|
|
162
|
+
}
|
|
163
|
+
const minGap = Math.min(...pixelGaps);
|
|
164
|
+
const maxGap = Math.max(...pixelGaps);
|
|
165
|
+
const meanGap = pixelGaps.reduce((sum, gap) => sum + gap, 0) / pixelGaps.length;
|
|
166
|
+
const spreadRatio = meanGap > 0 ? (maxGap - minGap) / meanGap : maxGap - minGap;
|
|
167
|
+
const countDistance = Math.abs(indices.length - targetCount);
|
|
168
|
+
const gaps = indexGaps(indices);
|
|
169
|
+
const smallestGap = Math.min(...gaps);
|
|
170
|
+
const smallestGapIndex = gaps.indexOf(smallestGap);
|
|
171
|
+
const interiorPenalty = smallestGapIndex > 0 && smallestGapIndex < gaps.length - 1 ? 0.08 : 0;
|
|
172
|
+
const symmetryPenalty = gaps.reduce((penalty, gap, index) => {
|
|
173
|
+
return penalty + Math.abs(gap - (gaps.at(-1 - index) ?? gap));
|
|
174
|
+
}, 0) / gaps.length;
|
|
175
|
+
return {
|
|
176
|
+
score: spreadRatio + 0.1 * countDistance + interiorPenalty + symmetryPenalty * 0.02,
|
|
177
|
+
symmetryPenalty,
|
|
178
|
+
countDistance,
|
|
179
|
+
edgePreference: smallestGapEdgePreference(indices),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function isBetterTickLayout(next, best, nextCountDistance, bestCountDistance) {
|
|
183
|
+
if (next.score < best.score - 1e-6) {
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
if (Math.abs(next.score - best.score) > 1e-6) {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
if (nextCountDistance < bestCountDistance) {
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
if (nextCountDistance > bestCountDistance) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
if (next.symmetryPenalty < best.symmetryPenalty - 1e-6) {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
if (next.symmetryPenalty > best.symmetryPenalty + 1e-6) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
return next.edgePreference < best.edgePreference;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Picks tick indices with the most even on-screen spacing. Tries
|
|
205
|
+
* `targetCount ± 1` and evaluates every gap layout when feasible.
|
|
206
|
+
*/
|
|
207
|
+
export function selectEvenlySpacedIndices(length, targetCount, options) {
|
|
208
|
+
if (length <= 0) {
|
|
209
|
+
return [];
|
|
210
|
+
}
|
|
211
|
+
if (length === 1) {
|
|
212
|
+
return [0];
|
|
213
|
+
}
|
|
214
|
+
if (length <= targetCount) {
|
|
215
|
+
return Array.from({ length }, (_, index) => index);
|
|
216
|
+
}
|
|
217
|
+
const resolveXPx = options?.resolveXPx ?? ((index) => index);
|
|
218
|
+
const minCount = Math.max(2, targetCount - 1);
|
|
219
|
+
const maxCount = Math.min(length, targetCount + 1);
|
|
220
|
+
let bestIndices = indicesForTickCount(length, targetCount);
|
|
221
|
+
let bestScore = scoreTickLayout(bestIndices, resolveXPx, targetCount);
|
|
222
|
+
let bestCountDistance = bestScore.countDistance;
|
|
223
|
+
for (let tickCount = minCount; tickCount <= maxCount; tickCount++) {
|
|
224
|
+
for (const rawIndices of allIndexLayouts(length, tickCount)) {
|
|
225
|
+
const indices = options?.data && options.dateLabels && options.xAccessor
|
|
226
|
+
? dedupeIndicesByLabel(rawIndices, options.data, options.dateLabels, options.xAccessor)
|
|
227
|
+
: rawIndices;
|
|
228
|
+
if (indices.length < 2) {
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
const layoutScore = scoreTickLayout(indices, resolveXPx, targetCount);
|
|
232
|
+
const countDistance = Math.abs(indices.length - targetCount);
|
|
233
|
+
if (isBetterTickLayout(layoutScore, bestScore, countDistance, bestCountDistance)) {
|
|
234
|
+
bestIndices = indices;
|
|
235
|
+
bestScore = layoutScore;
|
|
236
|
+
bestCountDistance = countDistance;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return bestIndices;
|
|
241
|
+
}
|
|
242
|
+
function buildDataAlignedTicks({ data, dateLabels, marginLeft, targetTickCount, xAccessor, xScale, }) {
|
|
243
|
+
const seenLabels = new Set();
|
|
244
|
+
const ticks = [];
|
|
245
|
+
const resolveXPx = (index) => {
|
|
246
|
+
const point = data[index];
|
|
247
|
+
if (!point) {
|
|
248
|
+
return index;
|
|
249
|
+
}
|
|
250
|
+
return xScale(xAccessor(point)) ?? 0;
|
|
251
|
+
};
|
|
252
|
+
for (const index of selectEvenlySpacedIndices(data.length, targetTickCount, {
|
|
253
|
+
data,
|
|
254
|
+
dateLabels,
|
|
255
|
+
resolveXPx,
|
|
256
|
+
xAccessor,
|
|
257
|
+
})) {
|
|
258
|
+
const point = data[index];
|
|
259
|
+
if (!point) {
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
const date = xAccessor(point);
|
|
263
|
+
const label = dateLabels[index] ?? shortDateFmt.format(date);
|
|
264
|
+
if (seenLabels.has(label)) {
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
seenLabels.add(label);
|
|
268
|
+
ticks.push({
|
|
269
|
+
date,
|
|
270
|
+
label,
|
|
271
|
+
x: (xScale(date) ?? 0) + marginLeft,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
return ticks;
|
|
275
|
+
}
|
|
276
|
+
function buildDomainTicks({ marginLeft, numTicks, xScale, }) {
|
|
277
|
+
const domain = xScale.domain();
|
|
278
|
+
const startDate = domain[0];
|
|
279
|
+
const endDate = domain[1];
|
|
280
|
+
if (!(startDate && endDate)) {
|
|
281
|
+
return [];
|
|
282
|
+
}
|
|
283
|
+
const startTime = startDate.getTime();
|
|
284
|
+
const endTime = endDate.getTime();
|
|
285
|
+
const timeRange = endTime - startTime;
|
|
286
|
+
const tickCount = Math.max(2, numTicks);
|
|
287
|
+
const seenLabels = new Set();
|
|
288
|
+
const ticks = [];
|
|
289
|
+
for (let i = 0; i < tickCount; i++) {
|
|
290
|
+
const t = i / (tickCount - 1);
|
|
291
|
+
const date = new Date(startTime + t * timeRange);
|
|
292
|
+
const label = shortDateFmt.format(date);
|
|
293
|
+
if (seenLabels.has(label)) {
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
seenLabels.add(label);
|
|
297
|
+
ticks.push({
|
|
298
|
+
date,
|
|
299
|
+
label,
|
|
300
|
+
x: (xScale(date) ?? 0) + marginLeft,
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
return ticks;
|
|
304
|
+
}
|
|
305
|
+
function domainExtendsPastData(data, xAccessor, xScale) {
|
|
306
|
+
if (data.length === 0) {
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
const domainEnd = xScale.domain()[1];
|
|
310
|
+
const lastPoint = data.at(-1);
|
|
311
|
+
if (!(domainEnd && lastPoint)) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
return domainEnd.getTime() > xAccessor(lastPoint).getTime();
|
|
315
|
+
}
|
|
316
|
+
/** Domain ticks for the projection tail when brush keeps data-aligned labels. */
|
|
317
|
+
function appendProjectionTailTicks(ticks, data, xAccessor, xScale, marginLeft, maxExtraTicks) {
|
|
318
|
+
if (data.length === 0 || maxExtraTicks <= 0) {
|
|
319
|
+
return ticks;
|
|
320
|
+
}
|
|
321
|
+
const lastPoint = data.at(-1);
|
|
322
|
+
const domainEnd = xScale.domain()[1];
|
|
323
|
+
if (!(lastPoint && domainEnd)) {
|
|
324
|
+
return ticks;
|
|
325
|
+
}
|
|
326
|
+
const lastDate = xAccessor(lastPoint);
|
|
327
|
+
const startTime = lastDate.getTime();
|
|
328
|
+
const endTime = domainEnd.getTime();
|
|
329
|
+
if (endTime <= startTime) {
|
|
330
|
+
return ticks;
|
|
331
|
+
}
|
|
332
|
+
const seenLabels = new Set(ticks.map((tick) => tick.label));
|
|
333
|
+
const extras = [];
|
|
334
|
+
const extraCount = Math.min(maxExtraTicks, 3);
|
|
335
|
+
for (let i = 1; i <= extraCount; i++) {
|
|
336
|
+
const date = new Date(startTime + (i / (extraCount + 1)) * (endTime - startTime));
|
|
337
|
+
const label = shortDateFmt.format(date);
|
|
338
|
+
if (seenLabels.has(label)) {
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
seenLabels.add(label);
|
|
342
|
+
extras.push({
|
|
343
|
+
date,
|
|
344
|
+
label,
|
|
345
|
+
x: (xScale(date) ?? 0) + marginLeft,
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
const endLabel = shortDateFmt.format(domainEnd);
|
|
349
|
+
if (!seenLabels.has(endLabel)) {
|
|
350
|
+
extras.push({
|
|
351
|
+
date: domainEnd,
|
|
352
|
+
label: endLabel,
|
|
353
|
+
x: (xScale(domainEnd) ?? 0) + marginLeft,
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
if (extras.length === 0) {
|
|
357
|
+
return ticks;
|
|
358
|
+
}
|
|
359
|
+
return [...ticks, ...extras].sort((a, b) => a.x - b.x);
|
|
360
|
+
}
|
|
361
|
+
export function XAxis(props) {
|
|
362
|
+
const { containerRef } = useChartStable();
|
|
363
|
+
const [mounted, setMounted] = useState(false);
|
|
364
|
+
useEffect(() => {
|
|
365
|
+
setMounted(true);
|
|
366
|
+
}, []);
|
|
367
|
+
const container = containerRef.current;
|
|
368
|
+
if (!(mounted && container)) {
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
return _jsx(XAxisInner, { ...props, container: container });
|
|
372
|
+
}
|
|
373
|
+
const XAxisInner = memo(function XAxisInner({ numTicks = 5, tickerHalfWidth = 50, tickMode = "data", container, }) {
|
|
374
|
+
const { xScale, margin, tooltipData, data, xAccessor, dateLabels, xDomain } = useChart();
|
|
375
|
+
const labelsToShow = useMemo(() => {
|
|
376
|
+
const projectionExtendsScale = tickMode === "data" && domainExtendsPastData(data, xAccessor, xScale);
|
|
377
|
+
if (tickMode === "domain") {
|
|
378
|
+
return buildDomainTicks({
|
|
379
|
+
marginLeft: margin.left,
|
|
380
|
+
numTicks,
|
|
381
|
+
xScale,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
// No brush: evenly spaced ticks across the full domain (data + projection).
|
|
385
|
+
if (projectionExtendsScale && xDomain == null) {
|
|
386
|
+
return buildDomainTicks({
|
|
387
|
+
marginLeft: margin.left,
|
|
388
|
+
numTicks,
|
|
389
|
+
xScale,
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
const dataTicks = buildDataAlignedTicks({
|
|
393
|
+
data,
|
|
394
|
+
dateLabels,
|
|
395
|
+
marginLeft: margin.left,
|
|
396
|
+
targetTickCount: numTicks,
|
|
397
|
+
xAccessor,
|
|
398
|
+
xScale,
|
|
399
|
+
});
|
|
400
|
+
// Brush: keep data-aligned ticks, add labels only in the projection tail.
|
|
401
|
+
if (projectionExtendsScale && xDomain != null) {
|
|
402
|
+
return appendProjectionTailTicks(dataTicks, data, xAccessor, xScale, margin.left, Math.max(1, numTicks - dataTicks.length + 1));
|
|
403
|
+
}
|
|
404
|
+
return dataTicks;
|
|
405
|
+
}, [tickMode, xDomain, data, dateLabels, xAccessor, xScale, margin.left, numTicks]);
|
|
406
|
+
const isHovering = tooltipData !== null;
|
|
407
|
+
const crosshairX = tooltipData ? tooltipData.x + margin.left : null;
|
|
408
|
+
const hoveredLabel = isHovering && tooltipData
|
|
409
|
+
? (dateLabels[tooltipData.index] ?? shortDateFmt.format(xAccessor(tooltipData.point)))
|
|
410
|
+
: null;
|
|
411
|
+
return createPortal(_jsx("div", { className: "pointer-events-none absolute inset-0", children: labelsToShow.map((item) => (_jsx(XAxisLabel, { animatePosition: xDomain == null, crosshairX: crosshairX, hoveredLabel: hoveredLabel, isHovering: isHovering, label: item.label, tickerHalfWidth: tickerHalfWidth, x: item.x }, `${item.date.getTime()}-${item.x}`))) }), container);
|
|
412
|
+
});
|
|
413
|
+
XAxis.displayName = "XAxis";
|
|
414
|
+
export default XAxis;
|
|
415
|
+
//# sourceMappingURL=x-axis.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { scaleLinear } from "@visx/scale";
|
|
2
|
+
import type { LineConfig } from "./chart-context.js";
|
|
3
|
+
/** Default axis id when `yAxisId` is omitted (Recharts-style `0` / primary left axis). */
|
|
4
|
+
export declare const DEFAULT_Y_AXIS_ID = "left";
|
|
5
|
+
export type YAxisOrientation = "left" | "right";
|
|
6
|
+
export declare function normalizeYAxisId(id?: string | number): string;
|
|
7
|
+
export declare function groupLinesByYAxisId(lines: LineConfig[]): Map<string, LineConfig[]>;
|
|
8
|
+
type YScale = ReturnType<typeof scaleLinear<number>>;
|
|
9
|
+
export declare function getPrimaryYScale(yScales: Record<string, YScale>, fallback: YScale): YScale;
|
|
10
|
+
export declare function buildYScalesForLines({ lines, innerHeight, resolveDomain, }: {
|
|
11
|
+
lines: LineConfig[];
|
|
12
|
+
/** Passed by callers; domain is resolved via `resolveDomain`. */
|
|
13
|
+
data?: Record<string, unknown>[];
|
|
14
|
+
innerHeight: number;
|
|
15
|
+
resolveDomain: (dataKeys: string[]) => [number, number];
|
|
16
|
+
}): Record<string, YScale>;
|
|
17
|
+
/** Build y-scales from pre-computed (already nice'd) domain endpoints. */
|
|
18
|
+
export declare function buildYScalesFromDomains({ lines, innerHeight, domainsByAxis, }: {
|
|
19
|
+
lines: LineConfig[];
|
|
20
|
+
innerHeight: number;
|
|
21
|
+
domainsByAxis: Record<string, [number, number]>;
|
|
22
|
+
}): Record<string, YScale>;
|
|
23
|
+
/** Single-axis charts (bar, scatter, candlestick, live line). */
|
|
24
|
+
export declare function wrapSingleYScale(yScale: YScale): Record<string, YScale>;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=y-axis-scales.d.ts.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { scaleLinear } from "@visx/scale";
|
|
2
|
+
/** Default axis id when `yAxisId` is omitted (Recharts-style `0` / primary left axis). */
|
|
3
|
+
export const DEFAULT_Y_AXIS_ID = "left";
|
|
4
|
+
export function normalizeYAxisId(id) {
|
|
5
|
+
if (id == null || id === "") {
|
|
6
|
+
return DEFAULT_Y_AXIS_ID;
|
|
7
|
+
}
|
|
8
|
+
return String(id);
|
|
9
|
+
}
|
|
10
|
+
export function groupLinesByYAxisId(lines) {
|
|
11
|
+
const groups = new Map();
|
|
12
|
+
for (const line of lines) {
|
|
13
|
+
const axisId = normalizeYAxisId(line.yAxisId);
|
|
14
|
+
const bucket = groups.get(axisId) ?? [];
|
|
15
|
+
bucket.push(line);
|
|
16
|
+
groups.set(axisId, bucket);
|
|
17
|
+
}
|
|
18
|
+
return groups;
|
|
19
|
+
}
|
|
20
|
+
export function getPrimaryYScale(yScales, fallback) {
|
|
21
|
+
const primary = yScales[DEFAULT_Y_AXIS_ID];
|
|
22
|
+
if (primary) {
|
|
23
|
+
return primary;
|
|
24
|
+
}
|
|
25
|
+
const first = Object.values(yScales)[0];
|
|
26
|
+
return first ?? fallback;
|
|
27
|
+
}
|
|
28
|
+
export function buildYScalesForLines({ lines, innerHeight, resolveDomain, }) {
|
|
29
|
+
const groups = groupLinesByYAxisId(lines);
|
|
30
|
+
const scales = {};
|
|
31
|
+
for (const [axisId, axisLines] of groups) {
|
|
32
|
+
const dataKeys = axisLines.map((line) => line.dataKey);
|
|
33
|
+
const domain = resolveDomain(dataKeys);
|
|
34
|
+
scales[axisId] = scaleLinear({
|
|
35
|
+
range: [innerHeight, 0],
|
|
36
|
+
domain,
|
|
37
|
+
nice: true,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (!scales[DEFAULT_Y_AXIS_ID]) {
|
|
41
|
+
scales[DEFAULT_Y_AXIS_ID] = scaleLinear({
|
|
42
|
+
range: [innerHeight, 0],
|
|
43
|
+
domain: [0, 100],
|
|
44
|
+
nice: true,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return scales;
|
|
48
|
+
}
|
|
49
|
+
/** Build y-scales from pre-computed (already nice'd) domain endpoints. */
|
|
50
|
+
export function buildYScalesFromDomains({ lines, innerHeight, domainsByAxis, }) {
|
|
51
|
+
const groups = groupLinesByYAxisId(lines);
|
|
52
|
+
const scales = {};
|
|
53
|
+
for (const [axisId] of groups) {
|
|
54
|
+
const domain = domainsByAxis[axisId] ?? domainsByAxis[DEFAULT_Y_AXIS_ID] ?? [0, 100];
|
|
55
|
+
scales[axisId] = scaleLinear({
|
|
56
|
+
range: [innerHeight, 0],
|
|
57
|
+
domain,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (!scales[DEFAULT_Y_AXIS_ID]) {
|
|
61
|
+
scales[DEFAULT_Y_AXIS_ID] = scaleLinear({
|
|
62
|
+
range: [innerHeight, 0],
|
|
63
|
+
domain: domainsByAxis[DEFAULT_Y_AXIS_ID] ?? [0, 100],
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return scales;
|
|
67
|
+
}
|
|
68
|
+
/** Single-axis charts (bar, scatter, candlestick, live line). */
|
|
69
|
+
export function wrapSingleYScale(yScale) {
|
|
70
|
+
return { [DEFAULT_Y_AXIS_ID]: yScale };
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=y-axis-scales.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Default hint passed to `scale.ticks()` (d3 — approximate tick count). */
|
|
2
|
+
export declare const Y_AXIS_DEFAULT_TICK_COUNT = 5;
|
|
3
|
+
/** Minimum valid `numTicks` for `scale.ticks()` — values ≤ 0 yield no ticks. */
|
|
4
|
+
export declare const Y_AXIS_MIN_TICK_COUNT = 1;
|
|
5
|
+
/**
|
|
6
|
+
* Upper bound for the tick count hint. D3 may return more "nice" ticks above ~10;
|
|
7
|
+
* keeping the hint in a modest range avoids overcrowded axes.
|
|
8
|
+
*/
|
|
9
|
+
export declare const Y_AXIS_MAX_TICK_COUNT = 10;
|
|
10
|
+
/** Clamps a user `numTicks` value to a valid d3 tick-count hint. */
|
|
11
|
+
export declare function resolveYAxisTickCount(numTicks?: number): number;
|
|
12
|
+
//# sourceMappingURL=y-axis-ticks.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Default hint passed to `scale.ticks()` (d3 — approximate tick count). */
|
|
2
|
+
export const Y_AXIS_DEFAULT_TICK_COUNT = 5;
|
|
3
|
+
/** Minimum valid `numTicks` for `scale.ticks()` — values ≤ 0 yield no ticks. */
|
|
4
|
+
export const Y_AXIS_MIN_TICK_COUNT = 1;
|
|
5
|
+
/**
|
|
6
|
+
* Upper bound for the tick count hint. D3 may return more "nice" ticks above ~10;
|
|
7
|
+
* keeping the hint in a modest range avoids overcrowded axes.
|
|
8
|
+
*/
|
|
9
|
+
export const Y_AXIS_MAX_TICK_COUNT = 10;
|
|
10
|
+
/** Clamps a user `numTicks` value to a valid d3 tick-count hint. */
|
|
11
|
+
export function resolveYAxisTickCount(numTicks) {
|
|
12
|
+
if (numTicks == null || !Number.isFinite(numTicks)) {
|
|
13
|
+
return Y_AXIS_DEFAULT_TICK_COUNT;
|
|
14
|
+
}
|
|
15
|
+
const rounded = Math.round(numTicks);
|
|
16
|
+
if (rounded < Y_AXIS_MIN_TICK_COUNT) {
|
|
17
|
+
return Y_AXIS_MIN_TICK_COUNT;
|
|
18
|
+
}
|
|
19
|
+
if (rounded > Y_AXIS_MAX_TICK_COUNT) {
|
|
20
|
+
return Y_AXIS_MAX_TICK_COUNT;
|
|
21
|
+
}
|
|
22
|
+
return rounded;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=y-axis-ticks.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { YAxisOrientation } from "./y-axis-scales.js";
|
|
2
|
+
export interface YAxisProps {
|
|
3
|
+
/** Scale group id (Recharts `yAxisId`). Default: `"left"`. */
|
|
4
|
+
yAxisId?: string | number;
|
|
5
|
+
/** Which side of the chart to render labels. Default: `"left"`. */
|
|
6
|
+
orientation?: YAxisOrientation;
|
|
7
|
+
/**
|
|
8
|
+
* Approximate tick count hint for `scale.ticks()` (d3). Actual label count may differ.
|
|
9
|
+
* Clamped to {@link Y_AXIS_MIN_TICK_COUNT}–{@link Y_AXIS_MAX_TICK_COUNT}. Default: 5.
|
|
10
|
+
*/
|
|
11
|
+
numTicks?: number;
|
|
12
|
+
/** Format large numbers (e.g. 1000 as "1k"). Default: true */
|
|
13
|
+
formatLargeNumbers?: boolean;
|
|
14
|
+
/** Custom formatter for tick labels (e.g. USD). Overrides formatLargeNumbers when set. */
|
|
15
|
+
formatValue?: (value: number) => string;
|
|
16
|
+
}
|
|
17
|
+
export declare function YAxis(props: YAxisProps): import("react").JSX.Element | null;
|
|
18
|
+
export declare namespace YAxis {
|
|
19
|
+
var displayName: string;
|
|
20
|
+
}
|
|
21
|
+
export default YAxis;
|
|
22
|
+
//# sourceMappingURL=y-axis.d.ts.map
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { memo, useEffect, useMemo, useState } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { useChartStable, useYScale } from "./chart-context.js";
|
|
6
|
+
import { DEFAULT_Y_DOMAIN_TWEEN_MS } from "./chart-phase.js";
|
|
7
|
+
import { LINE_LOADING_PULSE_EASE } from "./line-loading-timing.js";
|
|
8
|
+
import { resolveReferenceDataRange } from "./reference-area-geometry.js";
|
|
9
|
+
import { normalizeYAxisId } from "./y-axis-scales.js";
|
|
10
|
+
import { resolveYAxisTickCount, Y_AXIS_DEFAULT_TICK_COUNT } from "./y-axis-ticks.js";
|
|
11
|
+
const Y_AXIS_POSITION_TWEEN_MS = DEFAULT_Y_DOMAIN_TWEEN_MS;
|
|
12
|
+
function formatLabel(value, formatLargeNumbers, formatValue) {
|
|
13
|
+
if (formatValue) {
|
|
14
|
+
return formatValue(value);
|
|
15
|
+
}
|
|
16
|
+
if (formatLargeNumbers && value >= 1000) {
|
|
17
|
+
return `${(value / 1000).toFixed(0)}k`;
|
|
18
|
+
}
|
|
19
|
+
return String(value);
|
|
20
|
+
}
|
|
21
|
+
function resolveTickLabelColor(tickY, axisId, yScale, referenceAreas) {
|
|
22
|
+
for (const area of referenceAreas) {
|
|
23
|
+
if (!area.axisLabelColor) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (normalizeYAxisId(area.yAxisId) !== axisId) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const [low, high] = resolveReferenceDataRange(area.y1, area.y2, yScale.domain());
|
|
30
|
+
const topPixel = yScale(high) ?? 0;
|
|
31
|
+
const bottomPixel = yScale(low) ?? 0;
|
|
32
|
+
const bandTop = Math.min(topPixel, bottomPixel);
|
|
33
|
+
const bandBottom = Math.max(topPixel, bottomPixel);
|
|
34
|
+
if (tickY >= bandTop && tickY <= bandBottom) {
|
|
35
|
+
return area.axisLabelColor;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
export function YAxis(props) {
|
|
41
|
+
const { containerRef } = useChartStable();
|
|
42
|
+
const [mounted, setMounted] = useState(false);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
setMounted(true);
|
|
45
|
+
}, []);
|
|
46
|
+
const container = containerRef.current;
|
|
47
|
+
if (!(mounted && container)) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return _jsx(YAxisInner, { ...props, container: container });
|
|
51
|
+
}
|
|
52
|
+
const YAxisInner = memo(function YAxisInner({ yAxisId, orientation = "left", numTicks = Y_AXIS_DEFAULT_TICK_COUNT, formatLargeNumbers = true, formatValue, container, }) {
|
|
53
|
+
const { margin, referenceAreas } = useChartStable();
|
|
54
|
+
const yScale = useYScale(yAxisId);
|
|
55
|
+
const isLeft = orientation === "left";
|
|
56
|
+
const axisId = normalizeYAxisId(yAxisId);
|
|
57
|
+
const ticks = useMemo(() => {
|
|
58
|
+
const tickValues = yScale.ticks(resolveYAxisTickCount(numTicks));
|
|
59
|
+
return tickValues.map((value) => {
|
|
60
|
+
const y = (yScale(value) ?? 0) + margin.top;
|
|
61
|
+
return {
|
|
62
|
+
value,
|
|
63
|
+
y,
|
|
64
|
+
label: formatLabel(value, formatLargeNumbers, formatValue),
|
|
65
|
+
labelColor: resolveTickLabelColor(y - margin.top, axisId, yScale, referenceAreas),
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
}, [yScale, margin.top, numTicks, formatLargeNumbers, formatValue, axisId, referenceAreas]);
|
|
69
|
+
return createPortal(_jsx("div", { className: "pointer-events-none absolute inset-0", children: _jsx("div", { className: "absolute top-0 bottom-0", style: isLeft ? { left: 0, width: margin.left } : { right: 0, width: margin.right }, children: ticks.map((tick) => (_jsx("div", { className: "absolute flex items-center", style: {
|
|
70
|
+
top: tick.y,
|
|
71
|
+
transform: "translateY(-50%)",
|
|
72
|
+
transition: `top ${Y_AXIS_POSITION_TWEEN_MS}ms cubic-bezier(${LINE_LOADING_PULSE_EASE.join(", ")})`,
|
|
73
|
+
...(isLeft
|
|
74
|
+
? { right: 0, justifyContent: "flex-end", paddingRight: 8 }
|
|
75
|
+
: { left: 0, justifyContent: "flex-start", paddingLeft: 8 }),
|
|
76
|
+
}, children: _jsx("span", { className: "text-chart-label text-xs", style: tick.labelColor ? { color: tick.labelColor } : undefined, children: tick.label }) }, tick.value))) }) }), container);
|
|
77
|
+
});
|
|
78
|
+
YAxis.displayName = "YAxis";
|
|
79
|
+
export default YAxis;
|
|
80
|
+
//# sourceMappingURL=y-axis.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { LineConfig } from "./chart-context.js";
|
|
2
|
+
import { type ChartPhase } from "./chart-phase.js";
|
|
3
|
+
export type YDomain = [number, number];
|
|
4
|
+
/** Apply visx `nice()` to raw domain endpoints for stable grid ticks. */
|
|
5
|
+
export declare function niceYDomain(domain: YDomain): YDomain;
|
|
6
|
+
/**
|
|
7
|
+
* Skip Y tween when both endpoints move less than the threshold relative to span.
|
|
8
|
+
* When in doubt callers should tween — beauty wins over micro-optimization.
|
|
9
|
+
*/
|
|
10
|
+
export declare function shouldTweenYDomain(from: YDomain, to: YDomain): boolean;
|
|
11
|
+
/** Phases where the chart shows loading chrome (shimmer, pulse, label). */
|
|
12
|
+
export declare function isLoadingChromePhase(phase: ChartPhase): boolean;
|
|
13
|
+
/** Phases where grid lines use loading stroke styling (muted / dashed chrome). */
|
|
14
|
+
export declare function isLoadingGridChromePhase(phase: ChartPhase): boolean;
|
|
15
|
+
/** Phases where Y-domain tween runs after the series has exited. */
|
|
16
|
+
export declare function isYDomainTweenPhase(phase: ChartPhase): boolean;
|
|
17
|
+
/** Phases where {@link ReferenceArea} bands are shown (fade in/out on transitions). */
|
|
18
|
+
export declare function isReferenceAreaVisiblePhase(phase: ChartPhase): boolean;
|
|
19
|
+
export declare function resolveAnimatedYDestinationDomains(chartPhase: ChartPhase, skeletonByAxis: Record<string, YDomain>, targetByAxis: Record<string, YDomain>): Record<string, YDomain>;
|
|
20
|
+
export declare function computeYDomainsByAxis({ lines, resolveDomain, }: {
|
|
21
|
+
lines: LineConfig[];
|
|
22
|
+
resolveDomain: (dataKeys: string[]) => YDomain;
|
|
23
|
+
}): Record<string, YDomain>;
|
|
24
|
+
/** Merge domain maps, normalizing axis ids to strings. */
|
|
25
|
+
export declare function mergeYDomainRecords(...records: Record<string, YDomain>[]): Record<string, YDomain>;
|
|
26
|
+
export declare function domainsEqual(left: Record<string, YDomain>, right: Record<string, YDomain>): boolean;
|
|
27
|
+
//# sourceMappingURL=y-domain-utils.d.ts.map
|