@aiconstructions/graficos 0.0.0-stage → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ALTERACOES.md +53 -0
- package/LICENSE-BKLIT +21 -0
- package/LICENSE-visx-pattern +21 -0
- package/README.md +188 -2
- package/dist/aic/cores.js +83 -0
- package/dist/aic/index.js +22 -0
- package/dist/aic/interacao.js +55 -0
- package/dist/charts/animation.js +55 -0
- package/dist/charts/arc-geometry.js +58 -0
- package/dist/charts/arc-path.js +15 -0
- package/dist/charts/area-chart-loading.js +89 -0
- package/dist/charts/area-chart.js +149 -0
- package/dist/charts/area-gradient-defs.js +90 -0
- package/dist/charts/area-value-label-layout.js +70 -0
- package/dist/charts/area-value-labels.js +211 -0
- package/dist/charts/area.js +272 -0
- package/dist/charts/background.js +198 -0
- package/dist/charts/band-config.js +82 -0
- package/dist/charts/band-geometry.js +186 -0
- package/dist/charts/band.js +346 -0
- package/dist/charts/bar-chart-loading.js +27 -0
- package/dist/charts/bar-chart.js +545 -0
- package/dist/charts/bar-depth-geometry.js +18 -0
- package/dist/charts/bar-depth.js +608 -0
- package/dist/charts/bar-lollipop.js +278 -0
- package/dist/charts/bar-squares-layout.js +66 -0
- package/dist/charts/bar-squares.js +467 -0
- package/dist/charts/bar-value-label-layout.js +42 -0
- package/dist/charts/bar-x-axis.js +133 -0
- package/dist/charts/bar-y-axis.js +116 -0
- package/dist/charts/bar.js +457 -0
- package/dist/charts/bollinger.js +49 -0
- package/dist/charts/candlestick-chart.js +370 -0
- package/dist/charts/candlestick.js +368 -0
- package/dist/charts/chart-brush-handle.js +91 -0
- package/dist/charts/chart-brush-layout.js +91 -0
- package/dist/charts/chart-brush-selection-overlay.js +87 -0
- package/dist/charts/chart-brush-state.js +253 -0
- package/dist/charts/chart-brush-track-overlay.js +103 -0
- package/dist/charts/chart-brush.js +517 -0
- package/dist/charts/chart-center-typography.js +8 -0
- package/dist/charts/chart-child-passthrough.js +119 -0
- package/dist/charts/chart-config-context.js +56 -0
- package/dist/charts/chart-context.js +337 -0
- package/dist/charts/chart-crosshair.js +262 -0
- package/dist/charts/chart-data-override.js +186 -0
- package/dist/charts/chart-defs.js +56 -0
- package/dist/charts/chart-formatters.js +77 -0
- package/dist/charts/chart-legend-hover.js +27 -0
- package/dist/charts/chart-legend.js +163 -0
- package/dist/charts/chart-loading-label.js +52 -0
- package/dist/charts/chart-parent-size.js +138 -0
- package/dist/charts/chart-phase.js +29 -0
- package/dist/charts/chart-reveal-clip.js +62 -0
- package/dist/charts/chart-scale.js +19 -0
- package/dist/charts/chart-stat-flow.js +72 -0
- package/dist/charts/choropleth/choropleth-background.js +29 -0
- package/dist/charts/choropleth/choropleth-camera.js +379 -0
- package/dist/charts/choropleth/choropleth-chart.js +644 -0
- package/dist/charts/choropleth/choropleth-context.js +152 -0
- package/dist/charts/choropleth/choropleth-dot-grid.js +293 -0
- package/dist/charts/choropleth/choropleth-feature.js +291 -0
- package/dist/charts/choropleth/choropleth-graticule.js +40 -0
- package/dist/charts/choropleth/choropleth-marker.js +222 -0
- package/dist/charts/choropleth/choropleth-projection.js +37 -0
- package/dist/charts/choropleth/choropleth-tooltip.js +82 -0
- package/dist/charts/choropleth/choropleth-zoom-matrix.js +150 -0
- package/dist/charts/choropleth/index.js +44 -0
- package/dist/charts/choropleth/use-choropleth-zoom-state.js +636 -0
- package/dist/charts/composed-chart.js +346 -0
- package/dist/charts/crosshair-store.js +49 -0
- package/dist/charts/dash-tail-stroke.js +58 -0
- package/dist/charts/date-pill-store.js +50 -0
- package/dist/charts/date-ranges.js +131 -0
- package/dist/charts/deadline.js +295 -0
- package/dist/charts/decimate-time-series.js +112 -0
- package/dist/charts/fade-edges.js +171 -0
- package/dist/charts/fast-path.js +78 -0
- package/dist/charts/filter-data-by-x-domain.js +45 -0
- package/dist/charts/funnel-chart.js +773 -0
- package/dist/charts/gauge-arc-layers.js +479 -0
- package/dist/charts/gauge-dial.js +329 -0
- package/dist/charts/gauge-label-layout.js +148 -0
- package/dist/charts/gauge.js +946 -0
- package/dist/charts/generate-chart-skeleton-data.js +27 -0
- package/dist/charts/gradients.js +158 -0
- package/dist/charts/grid-lines.js +114 -0
- package/dist/charts/grid.js +225 -0
- package/dist/charts/heatmap/generate-heatmap-skeleton-data.js +13 -0
- package/dist/charts/heatmap/heatmap-animation.js +128 -0
- package/dist/charts/heatmap/heatmap-cells.js +519 -0
- package/dist/charts/heatmap/heatmap-chart-loading.js +44 -0
- package/dist/charts/heatmap/heatmap-chart.js +548 -0
- package/dist/charts/heatmap/heatmap-colors.js +127 -0
- package/dist/charts/heatmap/heatmap-context.js +107 -0
- package/dist/charts/heatmap/heatmap-legend-gradient.js +97 -0
- package/dist/charts/heatmap/heatmap-legend-swatch.js +76 -0
- package/dist/charts/heatmap/heatmap-legend.js +165 -0
- package/dist/charts/heatmap/heatmap-pattern-defs.js +37 -0
- package/dist/charts/heatmap/heatmap-rect-cells.js +39 -0
- package/dist/charts/heatmap/heatmap-resolve-separator.js +84 -0
- package/dist/charts/heatmap/heatmap-separator.js +168 -0
- package/dist/charts/heatmap/heatmap-tooltip.js +73 -0
- package/dist/charts/heatmap/heatmap-utils.js +633 -0
- package/dist/charts/heatmap/heatmap-x-axis.js +79 -0
- package/dist/charts/heatmap/heatmap-y-axis.js +72 -0
- package/dist/charts/heatmap/index.js +208 -0
- package/dist/charts/highlight-segment-bounds.js +34 -0
- package/dist/charts/highlight-segment.js +119 -0
- package/dist/charts/index.js +944 -0
- package/dist/charts/indicator-fade.js +44 -0
- package/dist/charts/legend/index.js +22 -0
- package/dist/charts/legend/legend-context.js +47 -0
- package/dist/charts/legend/legend-item.js +30 -0
- package/dist/charts/legend/legend-label.js +14 -0
- package/dist/charts/legend/legend-marker.js +18 -0
- package/dist/charts/legend/legend-progress.js +39 -0
- package/dist/charts/legend/legend-value.js +31 -0
- package/dist/charts/legend/legend.js +69 -0
- package/dist/charts/line-backdrop.js +129 -0
- package/dist/charts/line-chart-loading.js +85 -0
- package/dist/charts/line-chart.js +182 -0
- package/dist/charts/line-loading-pulse.js +185 -0
- package/dist/charts/line-loading-timing.js +12 -0
- package/dist/charts/line-path.js +58 -0
- package/dist/charts/line-series-terminal-marker.js +75 -0
- package/dist/charts/line.js +499 -0
- package/dist/charts/live-line-chart.js +494 -0
- package/dist/charts/live-line.js +277 -0
- package/dist/charts/live-x-axis.js +116 -0
- package/dist/charts/live-y-axis.js +164 -0
- package/dist/charts/loading-sweep.js +344 -0
- package/dist/charts/local-point.js +56 -0
- package/dist/charts/markers/chart-markers.js +149 -0
- package/dist/charts/markers/index.js +14 -0
- package/dist/charts/markers/marker-group.js +411 -0
- package/dist/charts/motion-utils.js +29 -0
- package/dist/charts/notch-gauge-shared.js +146 -0
- package/dist/charts/particle-line.js +1340 -0
- package/dist/charts/path-stroke-utils.js +51 -0
- package/dist/charts/pattern-area.js +127 -0
- package/dist/charts/pattern-preset.js +287 -0
- package/dist/charts/pattern-tile.js +31 -0
- package/dist/charts/patterns/circles.js +62 -0
- package/dist/charts/patterns/constants.js +9 -0
- package/dist/charts/patterns/hexagons.js +38 -0
- package/dist/charts/patterns/index.js +16 -0
- package/dist/charts/patterns/lines.js +65 -0
- package/dist/charts/patterns/path.js +37 -0
- package/dist/charts/patterns/pattern.js +16 -0
- package/dist/charts/patterns/waves.js +40 -0
- package/dist/charts/pie-center-shell.js +127 -0
- package/dist/charts/pie-center.js +87 -0
- package/dist/charts/pie-chart.js +377 -0
- package/dist/charts/pie-context.js +116 -0
- package/dist/charts/pie-slice.js +394 -0
- package/dist/charts/pie-ticks.js +332 -0
- package/dist/charts/profit-loss-legend-hover.js +18 -0
- package/dist/charts/profit-loss-legend.js +53 -0
- package/dist/charts/profit-loss-line.js +162 -0
- package/dist/charts/profit-loss-segments.js +88 -0
- package/dist/charts/projection-config.js +90 -0
- package/dist/charts/projection-line-end-marker.js +50 -0
- package/dist/charts/projection-line.js +466 -0
- package/dist/charts/projection-utils.js +303 -0
- package/dist/charts/radar-area.js +192 -0
- package/dist/charts/radar-axis.js +41 -0
- package/dist/charts/radar-chart.js +184 -0
- package/dist/charts/radar-context.js +104 -0
- package/dist/charts/radar-grid.js +121 -0
- package/dist/charts/radar-labels.js +62 -0
- package/dist/charts/radial-area.js +498 -0
- package/dist/charts/radial-axis.js +652 -0
- package/dist/charts/radial-bar.js +316 -0
- package/dist/charts/radial-center.js +67 -0
- package/dist/charts/radial-chart.js +740 -0
- package/dist/charts/radial-dot-bar-layout.js +68 -0
- package/dist/charts/radial-dot-bar.js +387 -0
- package/dist/charts/radial-geometry.js +114 -0
- package/dist/charts/radial-legend.js +66 -0
- package/dist/charts/radial-line.js +280 -0
- package/dist/charts/radial-ring-bar.js +255 -0
- package/dist/charts/radial-scrubber.js +120 -0
- package/dist/charts/radial-series-color.js +10 -0
- package/dist/charts/reference-area-config.js +43 -0
- package/dist/charts/reference-area-geometry.js +76 -0
- package/dist/charts/reference-area-registration-context.js +10 -0
- package/dist/charts/reference-area.js +241 -0
- package/dist/charts/responsive-chart-label-count.js +18 -0
- package/dist/charts/ring-center.js +78 -0
- package/dist/charts/ring-chart.js +362 -0
- package/dist/charts/ring-context.js +122 -0
- package/dist/charts/ring-grid.js +175 -0
- package/dist/charts/ring-labels.js +109 -0
- package/dist/charts/ring.js +237 -0
- package/dist/charts/sankey/index.js +22 -0
- package/dist/charts/sankey/sankey-chart.js +199 -0
- package/dist/charts/sankey/sankey-context.js +32 -0
- package/dist/charts/sankey/sankey-link.js +232 -0
- package/dist/charts/sankey/sankey-node.js +348 -0
- package/dist/charts/sankey/sankey-tooltip.js +94 -0
- package/dist/charts/scatter-chart-shell.js +279 -0
- package/dist/charts/scatter-chart.js +150 -0
- package/dist/charts/scatter-jitter.js +86 -0
- package/dist/charts/scatter-svg.js +17 -0
- package/dist/charts/scatter.js +92 -0
- package/dist/charts/segment.js +107 -0
- package/dist/charts/series-bar-layout.js +42 -0
- package/dist/charts/series-bar.js +241 -0
- package/dist/charts/series-dash-tail-overlay.js +53 -0
- package/dist/charts/series-highlight-layer.js +43 -0
- package/dist/charts/series-hover-dim.js +32 -0
- package/dist/charts/series-markers.js +239 -0
- package/dist/charts/series-path-utils.js +185 -0
- package/dist/charts/series-point-marker.js +150 -0
- package/dist/charts/sparkline-geometry.js +197 -0
- package/dist/charts/sparkline.js +910 -0
- package/dist/charts/static-chart-preview-context.js +16 -0
- package/dist/charts/sunburst-breadcrumb.js +33 -0
- package/dist/charts/sunburst-center.js +37 -0
- package/dist/charts/sunburst-chart.js +408 -0
- package/dist/charts/sunburst-context.js +140 -0
- package/dist/charts/sunburst-data.js +0 -0
- package/dist/charts/sunburst-hint.js +42 -0
- package/dist/charts/sunburst-labels.js +130 -0
- package/dist/charts/sunburst-segment.js +144 -0
- package/dist/charts/sunburst.js +419 -0
- package/dist/charts/time-series-chart-shell.js +688 -0
- package/dist/charts/tooltip/chart-tooltip.js +516 -0
- package/dist/charts/tooltip/cursor-tooltip-box.js +183 -0
- package/dist/charts/tooltip/date-ticker.js +376 -0
- package/dist/charts/tooltip/index.js +32 -0
- package/dist/charts/tooltip/liquid-glass.js +142 -0
- package/dist/charts/tooltip/tooltip-box.js +502 -0
- package/dist/charts/tooltip/tooltip-content.js +59 -0
- package/dist/charts/tooltip/tooltip-dot.js +170 -0
- package/dist/charts/tooltip/tooltip-indicator.js +175 -0
- package/dist/charts/tooltip/use-delayed-tooltip-data.js +41 -0
- package/dist/charts/tooltip/use-velocity-stretch.js +52 -0
- package/dist/charts/trend-line-utils.js +64 -0
- package/dist/charts/trend-line.js +318 -0
- package/dist/charts/use-animated-band.js +175 -0
- package/dist/charts/use-animated-series-path.js +208 -0
- package/dist/charts/use-animated-y-domains.js +192 -0
- package/dist/charts/use-category-slots.js +29 -0
- package/dist/charts/use-chart-interaction.js +296 -0
- package/dist/charts/use-chart-phase-orchestrator.js +183 -0
- package/dist/charts/use-enter-complete.js +18 -0
- package/dist/charts/use-grid-shimmer.js +88 -0
- package/dist/charts/use-highlight-segment.js +65 -0
- package/dist/charts/use-mount-progress.js +23 -0
- package/dist/charts/use-scatter-chart-interaction.js +364 -0
- package/dist/charts/use-scheduled-tooltip.js +84 -0
- package/dist/charts/visx-pattern.js +30 -0
- package/dist/charts/weekends.js +174 -0
- package/dist/charts/x-axis-hover.js +46 -0
- package/dist/charts/x-axis.js +523 -0
- package/dist/charts/y-axis-scales.js +71 -0
- package/dist/charts/y-axis-ticks.js +22 -0
- package/dist/charts/y-axis.js +233 -0
- package/dist/charts/y-domain-utils.js +189 -0
- package/dist/index.d.ts +7346 -0
- package/dist/index.js +2 -0
- package/dist/lib/utils.js +8 -0
- package/dist/shimmering-text.js +54 -0
- package/package.json +78 -4
- package/tema.css +202 -0
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { curveNatural } from "d3-shape";
|
|
4
|
+
import {
|
|
5
|
+
memo,
|
|
6
|
+
useCallback,
|
|
7
|
+
useId,
|
|
8
|
+
useMemo,
|
|
9
|
+
useRef,
|
|
10
|
+
useState
|
|
11
|
+
} from "react";
|
|
12
|
+
import {
|
|
13
|
+
chartCssVars,
|
|
14
|
+
useChartStable,
|
|
15
|
+
useSettledYScale,
|
|
16
|
+
useYScale
|
|
17
|
+
} from "./chart-context";
|
|
18
|
+
import {
|
|
19
|
+
fadeGradientStops,
|
|
20
|
+
horizontalPaintStops,
|
|
21
|
+
resolveFadeSides,
|
|
22
|
+
resolveStrokeGradientStops,
|
|
23
|
+
viewportFadeGradientAttrs
|
|
24
|
+
} from "./fade-edges";
|
|
25
|
+
import {
|
|
26
|
+
LineLoadingPulseStroke,
|
|
27
|
+
resolveLineLoadingPulseMode
|
|
28
|
+
} from "./line-loading-pulse";
|
|
29
|
+
import { LINE_LOADING_LOOP_PAUSE_MS } from "./line-loading-timing";
|
|
30
|
+
import { LinePath } from "./line-path";
|
|
31
|
+
import { LineLoadingSweep } from "./loading-sweep";
|
|
32
|
+
import {
|
|
33
|
+
resolveDashTailBounds,
|
|
34
|
+
usePathStrokeMetrics
|
|
35
|
+
} from "./path-stroke-utils";
|
|
36
|
+
import { SeriesDashTailOverlay } from "./series-dash-tail-overlay";
|
|
37
|
+
import { SeriesHighlightLayer } from "./series-highlight-layer";
|
|
38
|
+
import { SeriesHoverDim } from "./series-hover-dim";
|
|
39
|
+
import { SeriesMarkers } from "./series-markers";
|
|
40
|
+
import { useAnimatedSeriesPath } from "./use-animated-series-path";
|
|
41
|
+
const DEFAULT_GLOW_BLUR = 6;
|
|
42
|
+
const DEFAULT_GLOW_OPACITY = 0.7;
|
|
43
|
+
const DEFAULT_HIGHLIGHT_DIM_OPACITY = 0.3;
|
|
44
|
+
function LineSeriesStroke({
|
|
45
|
+
animatedPathD,
|
|
46
|
+
filter,
|
|
47
|
+
pathRef,
|
|
48
|
+
staticPathD,
|
|
49
|
+
strokeOpacity,
|
|
50
|
+
strokeWidth,
|
|
51
|
+
drawAnimatedPath,
|
|
52
|
+
visibleStroke
|
|
53
|
+
}) {
|
|
54
|
+
if (drawAnimatedPath) {
|
|
55
|
+
return /* @__PURE__ */ jsx(
|
|
56
|
+
"path",
|
|
57
|
+
{
|
|
58
|
+
d: animatedPathD,
|
|
59
|
+
fill: "none",
|
|
60
|
+
filter,
|
|
61
|
+
ref: pathRef,
|
|
62
|
+
stroke: visibleStroke,
|
|
63
|
+
strokeLinecap: "round",
|
|
64
|
+
strokeOpacity,
|
|
65
|
+
strokeWidth
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
return /* @__PURE__ */ jsx(
|
|
70
|
+
LinePath,
|
|
71
|
+
{
|
|
72
|
+
d: staticPathD,
|
|
73
|
+
filter,
|
|
74
|
+
innerRef: pathRef,
|
|
75
|
+
stroke: visibleStroke,
|
|
76
|
+
strokeLinecap: "round",
|
|
77
|
+
strokeOpacity,
|
|
78
|
+
strokeWidth
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
const LineLoadingOverlays = memo(function LineLoadingOverlays2({
|
|
83
|
+
curve,
|
|
84
|
+
handleLoadingPulseComplete,
|
|
85
|
+
innerWidth,
|
|
86
|
+
loadingStroke,
|
|
87
|
+
loadingStrokeOpacity,
|
|
88
|
+
loadingStyle,
|
|
89
|
+
pathD,
|
|
90
|
+
pulseEpoch,
|
|
91
|
+
pulseMode,
|
|
92
|
+
showLoadingPulse,
|
|
93
|
+
strokeWidth
|
|
94
|
+
}) {
|
|
95
|
+
const sweepLoading = showLoadingPulse && innerWidth > 0 && loadingStyle === "sweep";
|
|
96
|
+
const pulseLoading = showLoadingPulse && innerWidth > 0 && !sweepLoading;
|
|
97
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
98
|
+
sweepLoading ? /* @__PURE__ */ jsx(
|
|
99
|
+
LineLoadingSweep,
|
|
100
|
+
{
|
|
101
|
+
curve,
|
|
102
|
+
mode: pulseMode ?? "loop",
|
|
103
|
+
onTransitionComplete: handleLoadingPulseComplete,
|
|
104
|
+
stroke: loadingStroke,
|
|
105
|
+
strokeOpacity: loadingStrokeOpacity,
|
|
106
|
+
strokeWidth
|
|
107
|
+
},
|
|
108
|
+
"loading-sweep"
|
|
109
|
+
) : null,
|
|
110
|
+
pulseLoading && pathD ? /* @__PURE__ */ jsx(
|
|
111
|
+
LineLoadingPulseStroke,
|
|
112
|
+
{
|
|
113
|
+
loopEpoch: pulseEpoch,
|
|
114
|
+
mode: pulseMode ?? void 0,
|
|
115
|
+
onCycleComplete: handleLoadingPulseComplete,
|
|
116
|
+
pathD,
|
|
117
|
+
stroke: loadingStroke,
|
|
118
|
+
strokeOpacity: loadingStrokeOpacity,
|
|
119
|
+
strokeWidth
|
|
120
|
+
},
|
|
121
|
+
"loading-pulse"
|
|
122
|
+
) : null
|
|
123
|
+
] });
|
|
124
|
+
});
|
|
125
|
+
function resolveLineGlow(glow, strokeWidth) {
|
|
126
|
+
if (!glow) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
const options = glow === true ? {} : glow;
|
|
130
|
+
return {
|
|
131
|
+
blur: options.blur ?? DEFAULT_GLOW_BLUR,
|
|
132
|
+
opacity: options.opacity ?? DEFAULT_GLOW_OPACITY,
|
|
133
|
+
strokeWidth: options.strokeWidth ?? strokeWidth * 2
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function GradientStops({ stops }) {
|
|
137
|
+
return stops.map((stop) => /* @__PURE__ */ jsx(
|
|
138
|
+
"stop",
|
|
139
|
+
{
|
|
140
|
+
offset: stop.offset,
|
|
141
|
+
style: { stopColor: stop.color, stopOpacity: stop.opacity }
|
|
142
|
+
},
|
|
143
|
+
stop.offset
|
|
144
|
+
));
|
|
145
|
+
}
|
|
146
|
+
function useLineHighlightPaint({
|
|
147
|
+
colorStops,
|
|
148
|
+
enabled,
|
|
149
|
+
glowFilterId,
|
|
150
|
+
gradientId,
|
|
151
|
+
highlight,
|
|
152
|
+
stroke,
|
|
153
|
+
strokeWidth
|
|
154
|
+
}) {
|
|
155
|
+
const gradient = highlight?.strokeGradient;
|
|
156
|
+
const color = highlight?.stroke;
|
|
157
|
+
const stops = useMemo(() => {
|
|
158
|
+
const ownStops = gradient ? resolveStrokeGradientStops(gradient) : null;
|
|
159
|
+
if (ownStops) {
|
|
160
|
+
return horizontalPaintStops({
|
|
161
|
+
color: color ?? stroke,
|
|
162
|
+
colorStops: ownStops,
|
|
163
|
+
fadeStops: null
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if (color || !colorStops) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
return horizontalPaintStops({ color: stroke, colorStops, fadeStops: null });
|
|
170
|
+
}, [colorStops, color, gradient, stroke]);
|
|
171
|
+
const width = highlight?.strokeWidth ?? strokeWidth;
|
|
172
|
+
const glow = resolveLineGlow(
|
|
173
|
+
enabled ? highlight?.glow ?? false : false,
|
|
174
|
+
width
|
|
175
|
+
);
|
|
176
|
+
return {
|
|
177
|
+
stops,
|
|
178
|
+
stroke: stops ? `url(#${gradientId})` : color ?? stroke,
|
|
179
|
+
strokeWidth: width,
|
|
180
|
+
/** Filter def to render, or `null` when the segment has no glow. */
|
|
181
|
+
glowFilter: glow ? { id: glowFilterId, blur: glow.blur } : null,
|
|
182
|
+
/** `HighlightSegment` glow props. */
|
|
183
|
+
segmentGlow: glow ? {
|
|
184
|
+
filter: `url(#${glowFilterId})`,
|
|
185
|
+
opacity: glow.opacity,
|
|
186
|
+
strokeWidth: glow.strokeWidth
|
|
187
|
+
} : void 0,
|
|
188
|
+
dimOpacity: highlight?.dimOpacity ?? DEFAULT_HIGHLIGHT_DIM_OPACITY
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function GlowFilter({
|
|
192
|
+
blur,
|
|
193
|
+
id,
|
|
194
|
+
innerHeight,
|
|
195
|
+
innerWidth
|
|
196
|
+
}) {
|
|
197
|
+
const pad = blur * 3;
|
|
198
|
+
return /* @__PURE__ */ jsx(
|
|
199
|
+
"filter",
|
|
200
|
+
{
|
|
201
|
+
colorInterpolationFilters: "sRGB",
|
|
202
|
+
filterUnits: "userSpaceOnUse",
|
|
203
|
+
height: innerHeight + pad * 2,
|
|
204
|
+
id,
|
|
205
|
+
width: innerWidth + pad * 2,
|
|
206
|
+
x: -pad,
|
|
207
|
+
y: -pad,
|
|
208
|
+
children: /* @__PURE__ */ jsx("feGaussianBlur", { stdDeviation: blur })
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
const LineStrokeDefs = memo(function LineStrokeDefs2({
|
|
213
|
+
glowBlur,
|
|
214
|
+
glowFilterId,
|
|
215
|
+
gradientId,
|
|
216
|
+
highlightGlow,
|
|
217
|
+
highlightGradientId,
|
|
218
|
+
highlightStops,
|
|
219
|
+
innerHeight,
|
|
220
|
+
innerWidth,
|
|
221
|
+
paintStops
|
|
222
|
+
}) {
|
|
223
|
+
if (!(paintStops || highlightStops || glowFilterId || highlightGlow)) {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
return /* @__PURE__ */ jsxs("defs", { children: [
|
|
227
|
+
paintStops ? /* @__PURE__ */ jsx(
|
|
228
|
+
"linearGradient",
|
|
229
|
+
{
|
|
230
|
+
id: gradientId,
|
|
231
|
+
...viewportFadeGradientAttrs(innerWidth),
|
|
232
|
+
children: /* @__PURE__ */ jsx(GradientStops, { stops: paintStops })
|
|
233
|
+
}
|
|
234
|
+
) : null,
|
|
235
|
+
highlightStops ? /* @__PURE__ */ jsx(
|
|
236
|
+
"linearGradient",
|
|
237
|
+
{
|
|
238
|
+
id: highlightGradientId,
|
|
239
|
+
...viewportFadeGradientAttrs(innerWidth),
|
|
240
|
+
children: /* @__PURE__ */ jsx(GradientStops, { stops: highlightStops })
|
|
241
|
+
}
|
|
242
|
+
) : null,
|
|
243
|
+
glowFilterId ? /* @__PURE__ */ jsx(
|
|
244
|
+
GlowFilter,
|
|
245
|
+
{
|
|
246
|
+
blur: glowBlur,
|
|
247
|
+
id: glowFilterId,
|
|
248
|
+
innerHeight,
|
|
249
|
+
innerWidth
|
|
250
|
+
}
|
|
251
|
+
) : null,
|
|
252
|
+
highlightGlow ? /* @__PURE__ */ jsx(
|
|
253
|
+
GlowFilter,
|
|
254
|
+
{
|
|
255
|
+
blur: highlightGlow.blur,
|
|
256
|
+
id: highlightGlow.id,
|
|
257
|
+
innerHeight,
|
|
258
|
+
innerWidth
|
|
259
|
+
}
|
|
260
|
+
) : null
|
|
261
|
+
] });
|
|
262
|
+
});
|
|
263
|
+
function resolveLinePulseMode(chartPhase, loading, loadingPulseMode) {
|
|
264
|
+
if (loading === false) {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
return loadingPulseMode ?? (loading === true ? "loop" : resolveLineLoadingPulseMode(chartPhase));
|
|
268
|
+
}
|
|
269
|
+
function Line({
|
|
270
|
+
dataKey,
|
|
271
|
+
yAxisId,
|
|
272
|
+
stroke = chartCssVars.linePrimary,
|
|
273
|
+
strokeWidth = 2.5,
|
|
274
|
+
curve = curveNatural,
|
|
275
|
+
animate = true,
|
|
276
|
+
fadeEdges = true,
|
|
277
|
+
strokeGradient,
|
|
278
|
+
glow = false,
|
|
279
|
+
showHighlight = true,
|
|
280
|
+
highlight,
|
|
281
|
+
showMarkers = false,
|
|
282
|
+
markers,
|
|
283
|
+
dashFromIndex,
|
|
284
|
+
dashArray = "6,4",
|
|
285
|
+
loading,
|
|
286
|
+
loadingStroke = chartCssVars.foreground,
|
|
287
|
+
loadingStrokeOpacity = 0.5,
|
|
288
|
+
loadingPulseMode,
|
|
289
|
+
onLoadingPulseCycleComplete,
|
|
290
|
+
loadingStyle = "pulse"
|
|
291
|
+
}) {
|
|
292
|
+
const {
|
|
293
|
+
data,
|
|
294
|
+
renderData,
|
|
295
|
+
xScale,
|
|
296
|
+
innerHeight,
|
|
297
|
+
innerWidth,
|
|
298
|
+
xAccessor,
|
|
299
|
+
lines,
|
|
300
|
+
chartPhase,
|
|
301
|
+
notifyLoadingPulseComplete,
|
|
302
|
+
yDomainTweenDuration
|
|
303
|
+
} = useChartStable();
|
|
304
|
+
const yScale = useYScale(yAxisId);
|
|
305
|
+
const settledYScale = useSettledYScale(yAxisId);
|
|
306
|
+
const useDataTransitionPath = animate && chartPhase === "ready";
|
|
307
|
+
const { pathD: animatedPathD } = useAnimatedSeriesPath({
|
|
308
|
+
chartPhase,
|
|
309
|
+
curve,
|
|
310
|
+
dataKey,
|
|
311
|
+
durationMs: yDomainTweenDuration,
|
|
312
|
+
enabled: useDataTransitionPath,
|
|
313
|
+
innerWidth,
|
|
314
|
+
renderData,
|
|
315
|
+
settledYScale,
|
|
316
|
+
xAccessor,
|
|
317
|
+
xScale,
|
|
318
|
+
yScale
|
|
319
|
+
});
|
|
320
|
+
const pulseMode = resolveLinePulseMode(chartPhase, loading, loadingPulseMode);
|
|
321
|
+
const showLoadingPulse = pulseMode != null;
|
|
322
|
+
const [pulseEpoch, setPulseEpoch] = useState(0);
|
|
323
|
+
const effectiveShowHighlight = showHighlight && !showLoadingPulse;
|
|
324
|
+
const handleLoadingPulseComplete = useCallback(() => {
|
|
325
|
+
onLoadingPulseCycleComplete?.();
|
|
326
|
+
if (pulseMode === "loop") {
|
|
327
|
+
window.setTimeout(() => {
|
|
328
|
+
setPulseEpoch((epoch) => epoch + 1);
|
|
329
|
+
}, LINE_LOADING_LOOP_PAUSE_MS);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
notifyLoadingPulseComplete?.();
|
|
333
|
+
}, [notifyLoadingPulseComplete, onLoadingPulseCycleComplete, pulseMode]);
|
|
334
|
+
const seriesIndex = useMemo(() => {
|
|
335
|
+
const index = lines.findIndex((line) => line.dataKey === dataKey);
|
|
336
|
+
return index >= 0 ? index : 0;
|
|
337
|
+
}, [lines, dataKey]);
|
|
338
|
+
const pathRef = useRef(null);
|
|
339
|
+
const hasDashTail = resolveDashTailBounds(dashFromIndex, data.length);
|
|
340
|
+
const { pathLength, pathD } = usePathStrokeMetrics(
|
|
341
|
+
pathRef,
|
|
342
|
+
[
|
|
343
|
+
renderData,
|
|
344
|
+
innerWidth,
|
|
345
|
+
dashFromIndex,
|
|
346
|
+
animate,
|
|
347
|
+
useDataTransitionPath ? animatedPathD : null
|
|
348
|
+
],
|
|
349
|
+
// Only the dash tail and loading pulse read the metrics; outside the
|
|
350
|
+
// resting "ready" phase keep measuring so a pulse starts on a fresh path.
|
|
351
|
+
hasDashTail || showLoadingPulse || chartPhase !== "ready"
|
|
352
|
+
);
|
|
353
|
+
const reactId = useId();
|
|
354
|
+
const gradientId = `line-gradient-${dataKey}-${reactId}`;
|
|
355
|
+
const highlightGradientId = `${gradientId}-highlight`;
|
|
356
|
+
const glowFilterId = `line-glow-${dataKey}-${reactId}`;
|
|
357
|
+
const drawAnimatedPath = useDataTransitionPath && Boolean(animatedPathD);
|
|
358
|
+
const colorStops = useMemo(
|
|
359
|
+
() => resolveStrokeGradientStops(strokeGradient),
|
|
360
|
+
[strokeGradient]
|
|
361
|
+
);
|
|
362
|
+
const paintStops = useMemo(() => {
|
|
363
|
+
const sides = resolveFadeSides(fadeEdges);
|
|
364
|
+
if (!(sides.any || colorStops)) {
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
return horizontalPaintStops({
|
|
368
|
+
color: stroke,
|
|
369
|
+
colorStops,
|
|
370
|
+
fadeStops: sides.any ? fadeGradientStops(sides) : null
|
|
371
|
+
});
|
|
372
|
+
}, [colorStops, fadeEdges, stroke]);
|
|
373
|
+
const highlightPaint = useLineHighlightPaint({
|
|
374
|
+
colorStops,
|
|
375
|
+
enabled: effectiveShowHighlight,
|
|
376
|
+
glowFilterId: `${glowFilterId}-highlight`,
|
|
377
|
+
gradientId: highlightGradientId,
|
|
378
|
+
highlight,
|
|
379
|
+
stroke,
|
|
380
|
+
strokeWidth
|
|
381
|
+
});
|
|
382
|
+
const lineStroke = paintStops ? `url(#${gradientId})` : stroke;
|
|
383
|
+
const glowOptions = resolveLineGlow(glow, strokeWidth);
|
|
384
|
+
const showSeriesStroke = chartPhase === "revealing" || chartPhase === "ready" || chartPhase === "exitingReady";
|
|
385
|
+
let visibleStroke = "transparent";
|
|
386
|
+
if (showSeriesStroke && !hasDashTail) {
|
|
387
|
+
visibleStroke = lineStroke;
|
|
388
|
+
}
|
|
389
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
390
|
+
/* @__PURE__ */ jsx(
|
|
391
|
+
LineStrokeDefs,
|
|
392
|
+
{
|
|
393
|
+
glowBlur: glowOptions?.blur ?? 0,
|
|
394
|
+
glowFilterId: glowOptions ? glowFilterId : null,
|
|
395
|
+
gradientId,
|
|
396
|
+
highlightGlow: highlightPaint.glowFilter,
|
|
397
|
+
highlightGradientId,
|
|
398
|
+
highlightStops: highlightPaint.stops,
|
|
399
|
+
innerHeight,
|
|
400
|
+
innerWidth,
|
|
401
|
+
paintStops
|
|
402
|
+
}
|
|
403
|
+
),
|
|
404
|
+
/* @__PURE__ */ jsxs(
|
|
405
|
+
SeriesHoverDim,
|
|
406
|
+
{
|
|
407
|
+
dimOpacity: highlightPaint.dimOpacity,
|
|
408
|
+
enabled: effectiveShowHighlight,
|
|
409
|
+
seriesIndex,
|
|
410
|
+
children: [
|
|
411
|
+
glowOptions && showSeriesStroke ? /* @__PURE__ */ jsx(
|
|
412
|
+
LineSeriesStroke,
|
|
413
|
+
{
|
|
414
|
+
animatedPathD,
|
|
415
|
+
drawAnimatedPath,
|
|
416
|
+
filter: `url(#${glowFilterId})`,
|
|
417
|
+
staticPathD: animatedPathD,
|
|
418
|
+
strokeOpacity: glowOptions.opacity,
|
|
419
|
+
strokeWidth: glowOptions.strokeWidth,
|
|
420
|
+
visibleStroke: lineStroke
|
|
421
|
+
}
|
|
422
|
+
) : null,
|
|
423
|
+
/* @__PURE__ */ jsx(
|
|
424
|
+
LineSeriesStroke,
|
|
425
|
+
{
|
|
426
|
+
animatedPathD,
|
|
427
|
+
drawAnimatedPath,
|
|
428
|
+
pathRef,
|
|
429
|
+
staticPathD: animatedPathD,
|
|
430
|
+
strokeWidth,
|
|
431
|
+
visibleStroke
|
|
432
|
+
}
|
|
433
|
+
),
|
|
434
|
+
hasDashTail ? /* @__PURE__ */ jsx(
|
|
435
|
+
SeriesDashTailOverlay,
|
|
436
|
+
{
|
|
437
|
+
dashArray,
|
|
438
|
+
dashFromIndex,
|
|
439
|
+
data,
|
|
440
|
+
innerHeight,
|
|
441
|
+
innerWidth,
|
|
442
|
+
pathD,
|
|
443
|
+
pathLength,
|
|
444
|
+
stroke: lineStroke,
|
|
445
|
+
strokeWidth,
|
|
446
|
+
xAccessor,
|
|
447
|
+
xScale
|
|
448
|
+
}
|
|
449
|
+
) : null
|
|
450
|
+
]
|
|
451
|
+
}
|
|
452
|
+
),
|
|
453
|
+
showMarkers ? /* @__PURE__ */ jsx(
|
|
454
|
+
SeriesMarkers,
|
|
455
|
+
{
|
|
456
|
+
animate,
|
|
457
|
+
dataKey,
|
|
458
|
+
...markers,
|
|
459
|
+
fill: markers?.fill ?? stroke,
|
|
460
|
+
stroke: markers?.stroke ?? markers?.fill ?? stroke
|
|
461
|
+
}
|
|
462
|
+
) : null,
|
|
463
|
+
/* @__PURE__ */ jsx(
|
|
464
|
+
SeriesHighlightLayer,
|
|
465
|
+
{
|
|
466
|
+
enabled: effectiveShowHighlight,
|
|
467
|
+
fadeLength: highlight?.fadeLength,
|
|
468
|
+
glow: highlightPaint.segmentGlow,
|
|
469
|
+
height: innerHeight,
|
|
470
|
+
pathRef,
|
|
471
|
+
span: highlight?.span,
|
|
472
|
+
stroke: highlightPaint.stroke,
|
|
473
|
+
strokeWidth: highlightPaint.strokeWidth
|
|
474
|
+
}
|
|
475
|
+
),
|
|
476
|
+
/* @__PURE__ */ jsx(
|
|
477
|
+
LineLoadingOverlays,
|
|
478
|
+
{
|
|
479
|
+
curve,
|
|
480
|
+
handleLoadingPulseComplete,
|
|
481
|
+
innerWidth,
|
|
482
|
+
loadingStroke,
|
|
483
|
+
loadingStrokeOpacity,
|
|
484
|
+
loadingStyle,
|
|
485
|
+
pathD,
|
|
486
|
+
pulseEpoch,
|
|
487
|
+
pulseMode,
|
|
488
|
+
showLoadingPulse,
|
|
489
|
+
strokeWidth
|
|
490
|
+
}
|
|
491
|
+
)
|
|
492
|
+
] });
|
|
493
|
+
}
|
|
494
|
+
Line.displayName = "Line";
|
|
495
|
+
var line_default = Line;
|
|
496
|
+
export {
|
|
497
|
+
Line,
|
|
498
|
+
line_default as default
|
|
499
|
+
};
|