@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,272 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { curveMonotoneX } from "d3-shape";
|
|
4
|
+
import { useCallback, useId, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { AreaGradientDefs } from "./area-gradient-defs";
|
|
6
|
+
import { chartCssVars, useChartStable, useYScale } from "./chart-context";
|
|
7
|
+
import { resolveFadeSides } from "./fade-edges";
|
|
8
|
+
import {
|
|
9
|
+
LineLoadingPulseStroke,
|
|
10
|
+
resolveLineLoadingPulseMode
|
|
11
|
+
} from "./line-loading-pulse";
|
|
12
|
+
import { LINE_LOADING_LOOP_PAUSE_MS } from "./line-loading-timing";
|
|
13
|
+
import { areaClosedD, LinePath, linePathD } from "./line-path";
|
|
14
|
+
import { LineLoadingSweep } from "./loading-sweep";
|
|
15
|
+
import {
|
|
16
|
+
resolveDashTailBounds,
|
|
17
|
+
usePathStrokeMetrics
|
|
18
|
+
} from "./path-stroke-utils";
|
|
19
|
+
import { SeriesDashTailOverlay } from "./series-dash-tail-overlay";
|
|
20
|
+
import { SeriesHighlightLayer } from "./series-highlight-layer";
|
|
21
|
+
import { SeriesHoverDim } from "./series-hover-dim";
|
|
22
|
+
import { SeriesMarkers } from "./series-markers";
|
|
23
|
+
function useAreaLoadingPulseState(chartPhase, loading, loadingPulseMode, notifyLoadingPulseComplete) {
|
|
24
|
+
const phasePulseMode = resolveLineLoadingPulseMode(chartPhase);
|
|
25
|
+
const pulseMode = loading === false ? null : loadingPulseMode ?? (loading === true ? "loop" : phasePulseMode);
|
|
26
|
+
const showLoadingPulse = pulseMode != null;
|
|
27
|
+
const showSeriesContent = chartPhase === "revealing" || chartPhase === "ready" || chartPhase === "exitingReady";
|
|
28
|
+
const [pulseEpoch, setPulseEpoch] = useState(0);
|
|
29
|
+
const handleLoadingPulseComplete = useCallback(() => {
|
|
30
|
+
if (pulseMode === "loop") {
|
|
31
|
+
window.setTimeout(() => {
|
|
32
|
+
setPulseEpoch((epoch) => epoch + 1);
|
|
33
|
+
}, LINE_LOADING_LOOP_PAUSE_MS);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
notifyLoadingPulseComplete?.();
|
|
37
|
+
}, [notifyLoadingPulseComplete, pulseMode]);
|
|
38
|
+
return {
|
|
39
|
+
handleLoadingPulseComplete,
|
|
40
|
+
pulseMode,
|
|
41
|
+
pulseEpoch,
|
|
42
|
+
showLoadingPulse,
|
|
43
|
+
showSeriesContent
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function Area({
|
|
47
|
+
dataKey,
|
|
48
|
+
yAxisId,
|
|
49
|
+
fill = chartCssVars.linePrimary,
|
|
50
|
+
fillOpacity = 0.4,
|
|
51
|
+
stroke,
|
|
52
|
+
strokeWidth = 2,
|
|
53
|
+
curve = curveMonotoneX,
|
|
54
|
+
animate = true,
|
|
55
|
+
showLine = true,
|
|
56
|
+
showHighlight = true,
|
|
57
|
+
gradientToOpacity = 0,
|
|
58
|
+
gradientSpan = 1,
|
|
59
|
+
fadeEdges = false,
|
|
60
|
+
fadeBottom,
|
|
61
|
+
showMarkers = false,
|
|
62
|
+
markers,
|
|
63
|
+
dashFromIndex,
|
|
64
|
+
dashArray = "6,4",
|
|
65
|
+
loading,
|
|
66
|
+
loadingStroke = chartCssVars.foreground,
|
|
67
|
+
loadingStrokeOpacity = 0.5,
|
|
68
|
+
loadingPulseMode,
|
|
69
|
+
loadingStyle = "pulse"
|
|
70
|
+
}) {
|
|
71
|
+
const {
|
|
72
|
+
data,
|
|
73
|
+
renderData,
|
|
74
|
+
xScale,
|
|
75
|
+
innerHeight,
|
|
76
|
+
innerWidth,
|
|
77
|
+
xAccessor,
|
|
78
|
+
lines,
|
|
79
|
+
chartPhase,
|
|
80
|
+
notifyLoadingPulseComplete
|
|
81
|
+
} = useChartStable();
|
|
82
|
+
const yScale = useYScale(yAxisId);
|
|
83
|
+
const {
|
|
84
|
+
handleLoadingPulseComplete,
|
|
85
|
+
pulseMode,
|
|
86
|
+
pulseEpoch,
|
|
87
|
+
showLoadingPulse,
|
|
88
|
+
showSeriesContent
|
|
89
|
+
} = useAreaLoadingPulseState(
|
|
90
|
+
chartPhase,
|
|
91
|
+
loading,
|
|
92
|
+
loadingPulseMode,
|
|
93
|
+
notifyLoadingPulseComplete
|
|
94
|
+
);
|
|
95
|
+
const seriesIndex = useMemo(() => {
|
|
96
|
+
const index = lines.findIndex((line) => line.dataKey === dataKey);
|
|
97
|
+
return index >= 0 ? index : 0;
|
|
98
|
+
}, [lines, dataKey]);
|
|
99
|
+
const pathRef = useRef(null);
|
|
100
|
+
const hasDashTail = resolveDashTailBounds(dashFromIndex, data.length);
|
|
101
|
+
const { pathLength, pathD } = usePathStrokeMetrics(
|
|
102
|
+
pathRef,
|
|
103
|
+
[
|
|
104
|
+
renderData,
|
|
105
|
+
innerWidth,
|
|
106
|
+
dashFromIndex,
|
|
107
|
+
showLine,
|
|
108
|
+
showSeriesContent,
|
|
109
|
+
showLoadingPulse
|
|
110
|
+
],
|
|
111
|
+
// Only the dash tail and loading pulse read the metrics; outside the
|
|
112
|
+
// resting "ready" phase keep measuring so a pulse starts on a fresh path.
|
|
113
|
+
hasDashTail || showLoadingPulse || chartPhase !== "ready"
|
|
114
|
+
);
|
|
115
|
+
const uniqueId = useId();
|
|
116
|
+
const gradientId = `area-gradient-${dataKey}-${uniqueId}`;
|
|
117
|
+
const strokeGradientId = `area-stroke-gradient-${dataKey}-${uniqueId}`;
|
|
118
|
+
const edgeMaskId = `area-edge-mask-${dataKey}-${uniqueId}`;
|
|
119
|
+
const edgeGradientId = `${edgeMaskId}-gradient`;
|
|
120
|
+
const isPatternFill = fill.startsWith("url(");
|
|
121
|
+
const showAreaFill = isPatternFill || fillOpacity > 0;
|
|
122
|
+
const areaFill = isPatternFill ? fill : `url(#${gradientId})`;
|
|
123
|
+
const resolvedStroke = stroke || (isPatternFill ? chartCssVars.linePrimary : fill);
|
|
124
|
+
const getY = useCallback(
|
|
125
|
+
(d) => {
|
|
126
|
+
const value = d[dataKey];
|
|
127
|
+
return typeof value === "number" ? yScale(value) ?? 0 : 0;
|
|
128
|
+
},
|
|
129
|
+
[dataKey, yScale]
|
|
130
|
+
);
|
|
131
|
+
const fadeSides = resolveFadeSides(fadeEdges);
|
|
132
|
+
const useViewportEdgeFade = fadeSides.any && !isPatternFill;
|
|
133
|
+
let strokePaint = resolvedStroke;
|
|
134
|
+
if (!useViewportEdgeFade && fadeSides.any) {
|
|
135
|
+
strokePaint = `url(#${strokeGradientId})`;
|
|
136
|
+
}
|
|
137
|
+
const highlightEnabled = showHighlight && showLine && !showLoadingPulse && showSeriesContent;
|
|
138
|
+
const showSeriesStroke = showSeriesContent && showLine;
|
|
139
|
+
let visibleStroke = "transparent";
|
|
140
|
+
if (showSeriesStroke && !hasDashTail) {
|
|
141
|
+
visibleStroke = strokePaint;
|
|
142
|
+
}
|
|
143
|
+
const shouldMeasurePath = showLine && (showSeriesContent || showLoadingPulse);
|
|
144
|
+
const showFill = showSeriesContent && showAreaFill;
|
|
145
|
+
const getX = useCallback(
|
|
146
|
+
(d) => xScale(xAccessor(d)) ?? 0,
|
|
147
|
+
[xAccessor, xScale]
|
|
148
|
+
);
|
|
149
|
+
const areaPathD = useMemo(
|
|
150
|
+
() => showFill ? areaClosedD(renderData, { curve, x: getX, y: getY, yScale }) : "",
|
|
151
|
+
[curve, getX, getY, renderData, showFill, yScale]
|
|
152
|
+
);
|
|
153
|
+
const strokePathD = useMemo(
|
|
154
|
+
() => shouldMeasurePath ? linePathD(renderData, { curve, x: getX, y: getY }) : "",
|
|
155
|
+
[curve, getX, getY, renderData, shouldMeasurePath]
|
|
156
|
+
);
|
|
157
|
+
const seriesLayers = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
158
|
+
showFill ? /* @__PURE__ */ jsx("path", { d: areaPathD, fill: areaFill }) : null,
|
|
159
|
+
shouldMeasurePath ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
160
|
+
/* @__PURE__ */ jsx(
|
|
161
|
+
LinePath,
|
|
162
|
+
{
|
|
163
|
+
d: strokePathD,
|
|
164
|
+
innerRef: pathRef,
|
|
165
|
+
stroke: visibleStroke,
|
|
166
|
+
strokeLinecap: "round",
|
|
167
|
+
strokeWidth
|
|
168
|
+
}
|
|
169
|
+
),
|
|
170
|
+
showSeriesStroke && hasDashTail ? /* @__PURE__ */ jsx(
|
|
171
|
+
SeriesDashTailOverlay,
|
|
172
|
+
{
|
|
173
|
+
dashArray,
|
|
174
|
+
dashFromIndex,
|
|
175
|
+
data,
|
|
176
|
+
innerHeight,
|
|
177
|
+
innerWidth,
|
|
178
|
+
pathD,
|
|
179
|
+
pathLength,
|
|
180
|
+
stroke: strokePaint,
|
|
181
|
+
strokeWidth,
|
|
182
|
+
xAccessor,
|
|
183
|
+
xScale
|
|
184
|
+
}
|
|
185
|
+
) : null
|
|
186
|
+
] }) : null
|
|
187
|
+
] });
|
|
188
|
+
const sweepLoading = showLoadingPulse && innerWidth > 0 && loadingStyle === "sweep";
|
|
189
|
+
const pulseLoading = showLoadingPulse && innerWidth > 0 && !sweepLoading;
|
|
190
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
191
|
+
/* @__PURE__ */ jsx(
|
|
192
|
+
AreaGradientDefs,
|
|
193
|
+
{
|
|
194
|
+
edgeGradientId,
|
|
195
|
+
edgeMaskId,
|
|
196
|
+
fadeBottom,
|
|
197
|
+
fadeEdges,
|
|
198
|
+
fill,
|
|
199
|
+
fillOpacity,
|
|
200
|
+
gradientId,
|
|
201
|
+
gradientSpan,
|
|
202
|
+
gradientToOpacity,
|
|
203
|
+
innerHeight,
|
|
204
|
+
innerWidth,
|
|
205
|
+
isPatternFill,
|
|
206
|
+
resolvedStroke,
|
|
207
|
+
strokeGradientId
|
|
208
|
+
}
|
|
209
|
+
),
|
|
210
|
+
/* @__PURE__ */ jsx(
|
|
211
|
+
SeriesHoverDim,
|
|
212
|
+
{
|
|
213
|
+
dimOpacity: 0.6,
|
|
214
|
+
enabled: showHighlight,
|
|
215
|
+
seriesIndex,
|
|
216
|
+
children: useViewportEdgeFade ? /* @__PURE__ */ jsx("g", { mask: `url(#${edgeMaskId})`, children: seriesLayers }) : seriesLayers
|
|
217
|
+
}
|
|
218
|
+
),
|
|
219
|
+
/* @__PURE__ */ jsx(
|
|
220
|
+
SeriesHighlightLayer,
|
|
221
|
+
{
|
|
222
|
+
enabled: highlightEnabled,
|
|
223
|
+
height: innerHeight,
|
|
224
|
+
pathRef,
|
|
225
|
+
stroke: resolvedStroke,
|
|
226
|
+
strokeWidth
|
|
227
|
+
}
|
|
228
|
+
),
|
|
229
|
+
showMarkers && showSeriesContent ? /* @__PURE__ */ jsx(
|
|
230
|
+
SeriesMarkers,
|
|
231
|
+
{
|
|
232
|
+
animate,
|
|
233
|
+
dataKey,
|
|
234
|
+
...markers,
|
|
235
|
+
fill: markers?.fill ?? resolvedStroke,
|
|
236
|
+
stroke: markers?.stroke ?? markers?.fill ?? resolvedStroke
|
|
237
|
+
}
|
|
238
|
+
) : null,
|
|
239
|
+
sweepLoading ? /* @__PURE__ */ jsx(
|
|
240
|
+
LineLoadingSweep,
|
|
241
|
+
{
|
|
242
|
+
curve,
|
|
243
|
+
mode: pulseMode ?? "loop",
|
|
244
|
+
onTransitionComplete: handleLoadingPulseComplete,
|
|
245
|
+
stroke: loadingStroke,
|
|
246
|
+
strokeOpacity: loadingStrokeOpacity,
|
|
247
|
+
strokeWidth,
|
|
248
|
+
withArea: true
|
|
249
|
+
},
|
|
250
|
+
"loading-sweep"
|
|
251
|
+
) : null,
|
|
252
|
+
pulseLoading && pathD ? /* @__PURE__ */ jsx(
|
|
253
|
+
LineLoadingPulseStroke,
|
|
254
|
+
{
|
|
255
|
+
loopEpoch: pulseEpoch,
|
|
256
|
+
mode: pulseMode ?? void 0,
|
|
257
|
+
onCycleComplete: handleLoadingPulseComplete,
|
|
258
|
+
pathD,
|
|
259
|
+
stroke: loadingStroke,
|
|
260
|
+
strokeOpacity: loadingStrokeOpacity,
|
|
261
|
+
strokeWidth
|
|
262
|
+
},
|
|
263
|
+
"loading-pulse"
|
|
264
|
+
) : null
|
|
265
|
+
] });
|
|
266
|
+
}
|
|
267
|
+
Area.displayName = "Area";
|
|
268
|
+
var area_default = Area;
|
|
269
|
+
export {
|
|
270
|
+
Area,
|
|
271
|
+
area_default as default
|
|
272
|
+
};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { m } from "motion/react";
|
|
4
|
+
import { useId, useMemo } from "react";
|
|
5
|
+
import { useChartStable } from "./chart-context";
|
|
6
|
+
import {
|
|
7
|
+
renderPatternPreset
|
|
8
|
+
} from "./pattern-preset";
|
|
9
|
+
const BACKGROUND_ENTER_FADE_MS = 420;
|
|
10
|
+
function clampFadeLength(length) {
|
|
11
|
+
return Math.min(45, Math.max(0, length));
|
|
12
|
+
}
|
|
13
|
+
function fadeMaskStops(lengthPercent) {
|
|
14
|
+
const edge = clampFadeLength(lengthPercent);
|
|
15
|
+
return [
|
|
16
|
+
{ offset: "0%", opacity: 0 },
|
|
17
|
+
{ offset: `${edge}%`, opacity: 1 },
|
|
18
|
+
{ offset: `${100 - edge}%`, opacity: 1 },
|
|
19
|
+
{ offset: "100%", opacity: 0 }
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
function Background(props) {
|
|
23
|
+
const { innerWidth, innerHeight, isLoaded, enterTransition } = useChartStable();
|
|
24
|
+
return /* @__PURE__ */ jsx(
|
|
25
|
+
BackgroundPatternLayer,
|
|
26
|
+
{
|
|
27
|
+
...props,
|
|
28
|
+
enterTransition,
|
|
29
|
+
height: innerHeight,
|
|
30
|
+
isLoaded,
|
|
31
|
+
width: innerWidth
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
Background.displayName = "Background";
|
|
36
|
+
function BackgroundPatternLayer({
|
|
37
|
+
pattern = "diagonal-up",
|
|
38
|
+
color = "var(--chart-grid)",
|
|
39
|
+
scale = 1,
|
|
40
|
+
strokeWidth,
|
|
41
|
+
radius,
|
|
42
|
+
complement,
|
|
43
|
+
fill,
|
|
44
|
+
dotFill,
|
|
45
|
+
tileBackground,
|
|
46
|
+
showFill = true,
|
|
47
|
+
opacity = 1,
|
|
48
|
+
fadeHorizontal = true,
|
|
49
|
+
fadeVertical = true,
|
|
50
|
+
fadeHorizontalLength = 10,
|
|
51
|
+
fadeVerticalLength = 10,
|
|
52
|
+
width: innerWidth,
|
|
53
|
+
height: innerHeight,
|
|
54
|
+
isLoaded,
|
|
55
|
+
enterTransition
|
|
56
|
+
}) {
|
|
57
|
+
const uniqueId = useId();
|
|
58
|
+
const patternId = `chart-background-${uniqueId.replace(/:/g, "")}`;
|
|
59
|
+
const hStops = useMemo(
|
|
60
|
+
() => fadeMaskStops(fadeHorizontalLength),
|
|
61
|
+
[fadeHorizontalLength]
|
|
62
|
+
);
|
|
63
|
+
const vStops = useMemo(
|
|
64
|
+
() => fadeMaskStops(fadeVerticalLength),
|
|
65
|
+
[fadeVerticalLength]
|
|
66
|
+
);
|
|
67
|
+
if (pattern === "none" || !showFill || innerWidth <= 0 || innerHeight <= 0) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
const patternNode = renderPatternPreset(pattern, patternId, {
|
|
71
|
+
color,
|
|
72
|
+
scale,
|
|
73
|
+
strokeWidth,
|
|
74
|
+
radius,
|
|
75
|
+
complement,
|
|
76
|
+
fill,
|
|
77
|
+
dotFill,
|
|
78
|
+
tileBackground
|
|
79
|
+
});
|
|
80
|
+
if (!patternNode) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const fadeMask = fadeHorizontal || fadeVertical;
|
|
84
|
+
const hMaskId = `chart-background-fade-h-${uniqueId.replace(/:/g, "")}`;
|
|
85
|
+
const hGradientId = `${hMaskId}-gradient`;
|
|
86
|
+
const vMaskId = `chart-background-fade-v-${uniqueId.replace(/:/g, "")}`;
|
|
87
|
+
const vGradientId = `${vMaskId}-gradient`;
|
|
88
|
+
const combinedMaskId = `chart-background-fade-${uniqueId.replace(/:/g, "")}`;
|
|
89
|
+
let maskRef;
|
|
90
|
+
if (fadeHorizontal && fadeVertical) {
|
|
91
|
+
maskRef = `url(#${combinedMaskId})`;
|
|
92
|
+
} else if (fadeHorizontal) {
|
|
93
|
+
maskRef = `url(#${hMaskId})`;
|
|
94
|
+
} else if (fadeVertical) {
|
|
95
|
+
maskRef = `url(#${vMaskId})`;
|
|
96
|
+
}
|
|
97
|
+
const targetOpacity = opacity;
|
|
98
|
+
const revealOpacity = isLoaded ? targetOpacity : 0;
|
|
99
|
+
const enterFade = enterTransition && typeof enterTransition === "object" ? enterTransition : { duration: BACKGROUND_ENTER_FADE_MS / 1e3, ease: "easeOut" };
|
|
100
|
+
return (
|
|
101
|
+
// biome-ignore lint/a11y/noAriaHiddenOnFocusable: decorative plot-area pattern layer
|
|
102
|
+
/* @__PURE__ */ jsxs("g", { "aria-hidden": "true", className: "chart-background", children: [
|
|
103
|
+
fadeMask ? /* @__PURE__ */ jsxs("defs", { children: [
|
|
104
|
+
fadeHorizontal ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
105
|
+
/* @__PURE__ */ jsx(
|
|
106
|
+
"linearGradient",
|
|
107
|
+
{
|
|
108
|
+
id: hGradientId,
|
|
109
|
+
x1: "0%",
|
|
110
|
+
x2: "100%",
|
|
111
|
+
y1: "0%",
|
|
112
|
+
y2: "0%",
|
|
113
|
+
children: hStops.map((stop) => /* @__PURE__ */ jsx(
|
|
114
|
+
"stop",
|
|
115
|
+
{
|
|
116
|
+
offset: stop.offset,
|
|
117
|
+
style: { stopColor: "white", stopOpacity: stop.opacity }
|
|
118
|
+
},
|
|
119
|
+
stop.offset
|
|
120
|
+
))
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
/* @__PURE__ */ jsx("mask", { id: hMaskId, children: /* @__PURE__ */ jsx(
|
|
124
|
+
"rect",
|
|
125
|
+
{
|
|
126
|
+
fill: `url(#${hGradientId})`,
|
|
127
|
+
height: innerHeight,
|
|
128
|
+
width: innerWidth,
|
|
129
|
+
x: 0,
|
|
130
|
+
y: 0
|
|
131
|
+
}
|
|
132
|
+
) })
|
|
133
|
+
] }) : null,
|
|
134
|
+
fadeVertical ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
135
|
+
/* @__PURE__ */ jsx(
|
|
136
|
+
"linearGradient",
|
|
137
|
+
{
|
|
138
|
+
id: vGradientId,
|
|
139
|
+
x1: "0%",
|
|
140
|
+
x2: "0%",
|
|
141
|
+
y1: "0%",
|
|
142
|
+
y2: "100%",
|
|
143
|
+
children: vStops.map((stop) => /* @__PURE__ */ jsx(
|
|
144
|
+
"stop",
|
|
145
|
+
{
|
|
146
|
+
offset: stop.offset,
|
|
147
|
+
style: { stopColor: "white", stopOpacity: stop.opacity }
|
|
148
|
+
},
|
|
149
|
+
stop.offset
|
|
150
|
+
))
|
|
151
|
+
}
|
|
152
|
+
),
|
|
153
|
+
/* @__PURE__ */ jsx("mask", { id: vMaskId, children: /* @__PURE__ */ jsx(
|
|
154
|
+
"rect",
|
|
155
|
+
{
|
|
156
|
+
fill: `url(#${vGradientId})`,
|
|
157
|
+
height: innerHeight,
|
|
158
|
+
width: innerWidth,
|
|
159
|
+
x: 0,
|
|
160
|
+
y: 0
|
|
161
|
+
}
|
|
162
|
+
) })
|
|
163
|
+
] }) : null,
|
|
164
|
+
fadeHorizontal && fadeVertical ? /* @__PURE__ */ jsx("mask", { id: combinedMaskId, children: /* @__PURE__ */ jsx("g", { mask: `url(#${hMaskId})`, children: /* @__PURE__ */ jsx(
|
|
165
|
+
"rect",
|
|
166
|
+
{
|
|
167
|
+
fill: `url(#${vGradientId})`,
|
|
168
|
+
height: innerHeight,
|
|
169
|
+
width: innerWidth,
|
|
170
|
+
x: 0,
|
|
171
|
+
y: 0
|
|
172
|
+
}
|
|
173
|
+
) }) }) : null
|
|
174
|
+
] }) : null,
|
|
175
|
+
/* @__PURE__ */ jsx("defs", { children: patternNode }),
|
|
176
|
+
/* @__PURE__ */ jsx(
|
|
177
|
+
m.rect,
|
|
178
|
+
{
|
|
179
|
+
animate: { opacity: revealOpacity },
|
|
180
|
+
fill: `url(#${patternId})`,
|
|
181
|
+
height: innerHeight,
|
|
182
|
+
initial: { opacity: 0 },
|
|
183
|
+
mask: maskRef,
|
|
184
|
+
transition: isLoaded ? enterFade : { duration: 0 },
|
|
185
|
+
width: innerWidth,
|
|
186
|
+
x: 0,
|
|
187
|
+
y: 0
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
] })
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
var background_default = Background;
|
|
194
|
+
export {
|
|
195
|
+
Background,
|
|
196
|
+
BackgroundPatternLayer,
|
|
197
|
+
background_default as default
|
|
198
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
Fragment,
|
|
4
|
+
isValidElement
|
|
5
|
+
} from "react";
|
|
6
|
+
import { isChartClipPassthrough } from "./chart-child-passthrough";
|
|
7
|
+
import { normalizeYAxisId } from "./y-axis-scales";
|
|
8
|
+
const DEFAULT_BAND_FILL = "var(--chart-line-primary)";
|
|
9
|
+
function defaultBandLabel(upperKey, lowerKey) {
|
|
10
|
+
return upperKey === lowerKey ? upperKey : `${lowerKey} \u2013 ${upperKey}`;
|
|
11
|
+
}
|
|
12
|
+
function nonEmptyString(value) {
|
|
13
|
+
return typeof value === "string" && value.length > 0;
|
|
14
|
+
}
|
|
15
|
+
function bandConfigFromProps(props) {
|
|
16
|
+
if (!(nonEmptyString(props?.upperKey) && nonEmptyString(props.lowerKey))) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
yAxisId: normalizeYAxisId(props.yAxisId),
|
|
21
|
+
upperKey: props.upperKey,
|
|
22
|
+
lowerKey: props.lowerKey,
|
|
23
|
+
color: nonEmptyString(props.fill) ? props.fill : DEFAULT_BAND_FILL,
|
|
24
|
+
label: nonEmptyString(props.label) ? props.label : defaultBandLabel(props.upperKey, props.lowerKey),
|
|
25
|
+
showInTooltip: props.showInTooltip !== false
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function getChildComponentName(child) {
|
|
29
|
+
const childType = child.type;
|
|
30
|
+
return typeof child.type === "function" ? childType.displayName || childType.name || "" : "";
|
|
31
|
+
}
|
|
32
|
+
function extractBandConfigs(children) {
|
|
33
|
+
const configs = [];
|
|
34
|
+
const visit = (node) => {
|
|
35
|
+
Children.forEach(node, (child) => {
|
|
36
|
+
if (!isValidElement(child)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (child.type === Fragment) {
|
|
40
|
+
visit(child.props.children);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (getChildComponentName(child) === "Band") {
|
|
44
|
+
const config = bandConfigFromProps(
|
|
45
|
+
child.props
|
|
46
|
+
);
|
|
47
|
+
if (config) {
|
|
48
|
+
configs.push(config);
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (isChartClipPassthrough(child.type)) {
|
|
53
|
+
visit(child.props.children);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const childProps = child.props;
|
|
57
|
+
if (childProps?.children) {
|
|
58
|
+
visit(childProps.children);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
visit(children);
|
|
63
|
+
return configs;
|
|
64
|
+
}
|
|
65
|
+
function bandKeysByAxis(configs) {
|
|
66
|
+
const byAxis = {};
|
|
67
|
+
for (const config of configs) {
|
|
68
|
+
const keys = byAxis[config.yAxisId] ?? [];
|
|
69
|
+
for (const key of [config.upperKey, config.lowerKey]) {
|
|
70
|
+
if (!keys.includes(key)) {
|
|
71
|
+
keys.push(key);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
byAxis[config.yAxisId] = keys;
|
|
75
|
+
}
|
|
76
|
+
return byAxis;
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
bandKeysByAxis,
|
|
80
|
+
defaultBandLabel,
|
|
81
|
+
extractBandConfigs
|
|
82
|
+
};
|