@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,186 @@
|
|
|
1
|
+
import { area as d3Area, line as d3Line } from "d3-shape";
|
|
2
|
+
import {
|
|
3
|
+
flattenSeriesPath,
|
|
4
|
+
interpolateSeriesPathPoints,
|
|
5
|
+
samplePolylineY
|
|
6
|
+
} from "./series-path-utils";
|
|
7
|
+
function finiteNumber(value) {
|
|
8
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
9
|
+
}
|
|
10
|
+
function computeBandSegments(data, xAccessor, xScale, yScale, upperKey, lowerKey) {
|
|
11
|
+
const segments = [];
|
|
12
|
+
let current = [];
|
|
13
|
+
data.forEach((datum, index) => {
|
|
14
|
+
const upper = datum[upperKey];
|
|
15
|
+
const lower = datum[lowerKey];
|
|
16
|
+
if (!(finiteNumber(upper) && finiteNumber(lower))) {
|
|
17
|
+
if (current.length > 0) {
|
|
18
|
+
segments.push(current);
|
|
19
|
+
current = [];
|
|
20
|
+
}
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const xValue = xAccessor(datum);
|
|
24
|
+
current.push({
|
|
25
|
+
x: xScale(xValue) ?? 0,
|
|
26
|
+
upper: yScale(upper) ?? 0,
|
|
27
|
+
lower: yScale(lower) ?? 0,
|
|
28
|
+
key: String(xValue.getTime?.() ?? index)
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
if (current.length > 0) {
|
|
32
|
+
segments.push(current);
|
|
33
|
+
}
|
|
34
|
+
return segments;
|
|
35
|
+
}
|
|
36
|
+
function edgePoints(segment, edge) {
|
|
37
|
+
return segment.map((point) => ({
|
|
38
|
+
x: point.x,
|
|
39
|
+
y: point[edge],
|
|
40
|
+
key: point.key
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
function bandAreaPath(segments, curve) {
|
|
44
|
+
const generator = d3Area().x((point) => point.x).y0((point) => point.lower).y1((point) => point.upper).curve(curve);
|
|
45
|
+
return segments.filter((segment) => segment.length > 1).map((segment) => generator(segment) ?? "").join("");
|
|
46
|
+
}
|
|
47
|
+
function bandEdgePath(segments, edge, curve) {
|
|
48
|
+
const generator = d3Line().x((point) => point.x).y((point) => point[edge]).curve(curve);
|
|
49
|
+
return segments.filter((segment) => segment.length > 1).map((segment) => generator(segment) ?? "").join("");
|
|
50
|
+
}
|
|
51
|
+
function bandEdgeClipPath(segments, edge, side, curve, far) {
|
|
52
|
+
const generator = d3Line().x((point) => point.x).y((point) => point[edge]).curve(curve);
|
|
53
|
+
const y = side === "above" ? -far : far;
|
|
54
|
+
return segments.filter((segment) => segment.length > 1).map((segment) => {
|
|
55
|
+
const path = generator(segment);
|
|
56
|
+
const first = segment[0];
|
|
57
|
+
const last = segment.at(-1);
|
|
58
|
+
if (!(path && first && last)) {
|
|
59
|
+
return "";
|
|
60
|
+
}
|
|
61
|
+
return `${path}L${last.x},${y}L${first.x},${y}Z`;
|
|
62
|
+
}).join("");
|
|
63
|
+
}
|
|
64
|
+
function bandPixelExtent(segments) {
|
|
65
|
+
let top = Number.POSITIVE_INFINITY;
|
|
66
|
+
let bottom = Number.NEGATIVE_INFINITY;
|
|
67
|
+
for (const segment of segments) {
|
|
68
|
+
for (const point of segment) {
|
|
69
|
+
top = Math.min(top, point.upper, point.lower);
|
|
70
|
+
bottom = Math.max(bottom, point.upper, point.lower);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return Number.isFinite(top) ? { top, bottom } : null;
|
|
74
|
+
}
|
|
75
|
+
function flattenBandEdges(segments, curve, alreadyPolyline) {
|
|
76
|
+
const flatten = (edge) => segments.flatMap((segment) => {
|
|
77
|
+
const points = edgePoints(segment, edge);
|
|
78
|
+
return alreadyPolyline ? points : flattenSeriesPath(points, curve);
|
|
79
|
+
}).sort((a, b) => a.x - b.x);
|
|
80
|
+
return { upper: flatten("upper"), lower: flatten("lower") };
|
|
81
|
+
}
|
|
82
|
+
function morphBandSegments(from, targets, curve, progress, sampleSpacingPx = 2) {
|
|
83
|
+
if (from.upper.length === 0 || from.lower.length === 0) {
|
|
84
|
+
return targets;
|
|
85
|
+
}
|
|
86
|
+
return targets.map((segment) => {
|
|
87
|
+
const first = segment[0];
|
|
88
|
+
const last = segment.at(-1);
|
|
89
|
+
if (!(first && last) || segment.length < 2) {
|
|
90
|
+
return segment;
|
|
91
|
+
}
|
|
92
|
+
const toUpper = flattenSeriesPath(edgePoints(segment, "upper"), curve);
|
|
93
|
+
const toLower = flattenSeriesPath(edgePoints(segment, "lower"), curve);
|
|
94
|
+
const span = last.x - first.x;
|
|
95
|
+
const count = Math.max(2, Math.ceil(span / sampleSpacingPx) + 1);
|
|
96
|
+
const result = new Array(count);
|
|
97
|
+
for (let index = 0; index < count; index++) {
|
|
98
|
+
const x = first.x + span * index / (count - 1);
|
|
99
|
+
const fromUpper = samplePolylineY(from.upper, x);
|
|
100
|
+
const fromLower = samplePolylineY(from.lower, x);
|
|
101
|
+
result[index] = {
|
|
102
|
+
x,
|
|
103
|
+
upper: fromUpper + (samplePolylineY(toUpper, x) - fromUpper) * progress,
|
|
104
|
+
lower: fromLower + (samplePolylineY(toLower, x) - fromLower) * progress,
|
|
105
|
+
key: ""
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
return result;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function interpolateBandSegments(from, targets, progress) {
|
|
112
|
+
if (progress >= 1 || from.length === 0) {
|
|
113
|
+
return targets;
|
|
114
|
+
}
|
|
115
|
+
const fromUpper = from.flatMap((segment) => edgePoints(segment, "upper"));
|
|
116
|
+
const fromLower = from.flatMap((segment) => edgePoints(segment, "lower"));
|
|
117
|
+
return targets.map((segment) => {
|
|
118
|
+
const upper = interpolateSeriesPathPoints(
|
|
119
|
+
fromUpper,
|
|
120
|
+
edgePoints(segment, "upper"),
|
|
121
|
+
progress
|
|
122
|
+
);
|
|
123
|
+
const lower = interpolateSeriesPathPoints(
|
|
124
|
+
fromLower,
|
|
125
|
+
edgePoints(segment, "lower"),
|
|
126
|
+
progress
|
|
127
|
+
);
|
|
128
|
+
return upper.map((point, index) => ({
|
|
129
|
+
x: point.x,
|
|
130
|
+
upper: point.y,
|
|
131
|
+
lower: lower[index]?.y ?? point.y,
|
|
132
|
+
key: point.key
|
|
133
|
+
}));
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function bandDataSignature(renderData, xAccessor, upperKey, lowerKey) {
|
|
137
|
+
return renderData.map((datum) => {
|
|
138
|
+
const upper = datum[upperKey];
|
|
139
|
+
const lower = datum[lowerKey];
|
|
140
|
+
return `${xAccessor(datum).getTime()}:${finiteNumber(upper) ? upper : ""}:${finiteNumber(lower) ? lower : ""}`;
|
|
141
|
+
}).join(",");
|
|
142
|
+
}
|
|
143
|
+
function resolveBandFadeSides(fade) {
|
|
144
|
+
let sides = { top: false, right: false, bottom: false, left: false };
|
|
145
|
+
if (fade === true) {
|
|
146
|
+
sides = { top: true, right: true, bottom: true, left: true };
|
|
147
|
+
} else if (fade === "left") {
|
|
148
|
+
sides.left = true;
|
|
149
|
+
} else if (fade === "right") {
|
|
150
|
+
sides.right = true;
|
|
151
|
+
} else if (fade && typeof fade === "object") {
|
|
152
|
+
sides = {
|
|
153
|
+
top: fade.top === true,
|
|
154
|
+
right: fade.right === true,
|
|
155
|
+
bottom: fade.bottom === true,
|
|
156
|
+
left: fade.left === true
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
...sides,
|
|
161
|
+
horizontal: sides.left || sides.right,
|
|
162
|
+
vertical: sides.top || sides.bottom
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function bandFadeStops(startFaded, endFaded, size) {
|
|
166
|
+
const span = Math.min(0.5, Math.max(0, size));
|
|
167
|
+
return [
|
|
168
|
+
{ offset: 0, opacity: startFaded ? 0 : 1 },
|
|
169
|
+
{ offset: span, opacity: 1 },
|
|
170
|
+
{ offset: 1 - span, opacity: 1 },
|
|
171
|
+
{ offset: 1, opacity: endFaded ? 0 : 1 }
|
|
172
|
+
];
|
|
173
|
+
}
|
|
174
|
+
export {
|
|
175
|
+
bandAreaPath,
|
|
176
|
+
bandDataSignature,
|
|
177
|
+
bandEdgeClipPath,
|
|
178
|
+
bandEdgePath,
|
|
179
|
+
bandFadeStops,
|
|
180
|
+
bandPixelExtent,
|
|
181
|
+
computeBandSegments,
|
|
182
|
+
flattenBandEdges,
|
|
183
|
+
interpolateBandSegments,
|
|
184
|
+
morphBandSegments,
|
|
185
|
+
resolveBandFadeSides
|
|
186
|
+
};
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { curveLinear, curveNatural } from "d3-shape";
|
|
4
|
+
import { useId, useMemo } from "react";
|
|
5
|
+
import {
|
|
6
|
+
bandAreaPath,
|
|
7
|
+
bandEdgeClipPath,
|
|
8
|
+
bandEdgePath,
|
|
9
|
+
bandFadeStops,
|
|
10
|
+
bandPixelExtent,
|
|
11
|
+
resolveBandFadeSides
|
|
12
|
+
} from "./band-geometry";
|
|
13
|
+
import { chartCssVars, useChartStable, useYScale } from "./chart-context";
|
|
14
|
+
import { renderPatternPreset } from "./pattern-preset";
|
|
15
|
+
import { useAnimatedBand } from "./use-animated-band";
|
|
16
|
+
function resolveEdgeStroke(override, base) {
|
|
17
|
+
if (override === false) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const resolved = {
|
|
21
|
+
stroke: override?.stroke ?? base.stroke,
|
|
22
|
+
strokeWidth: override?.strokeWidth ?? base.strokeWidth,
|
|
23
|
+
strokeDasharray: override?.strokeDasharray ?? base.strokeDasharray,
|
|
24
|
+
strokeOpacity: override?.strokeOpacity ?? base.strokeOpacity
|
|
25
|
+
};
|
|
26
|
+
return resolved.strokeWidth > 0 ? resolved : null;
|
|
27
|
+
}
|
|
28
|
+
function FadeMaskStops({ stops }) {
|
|
29
|
+
return stops.map((stop, index) => /* @__PURE__ */ jsx(
|
|
30
|
+
"stop",
|
|
31
|
+
{
|
|
32
|
+
offset: stop.offset,
|
|
33
|
+
style: { stopColor: "white", stopOpacity: stop.opacity }
|
|
34
|
+
},
|
|
35
|
+
index
|
|
36
|
+
));
|
|
37
|
+
}
|
|
38
|
+
function BandAreaFill({
|
|
39
|
+
d,
|
|
40
|
+
color,
|
|
41
|
+
clipPath,
|
|
42
|
+
style
|
|
43
|
+
}) {
|
|
44
|
+
const uniqueId = useId().replace(/:/g, "");
|
|
45
|
+
const paintId = `chart-band-paint-${uniqueId}`;
|
|
46
|
+
const { extent } = style;
|
|
47
|
+
const usesPattern = style.fillType === "pattern" && style.pattern !== "none";
|
|
48
|
+
const usesGradient = style.fillType === "gradient" && extent != null;
|
|
49
|
+
let paint = null;
|
|
50
|
+
let fill = color;
|
|
51
|
+
let opacity = style.fillOpacity;
|
|
52
|
+
if (usesPattern) {
|
|
53
|
+
paint = renderPatternPreset(style.pattern, paintId, {
|
|
54
|
+
color: style.patternColor ?? color,
|
|
55
|
+
scale: style.patternScale,
|
|
56
|
+
strokeWidth: style.patternStrokeWidth
|
|
57
|
+
});
|
|
58
|
+
fill = `url(#${paintId})`;
|
|
59
|
+
opacity = style.patternOpacity;
|
|
60
|
+
} else if (usesGradient) {
|
|
61
|
+
paint = /* @__PURE__ */ jsxs(
|
|
62
|
+
"linearGradient",
|
|
63
|
+
{
|
|
64
|
+
gradientUnits: "userSpaceOnUse",
|
|
65
|
+
id: paintId,
|
|
66
|
+
x1: 0,
|
|
67
|
+
x2: 0,
|
|
68
|
+
y1: extent.top,
|
|
69
|
+
y2: extent.bottom,
|
|
70
|
+
children: [
|
|
71
|
+
/* @__PURE__ */ jsx(
|
|
72
|
+
"stop",
|
|
73
|
+
{
|
|
74
|
+
offset: 0,
|
|
75
|
+
style: { stopColor: color, stopOpacity: style.fillOpacity }
|
|
76
|
+
}
|
|
77
|
+
),
|
|
78
|
+
/* @__PURE__ */ jsx(
|
|
79
|
+
"stop",
|
|
80
|
+
{
|
|
81
|
+
offset: 1,
|
|
82
|
+
style: { stopColor: color, stopOpacity: style.gradientToOpacity }
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
fill = `url(#${paintId})`;
|
|
89
|
+
opacity = 1;
|
|
90
|
+
}
|
|
91
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
92
|
+
paint ? /* @__PURE__ */ jsx("defs", { children: paint }) : null,
|
|
93
|
+
/* @__PURE__ */ jsx("path", { clipPath, d, fill, fillOpacity: opacity })
|
|
94
|
+
] });
|
|
95
|
+
}
|
|
96
|
+
function BandSplitFill({
|
|
97
|
+
d,
|
|
98
|
+
fill,
|
|
99
|
+
negativeFill,
|
|
100
|
+
segments,
|
|
101
|
+
curve,
|
|
102
|
+
innerHeight,
|
|
103
|
+
style
|
|
104
|
+
}) {
|
|
105
|
+
const uniqueId = useId().replace(/:/g, "");
|
|
106
|
+
const aboveId = `chart-band-above-${uniqueId}`;
|
|
107
|
+
const belowId = `chart-band-below-${uniqueId}`;
|
|
108
|
+
const clips = useMemo(() => {
|
|
109
|
+
const far = Math.max(innerHeight, 1) * 3;
|
|
110
|
+
return {
|
|
111
|
+
above: bandEdgeClipPath(segments, "lower", "above", curve, far),
|
|
112
|
+
below: bandEdgeClipPath(segments, "lower", "below", curve, far)
|
|
113
|
+
};
|
|
114
|
+
}, [segments, curve, innerHeight]);
|
|
115
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
116
|
+
/* @__PURE__ */ jsxs("defs", { children: [
|
|
117
|
+
/* @__PURE__ */ jsx("clipPath", { id: aboveId, children: /* @__PURE__ */ jsx("path", { d: clips.above }) }),
|
|
118
|
+
/* @__PURE__ */ jsx("clipPath", { id: belowId, children: /* @__PURE__ */ jsx("path", { d: clips.below }) })
|
|
119
|
+
] }),
|
|
120
|
+
/* @__PURE__ */ jsx(
|
|
121
|
+
BandAreaFill,
|
|
122
|
+
{
|
|
123
|
+
clipPath: `url(#${aboveId})`,
|
|
124
|
+
color: fill,
|
|
125
|
+
d,
|
|
126
|
+
style
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
/* @__PURE__ */ jsx(
|
|
130
|
+
BandAreaFill,
|
|
131
|
+
{
|
|
132
|
+
clipPath: `url(#${belowId})`,
|
|
133
|
+
color: negativeFill,
|
|
134
|
+
d,
|
|
135
|
+
style: { ...style, patternColor: void 0 }
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
] });
|
|
139
|
+
}
|
|
140
|
+
function isBandVisiblePhase(phase) {
|
|
141
|
+
return phase === "revealing" || phase === "ready" || phase === "exitingReady";
|
|
142
|
+
}
|
|
143
|
+
function Band({
|
|
144
|
+
upperKey,
|
|
145
|
+
lowerKey,
|
|
146
|
+
yAxisId,
|
|
147
|
+
// `label` / `showInTooltip` are read from props by the chart shell
|
|
148
|
+
// (`extractBandConfigs`) for tooltip rows.
|
|
149
|
+
curve = curveNatural,
|
|
150
|
+
fill = chartCssVars.linePrimary,
|
|
151
|
+
fillType = "solid",
|
|
152
|
+
fillOpacity = 0.15,
|
|
153
|
+
negativeFill,
|
|
154
|
+
gradientToOpacity = 0,
|
|
155
|
+
pattern = "diagonal-up",
|
|
156
|
+
patternColor,
|
|
157
|
+
patternScale,
|
|
158
|
+
patternStrokeWidth,
|
|
159
|
+
patternOpacity = 1,
|
|
160
|
+
stroke,
|
|
161
|
+
strokeWidth = 1,
|
|
162
|
+
strokeDasharray,
|
|
163
|
+
strokeOpacity = 1,
|
|
164
|
+
upperStroke,
|
|
165
|
+
lowerStroke,
|
|
166
|
+
fadeEdges = false,
|
|
167
|
+
fadeSize = 0.15,
|
|
168
|
+
className
|
|
169
|
+
}) {
|
|
170
|
+
const {
|
|
171
|
+
renderData,
|
|
172
|
+
xScale,
|
|
173
|
+
innerWidth,
|
|
174
|
+
innerHeight,
|
|
175
|
+
xAccessor,
|
|
176
|
+
chartPhase,
|
|
177
|
+
yDomainTweenDuration
|
|
178
|
+
} = useChartStable();
|
|
179
|
+
const yScale = useYScale(yAxisId);
|
|
180
|
+
const displayed = useAnimatedBand({
|
|
181
|
+
chartPhase,
|
|
182
|
+
curve,
|
|
183
|
+
durationMs: yDomainTweenDuration,
|
|
184
|
+
enabled: chartPhase === "ready",
|
|
185
|
+
innerWidth,
|
|
186
|
+
lowerKey,
|
|
187
|
+
renderData,
|
|
188
|
+
upperKey,
|
|
189
|
+
xAccessor,
|
|
190
|
+
xScale,
|
|
191
|
+
yScale
|
|
192
|
+
});
|
|
193
|
+
const { segments, polyline } = displayed;
|
|
194
|
+
const paths = useMemo(() => {
|
|
195
|
+
const pathCurve = polyline ? curveLinear : curve;
|
|
196
|
+
return {
|
|
197
|
+
area: bandAreaPath(segments, pathCurve),
|
|
198
|
+
upper: bandEdgePath(segments, "upper", pathCurve),
|
|
199
|
+
lower: bandEdgePath(segments, "lower", pathCurve),
|
|
200
|
+
extent: bandPixelExtent(segments)
|
|
201
|
+
};
|
|
202
|
+
}, [segments, polyline, curve]);
|
|
203
|
+
const uniqueId = useId().replace(/:/g, "");
|
|
204
|
+
const hMaskId = `chart-band-fade-x-${uniqueId}`;
|
|
205
|
+
const vMaskId = `chart-band-fade-y-${uniqueId}`;
|
|
206
|
+
if (!isBandVisiblePhase(chartPhase) || paths.area === "") {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
const { extent } = paths;
|
|
210
|
+
const hasExtent = extent != null && extent.bottom - extent.top > 0;
|
|
211
|
+
const fadeSides = resolveBandFadeSides(fadeEdges);
|
|
212
|
+
const fadeX = fadeSides.horizontal && innerWidth > 0;
|
|
213
|
+
const fadeY = fadeSides.vertical && hasExtent;
|
|
214
|
+
const fillStyle = {
|
|
215
|
+
extent: hasExtent ? extent : null,
|
|
216
|
+
fillOpacity,
|
|
217
|
+
fillType,
|
|
218
|
+
gradientToOpacity,
|
|
219
|
+
pattern,
|
|
220
|
+
patternColor,
|
|
221
|
+
patternOpacity,
|
|
222
|
+
patternScale,
|
|
223
|
+
patternStrokeWidth
|
|
224
|
+
};
|
|
225
|
+
const baseStroke = {
|
|
226
|
+
stroke: stroke ?? fill,
|
|
227
|
+
strokeWidth,
|
|
228
|
+
strokeDasharray,
|
|
229
|
+
strokeOpacity
|
|
230
|
+
};
|
|
231
|
+
const upperEdge = resolveEdgeStroke(upperStroke, baseStroke);
|
|
232
|
+
const lowerEdge = resolveEdgeStroke(lowerStroke, baseStroke);
|
|
233
|
+
const maskRegion = {
|
|
234
|
+
height: innerHeight * 3,
|
|
235
|
+
maskUnits: "userSpaceOnUse",
|
|
236
|
+
width: innerWidth * 3,
|
|
237
|
+
x: -innerWidth,
|
|
238
|
+
y: -innerHeight
|
|
239
|
+
};
|
|
240
|
+
const maskRect = {
|
|
241
|
+
height: maskRegion.height,
|
|
242
|
+
width: maskRegion.width,
|
|
243
|
+
x: maskRegion.x,
|
|
244
|
+
y: maskRegion.y
|
|
245
|
+
};
|
|
246
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
247
|
+
negativeFill ? /* @__PURE__ */ jsx(
|
|
248
|
+
BandSplitFill,
|
|
249
|
+
{
|
|
250
|
+
curve: polyline ? curveLinear : curve,
|
|
251
|
+
d: paths.area,
|
|
252
|
+
fill,
|
|
253
|
+
innerHeight,
|
|
254
|
+
negativeFill,
|
|
255
|
+
segments,
|
|
256
|
+
style: fillStyle
|
|
257
|
+
}
|
|
258
|
+
) : /* @__PURE__ */ jsx(BandAreaFill, { color: fill, d: paths.area, style: fillStyle }),
|
|
259
|
+
lowerEdge ? /* @__PURE__ */ jsx(
|
|
260
|
+
"path",
|
|
261
|
+
{
|
|
262
|
+
d: paths.lower,
|
|
263
|
+
fill: "none",
|
|
264
|
+
stroke: lowerEdge.stroke,
|
|
265
|
+
strokeDasharray: lowerEdge.strokeDasharray,
|
|
266
|
+
strokeLinecap: "round",
|
|
267
|
+
strokeOpacity: lowerEdge.strokeOpacity,
|
|
268
|
+
strokeWidth: lowerEdge.strokeWidth
|
|
269
|
+
}
|
|
270
|
+
) : null,
|
|
271
|
+
upperEdge ? /* @__PURE__ */ jsx(
|
|
272
|
+
"path",
|
|
273
|
+
{
|
|
274
|
+
d: paths.upper,
|
|
275
|
+
fill: "none",
|
|
276
|
+
stroke: upperEdge.stroke,
|
|
277
|
+
strokeDasharray: upperEdge.strokeDasharray,
|
|
278
|
+
strokeLinecap: "round",
|
|
279
|
+
strokeOpacity: upperEdge.strokeOpacity,
|
|
280
|
+
strokeWidth: upperEdge.strokeWidth
|
|
281
|
+
}
|
|
282
|
+
) : null
|
|
283
|
+
] });
|
|
284
|
+
return (
|
|
285
|
+
// biome-ignore lint/a11y/noAriaHiddenOnFocusable: decorative band
|
|
286
|
+
/* @__PURE__ */ jsxs(
|
|
287
|
+
"g",
|
|
288
|
+
{
|
|
289
|
+
"aria-hidden": "true",
|
|
290
|
+
className: className ?? "chart-band",
|
|
291
|
+
pointerEvents: "none",
|
|
292
|
+
children: [
|
|
293
|
+
/* @__PURE__ */ jsxs("defs", { children: [
|
|
294
|
+
fadeX ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
295
|
+
/* @__PURE__ */ jsx(
|
|
296
|
+
"linearGradient",
|
|
297
|
+
{
|
|
298
|
+
gradientUnits: "userSpaceOnUse",
|
|
299
|
+
id: `${hMaskId}-gradient`,
|
|
300
|
+
x1: 0,
|
|
301
|
+
x2: innerWidth,
|
|
302
|
+
y1: 0,
|
|
303
|
+
y2: 0,
|
|
304
|
+
children: /* @__PURE__ */ jsx(
|
|
305
|
+
FadeMaskStops,
|
|
306
|
+
{
|
|
307
|
+
stops: bandFadeStops(fadeSides.left, fadeSides.right, fadeSize)
|
|
308
|
+
}
|
|
309
|
+
)
|
|
310
|
+
}
|
|
311
|
+
),
|
|
312
|
+
/* @__PURE__ */ jsx("mask", { id: hMaskId, ...maskRegion, children: /* @__PURE__ */ jsx("rect", { fill: `url(#${hMaskId}-gradient)`, ...maskRect }) })
|
|
313
|
+
] }) : null,
|
|
314
|
+
fadeY && extent ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
315
|
+
/* @__PURE__ */ jsx(
|
|
316
|
+
"linearGradient",
|
|
317
|
+
{
|
|
318
|
+
gradientUnits: "userSpaceOnUse",
|
|
319
|
+
id: `${vMaskId}-gradient`,
|
|
320
|
+
x1: 0,
|
|
321
|
+
x2: 0,
|
|
322
|
+
y1: extent.top,
|
|
323
|
+
y2: extent.bottom,
|
|
324
|
+
children: /* @__PURE__ */ jsx(
|
|
325
|
+
FadeMaskStops,
|
|
326
|
+
{
|
|
327
|
+
stops: bandFadeStops(fadeSides.top, fadeSides.bottom, fadeSize)
|
|
328
|
+
}
|
|
329
|
+
)
|
|
330
|
+
}
|
|
331
|
+
),
|
|
332
|
+
/* @__PURE__ */ jsx("mask", { id: vMaskId, ...maskRegion, children: /* @__PURE__ */ jsx("rect", { fill: `url(#${vMaskId}-gradient)`, ...maskRect }) })
|
|
333
|
+
] }) : null
|
|
334
|
+
] }),
|
|
335
|
+
/* @__PURE__ */ jsx("g", { mask: fadeX ? `url(#${hMaskId})` : void 0, children: /* @__PURE__ */ jsx("g", { mask: fadeY ? `url(#${vMaskId})` : void 0, children: content }) })
|
|
336
|
+
]
|
|
337
|
+
}
|
|
338
|
+
)
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
Band.displayName = "Band";
|
|
342
|
+
var band_default = Band;
|
|
343
|
+
export {
|
|
344
|
+
Band,
|
|
345
|
+
band_default as default
|
|
346
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { BarChart } from "./bar-chart";
|
|
4
|
+
const EMPTY_DATA = [];
|
|
5
|
+
function BarChartLoading({
|
|
6
|
+
margin,
|
|
7
|
+
aspectRatio = "2 / 1",
|
|
8
|
+
className = "",
|
|
9
|
+
loadingFill
|
|
10
|
+
}) {
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
BarChart,
|
|
13
|
+
{
|
|
14
|
+
aspectRatio,
|
|
15
|
+
className,
|
|
16
|
+
data: EMPTY_DATA,
|
|
17
|
+
loadingFill,
|
|
18
|
+
margin,
|
|
19
|
+
status: "loading"
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
var bar_chart_loading_default = BarChartLoading;
|
|
24
|
+
export {
|
|
25
|
+
BarChartLoading,
|
|
26
|
+
bar_chart_loading_default as default
|
|
27
|
+
};
|