@aiconstructions/graficos 0.0.0-stage → 0.2.2
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 +57 -0
- package/LICENSE-BKLIT +21 -0
- package/LICENSE-visx-pattern +21 -0
- package/README.md +189 -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,644 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { domAnimation, LazyMotion } from "motion/react";
|
|
4
|
+
import React, {
|
|
5
|
+
memo,
|
|
6
|
+
useCallback,
|
|
7
|
+
useEffect,
|
|
8
|
+
useId,
|
|
9
|
+
useMemo,
|
|
10
|
+
useRef,
|
|
11
|
+
useState
|
|
12
|
+
} from "react";
|
|
13
|
+
import { cn } from "../../lib/utils";
|
|
14
|
+
import {
|
|
15
|
+
useChartDataOverride
|
|
16
|
+
} from "../chart-data-override";
|
|
17
|
+
import { ParentSize } from "../chart-parent-size";
|
|
18
|
+
import { ChoroplethBackground as ChoroplethBackgroundLayer } from "./choropleth-background";
|
|
19
|
+
import {
|
|
20
|
+
ChoroplethCameraContext,
|
|
21
|
+
useChoroplethCameraController
|
|
22
|
+
} from "./choropleth-camera";
|
|
23
|
+
import {
|
|
24
|
+
ChoroplethInteractionShell,
|
|
25
|
+
ChoroplethStableProvider,
|
|
26
|
+
ChoroplethZoomContext,
|
|
27
|
+
useChoroplethInteraction
|
|
28
|
+
} from "./choropleth-context";
|
|
29
|
+
import { ChoroplethDotGrid as ChoroplethDotGridLayer } from "./choropleth-dot-grid";
|
|
30
|
+
import { ChoroplethFeature as ChoroplethFeatureLayer } from "./choropleth-feature";
|
|
31
|
+
import { ChoroplethGraticule as ChoroplethGraticuleLayer } from "./choropleth-graticule";
|
|
32
|
+
import { ChoroplethMarker as ChoroplethMarkerLayer } from "./choropleth-marker";
|
|
33
|
+
import {
|
|
34
|
+
createChoroplethMercator,
|
|
35
|
+
projectFeaturePaths
|
|
36
|
+
} from "./choropleth-projection";
|
|
37
|
+
import { ChoroplethTooltip as ChoroplethTooltipLayer } from "./choropleth-tooltip";
|
|
38
|
+
import {
|
|
39
|
+
choroplethWheelDelta
|
|
40
|
+
} from "./choropleth-zoom-matrix";
|
|
41
|
+
import { useChoroplethZoomState } from "./use-choropleth-zoom-state";
|
|
42
|
+
const DEFAULT_MARGIN = { top: 0, right: 0, bottom: 0, left: 0 };
|
|
43
|
+
const SVG_COMPONENT_NAMES = /* @__PURE__ */ new Set([
|
|
44
|
+
"ChoroplethFeature",
|
|
45
|
+
"ChoroplethGraticule",
|
|
46
|
+
"ChoroplethTooltip",
|
|
47
|
+
"ChoroplethDotGrid",
|
|
48
|
+
"ChoroplethMarker"
|
|
49
|
+
]);
|
|
50
|
+
const SVG_COMPONENT_TYPES = /* @__PURE__ */ new Set([
|
|
51
|
+
ChoroplethFeatureLayer,
|
|
52
|
+
ChoroplethGraticuleLayer,
|
|
53
|
+
ChoroplethTooltipLayer,
|
|
54
|
+
ChoroplethDotGridLayer,
|
|
55
|
+
ChoroplethMarkerLayer
|
|
56
|
+
]);
|
|
57
|
+
const BACKDROP_COMPONENT_NAMES = /* @__PURE__ */ new Set(["ChoroplethBackground"]);
|
|
58
|
+
const BACKDROP_COMPONENT_TYPES = /* @__PURE__ */ new Set([ChoroplethBackgroundLayer]);
|
|
59
|
+
function isChoroplethBackdropChild(type) {
|
|
60
|
+
if (BACKDROP_COMPONENT_TYPES.has(type) || BACKDROP_COMPONENT_TYPES.has(resolveComponentType(type))) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
const displayName = getComponentDisplayName(type);
|
|
64
|
+
return displayName !== null && BACKDROP_COMPONENT_NAMES.has(displayName);
|
|
65
|
+
}
|
|
66
|
+
function resolveComponentType(type) {
|
|
67
|
+
if (typeof type === "object" && type !== null && "type" in type && type.type) {
|
|
68
|
+
return type.type;
|
|
69
|
+
}
|
|
70
|
+
return type;
|
|
71
|
+
}
|
|
72
|
+
function getComponentDisplayName(type) {
|
|
73
|
+
if (typeof type === "function") {
|
|
74
|
+
const fn = type;
|
|
75
|
+
return fn.displayName ?? fn.name ?? null;
|
|
76
|
+
}
|
|
77
|
+
if (typeof type === "object" && type !== null) {
|
|
78
|
+
const wrapped = type;
|
|
79
|
+
if (wrapped.displayName) {
|
|
80
|
+
return wrapped.displayName;
|
|
81
|
+
}
|
|
82
|
+
const inner = wrapped.type;
|
|
83
|
+
if (typeof inner === "function") {
|
|
84
|
+
const innerFn = inner;
|
|
85
|
+
return innerFn.displayName ?? innerFn.name ?? null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
function isChoroplethSvgChild(type) {
|
|
91
|
+
if (SVG_COMPONENT_TYPES.has(type)) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
const resolved = resolveComponentType(type);
|
|
95
|
+
if (resolved !== type && SVG_COMPONENT_TYPES.has(resolved)) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
const displayName = getComponentDisplayName(type);
|
|
99
|
+
return displayName !== null && SVG_COMPONENT_NAMES.has(displayName);
|
|
100
|
+
}
|
|
101
|
+
const HTML_ELEMENTS = /* @__PURE__ */ new Set(["div", "span", "button", "p", "a"]);
|
|
102
|
+
function separateChildren(children) {
|
|
103
|
+
const childArray = React.Children.toArray(children);
|
|
104
|
+
const backdropChildren = [];
|
|
105
|
+
const svgChildren = [];
|
|
106
|
+
const overlayChildren = [];
|
|
107
|
+
for (const child of childArray) {
|
|
108
|
+
if (!React.isValidElement(child)) {
|
|
109
|
+
svgChildren.push(child);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if (isChoroplethBackdropChild(child.type)) {
|
|
113
|
+
backdropChildren.push(child);
|
|
114
|
+
} else if (isChoroplethSvgChild(child.type)) {
|
|
115
|
+
svgChildren.push(child);
|
|
116
|
+
} else if (typeof child.type === "string") {
|
|
117
|
+
if (HTML_ELEMENTS.has(child.type)) {
|
|
118
|
+
overlayChildren.push(child);
|
|
119
|
+
} else {
|
|
120
|
+
svgChildren.push(child);
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
overlayChildren.push(child);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return { backdropChildren, svgChildren, overlayChildren };
|
|
127
|
+
}
|
|
128
|
+
const DEFAULT_INITIAL_ZOOM = {
|
|
129
|
+
scaleX: 1,
|
|
130
|
+
scaleY: 1,
|
|
131
|
+
translateX: 0,
|
|
132
|
+
translateY: 0,
|
|
133
|
+
skewX: 0,
|
|
134
|
+
skewY: 0
|
|
135
|
+
};
|
|
136
|
+
function fadeStops(edge, active) {
|
|
137
|
+
const outer = active ? 0 : 1;
|
|
138
|
+
return [
|
|
139
|
+
{ offset: "0%", opacity: outer },
|
|
140
|
+
{ offset: `${edge}%`, opacity: 1 },
|
|
141
|
+
{ offset: `${100 - edge}%`, opacity: 1 },
|
|
142
|
+
{ offset: "100%", opacity: outer }
|
|
143
|
+
];
|
|
144
|
+
}
|
|
145
|
+
function ViewportFadeMask({
|
|
146
|
+
id,
|
|
147
|
+
width,
|
|
148
|
+
height,
|
|
149
|
+
edgeFade,
|
|
150
|
+
active
|
|
151
|
+
}) {
|
|
152
|
+
const stops = fadeStops(edgeFade, active);
|
|
153
|
+
const stopNodes = stops.map((stop) => /* @__PURE__ */ jsx(
|
|
154
|
+
"stop",
|
|
155
|
+
{
|
|
156
|
+
offset: stop.offset,
|
|
157
|
+
stopColor: "white",
|
|
158
|
+
style: {
|
|
159
|
+
stopOpacity: stop.opacity,
|
|
160
|
+
transition: "stop-opacity 0.4s ease-out"
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
stop.offset
|
|
164
|
+
));
|
|
165
|
+
return /* @__PURE__ */ jsxs("defs", { children: [
|
|
166
|
+
/* @__PURE__ */ jsx("linearGradient", { id: `${id}-h`, x1: "0", x2: "1", y1: "0", y2: "0", children: stopNodes }),
|
|
167
|
+
/* @__PURE__ */ jsx("linearGradient", { id: `${id}-v`, x1: "0", x2: "0", y1: "0", y2: "1", children: stopNodes }),
|
|
168
|
+
/* @__PURE__ */ jsx(
|
|
169
|
+
"mask",
|
|
170
|
+
{
|
|
171
|
+
height,
|
|
172
|
+
id: `${id}-hm`,
|
|
173
|
+
maskUnits: "userSpaceOnUse",
|
|
174
|
+
width,
|
|
175
|
+
x: 0,
|
|
176
|
+
y: 0,
|
|
177
|
+
children: /* @__PURE__ */ jsx("rect", { fill: `url(#${id}-h)`, height, width })
|
|
178
|
+
}
|
|
179
|
+
),
|
|
180
|
+
/* @__PURE__ */ jsx(
|
|
181
|
+
"mask",
|
|
182
|
+
{
|
|
183
|
+
height,
|
|
184
|
+
id,
|
|
185
|
+
maskUnits: "userSpaceOnUse",
|
|
186
|
+
width,
|
|
187
|
+
x: 0,
|
|
188
|
+
y: 0,
|
|
189
|
+
children: /* @__PURE__ */ jsx("g", { mask: `url(#${id}-hm)`, children: /* @__PURE__ */ jsx("rect", { fill: `url(#${id}-v)`, height, width }) })
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
] });
|
|
193
|
+
}
|
|
194
|
+
const ChoroplethSvg = memo(function ChoroplethSvg2({
|
|
195
|
+
height,
|
|
196
|
+
width,
|
|
197
|
+
svgChildren,
|
|
198
|
+
zoom,
|
|
199
|
+
camera
|
|
200
|
+
}) {
|
|
201
|
+
const { setHoveredFeatureIndex, setTooltipData, setMarkerTooltip } = useChoroplethInteraction();
|
|
202
|
+
const { api, svgRef, cameraRef, edgeFade, edgeFadeActive } = camera;
|
|
203
|
+
const fadeId = `choropleth-edge-fade-${useId().replace(/:/g, "")}`;
|
|
204
|
+
const zoomContainerRef = zoom?.containerRef;
|
|
205
|
+
const handleMouseLeave = useCallback(() => {
|
|
206
|
+
setHoveredFeatureIndex(null);
|
|
207
|
+
setTooltipData(null);
|
|
208
|
+
setMarkerTooltip?.(null);
|
|
209
|
+
}, [setHoveredFeatureIndex, setTooltipData, setMarkerTooltip]);
|
|
210
|
+
const setSvgRef = useCallback(
|
|
211
|
+
(node) => {
|
|
212
|
+
svgRef.current = node;
|
|
213
|
+
if (zoomContainerRef) {
|
|
214
|
+
zoomContainerRef.current = node;
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
[svgRef, zoomContainerRef]
|
|
218
|
+
);
|
|
219
|
+
const handleClick = useCallback(
|
|
220
|
+
(event) => {
|
|
221
|
+
if (api.enabled && api.focusedKey !== null && event.target === event.currentTarget && !api.wasDrag()) {
|
|
222
|
+
api.reset();
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
[api]
|
|
226
|
+
);
|
|
227
|
+
let cursor;
|
|
228
|
+
if (zoom) {
|
|
229
|
+
cursor = zoom.isDragging ? "grabbing" : "grab";
|
|
230
|
+
}
|
|
231
|
+
return /* @__PURE__ */ jsxs(
|
|
232
|
+
"svg",
|
|
233
|
+
{
|
|
234
|
+
"aria-hidden": "true",
|
|
235
|
+
height,
|
|
236
|
+
onClick: handleClick,
|
|
237
|
+
onMouseLeave: handleMouseLeave,
|
|
238
|
+
ref: setSvgRef,
|
|
239
|
+
style: {
|
|
240
|
+
// Draws past its own box: the tilted plane would otherwise show the
|
|
241
|
+
// svg edge as a slanted cut. The untransformed wrapper clips instead.
|
|
242
|
+
contain: "layout style",
|
|
243
|
+
overflow: "visible",
|
|
244
|
+
cursor,
|
|
245
|
+
touchAction: zoom ? "none" : "manipulation"
|
|
246
|
+
},
|
|
247
|
+
width,
|
|
248
|
+
children: [
|
|
249
|
+
edgeFade > 0 ? /* @__PURE__ */ jsx(
|
|
250
|
+
ViewportFadeMask,
|
|
251
|
+
{
|
|
252
|
+
active: edgeFadeActive,
|
|
253
|
+
edgeFade,
|
|
254
|
+
height,
|
|
255
|
+
id: fadeId,
|
|
256
|
+
width
|
|
257
|
+
}
|
|
258
|
+
) : null,
|
|
259
|
+
/* @__PURE__ */ jsx("g", { mask: edgeFade > 0 ? `url(#${fadeId})` : void 0, children: /* @__PURE__ */ jsx("g", { ref: cameraRef, children: /* @__PURE__ */ jsx(
|
|
260
|
+
"g",
|
|
261
|
+
{
|
|
262
|
+
style: {
|
|
263
|
+
transition: zoom?.isDragging ? "none" : "transform 0.18s ease-out"
|
|
264
|
+
},
|
|
265
|
+
transform: zoom ? zoom.toString() : void 0,
|
|
266
|
+
children: svgChildren
|
|
267
|
+
}
|
|
268
|
+
) }) })
|
|
269
|
+
]
|
|
270
|
+
}
|
|
271
|
+
);
|
|
272
|
+
});
|
|
273
|
+
const ChoroplethMercatorContent = memo(function ChoroplethMercatorContent2({
|
|
274
|
+
mercator,
|
|
275
|
+
featurePaths,
|
|
276
|
+
data,
|
|
277
|
+
width,
|
|
278
|
+
height,
|
|
279
|
+
innerWidth,
|
|
280
|
+
innerHeight,
|
|
281
|
+
margin,
|
|
282
|
+
animationDuration,
|
|
283
|
+
enterTransition,
|
|
284
|
+
revealEpoch,
|
|
285
|
+
isLoaded,
|
|
286
|
+
containerRef,
|
|
287
|
+
backdropChildren,
|
|
288
|
+
svgChildren,
|
|
289
|
+
overlayChildren,
|
|
290
|
+
zoom,
|
|
291
|
+
cameraOptions
|
|
292
|
+
}) {
|
|
293
|
+
const camera = useChoroplethCameraController({
|
|
294
|
+
...cameraOptions,
|
|
295
|
+
width,
|
|
296
|
+
height,
|
|
297
|
+
mercator,
|
|
298
|
+
features: data.features,
|
|
299
|
+
onBeforeFocus: zoom?.reset
|
|
300
|
+
});
|
|
301
|
+
const pathGenerator = useCallback(
|
|
302
|
+
(feature) => mercator.path(feature) ?? void 0,
|
|
303
|
+
[mercator]
|
|
304
|
+
);
|
|
305
|
+
const rawPathGenerator = useCallback(
|
|
306
|
+
(geo) => mercator.path(geo),
|
|
307
|
+
[mercator]
|
|
308
|
+
);
|
|
309
|
+
const projectPoint = useCallback(
|
|
310
|
+
(coords) => {
|
|
311
|
+
const projected = mercator.projection(coords);
|
|
312
|
+
if (!projected) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
return projected;
|
|
316
|
+
},
|
|
317
|
+
[mercator]
|
|
318
|
+
);
|
|
319
|
+
const stableValue = useMemo(
|
|
320
|
+
() => ({
|
|
321
|
+
features: data.features,
|
|
322
|
+
featureCollection: data,
|
|
323
|
+
featurePaths,
|
|
324
|
+
pathGenerator,
|
|
325
|
+
rawPathGenerator,
|
|
326
|
+
projectPoint,
|
|
327
|
+
width,
|
|
328
|
+
height,
|
|
329
|
+
innerWidth,
|
|
330
|
+
innerHeight,
|
|
331
|
+
margin,
|
|
332
|
+
containerRef,
|
|
333
|
+
isLoaded,
|
|
334
|
+
animationDuration,
|
|
335
|
+
enterTransition,
|
|
336
|
+
revealEpoch
|
|
337
|
+
}),
|
|
338
|
+
[
|
|
339
|
+
animationDuration,
|
|
340
|
+
containerRef,
|
|
341
|
+
data,
|
|
342
|
+
enterTransition,
|
|
343
|
+
featurePaths,
|
|
344
|
+
height,
|
|
345
|
+
innerHeight,
|
|
346
|
+
innerWidth,
|
|
347
|
+
isLoaded,
|
|
348
|
+
margin,
|
|
349
|
+
pathGenerator,
|
|
350
|
+
projectPoint,
|
|
351
|
+
rawPathGenerator,
|
|
352
|
+
revealEpoch,
|
|
353
|
+
width
|
|
354
|
+
]
|
|
355
|
+
);
|
|
356
|
+
return /* @__PURE__ */ jsx(ChoroplethZoomContext.Provider, { value: { zoom: zoom ?? null }, children: /* @__PURE__ */ jsx(ChoroplethCameraContext.Provider, { value: camera.api, children: /* @__PURE__ */ jsx(ChoroplethStableProvider, { value: stableValue, children: /* @__PURE__ */ jsx(ChoroplethInteractionShell, { children: /* @__PURE__ */ jsxs(
|
|
357
|
+
"div",
|
|
358
|
+
{
|
|
359
|
+
className: "relative h-full w-full",
|
|
360
|
+
onPointerDown: camera.onPointerDown,
|
|
361
|
+
onPointerLeave: camera.onPointerLeave,
|
|
362
|
+
onPointerMove: camera.onPointerMove,
|
|
363
|
+
ref: containerRef,
|
|
364
|
+
children: [
|
|
365
|
+
backdropChildren.length > 0 ? /* @__PURE__ */ jsx(
|
|
366
|
+
"svg",
|
|
367
|
+
{
|
|
368
|
+
"aria-hidden": "true",
|
|
369
|
+
className: "pointer-events-none absolute inset-0",
|
|
370
|
+
height,
|
|
371
|
+
width,
|
|
372
|
+
children: backdropChildren
|
|
373
|
+
}
|
|
374
|
+
) : null,
|
|
375
|
+
/* @__PURE__ */ jsx(
|
|
376
|
+
"div",
|
|
377
|
+
{
|
|
378
|
+
className: "relative h-full w-full",
|
|
379
|
+
style: {
|
|
380
|
+
contain: "paint",
|
|
381
|
+
overflow: "hidden",
|
|
382
|
+
perspective: camera.hasPerspective ? `${camera.depth}px` : void 0
|
|
383
|
+
},
|
|
384
|
+
children: /* @__PURE__ */ jsx(
|
|
385
|
+
"div",
|
|
386
|
+
{
|
|
387
|
+
className: "h-full w-full",
|
|
388
|
+
ref: camera.planeRef,
|
|
389
|
+
style: {
|
|
390
|
+
transformOrigin: "50% 60%",
|
|
391
|
+
// A tilt that changes every frame otherwise makes Chrome
|
|
392
|
+
// drop to a low-res raster until the motion settles.
|
|
393
|
+
willChange: camera.hasPerspective ? "transform" : void 0
|
|
394
|
+
},
|
|
395
|
+
children: /* @__PURE__ */ jsx(
|
|
396
|
+
ChoroplethSvg,
|
|
397
|
+
{
|
|
398
|
+
camera,
|
|
399
|
+
height,
|
|
400
|
+
svgChildren,
|
|
401
|
+
width,
|
|
402
|
+
zoom
|
|
403
|
+
}
|
|
404
|
+
)
|
|
405
|
+
}
|
|
406
|
+
)
|
|
407
|
+
}
|
|
408
|
+
),
|
|
409
|
+
overlayChildren
|
|
410
|
+
]
|
|
411
|
+
}
|
|
412
|
+
) }) }) }) });
|
|
413
|
+
});
|
|
414
|
+
function ChoroplethZoom({
|
|
415
|
+
width,
|
|
416
|
+
height,
|
|
417
|
+
initialTransformMatrix,
|
|
418
|
+
scaleMin,
|
|
419
|
+
scaleMax,
|
|
420
|
+
children
|
|
421
|
+
}) {
|
|
422
|
+
const zoom = useChoroplethZoomState({
|
|
423
|
+
width,
|
|
424
|
+
height,
|
|
425
|
+
initialTransformMatrix,
|
|
426
|
+
scaleXMin: scaleMin,
|
|
427
|
+
scaleXMax: scaleMax,
|
|
428
|
+
scaleYMin: scaleMin,
|
|
429
|
+
scaleYMax: scaleMax,
|
|
430
|
+
wheelDelta: choroplethWheelDelta
|
|
431
|
+
});
|
|
432
|
+
return children(zoom);
|
|
433
|
+
}
|
|
434
|
+
function ChoroplethChartInner({
|
|
435
|
+
data,
|
|
436
|
+
width,
|
|
437
|
+
height,
|
|
438
|
+
margin: marginProp,
|
|
439
|
+
animationDuration,
|
|
440
|
+
enterTransition,
|
|
441
|
+
revealSignature = "",
|
|
442
|
+
scale: scaleProp,
|
|
443
|
+
center,
|
|
444
|
+
translate: translateProp,
|
|
445
|
+
zoomEnabled,
|
|
446
|
+
zoomMin,
|
|
447
|
+
zoomMax,
|
|
448
|
+
initialZoom,
|
|
449
|
+
cameraOptions,
|
|
450
|
+
children
|
|
451
|
+
}) {
|
|
452
|
+
const containerRef = useRef(null);
|
|
453
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
454
|
+
const [revealEpoch, setRevealEpoch] = useState(1);
|
|
455
|
+
const margin = useMemo(
|
|
456
|
+
() => ({
|
|
457
|
+
top: marginProp.top,
|
|
458
|
+
right: marginProp.right,
|
|
459
|
+
bottom: marginProp.bottom,
|
|
460
|
+
left: marginProp.left
|
|
461
|
+
}),
|
|
462
|
+
[marginProp.top, marginProp.right, marginProp.bottom, marginProp.left]
|
|
463
|
+
);
|
|
464
|
+
const innerWidth = width - margin.left - margin.right;
|
|
465
|
+
const innerHeight = height - margin.top - margin.bottom;
|
|
466
|
+
const scale = scaleProp ?? innerWidth / 630 * 100;
|
|
467
|
+
const translateX = translateProp?.[0] ?? innerWidth / 2 + margin.left;
|
|
468
|
+
const translateY = translateProp?.[1] ?? innerHeight / 2 + margin.top + 50;
|
|
469
|
+
const [centerX, centerY] = center;
|
|
470
|
+
const mercator = useMemo(
|
|
471
|
+
() => createChoroplethMercator({
|
|
472
|
+
scale,
|
|
473
|
+
translate: [translateX, translateY],
|
|
474
|
+
center: [centerX, centerY]
|
|
475
|
+
}),
|
|
476
|
+
[scale, translateX, translateY, centerX, centerY]
|
|
477
|
+
);
|
|
478
|
+
const featurePaths = useMemo(
|
|
479
|
+
() => projectFeaturePaths(mercator, data.features),
|
|
480
|
+
[mercator, data.features]
|
|
481
|
+
);
|
|
482
|
+
const { backdropChildren, svgChildren, overlayChildren } = useMemo(
|
|
483
|
+
() => separateChildren(children),
|
|
484
|
+
[children]
|
|
485
|
+
);
|
|
486
|
+
const [revealKey, setRevealKey] = useState({
|
|
487
|
+
animationDuration,
|
|
488
|
+
revealSignature
|
|
489
|
+
});
|
|
490
|
+
if (revealKey.animationDuration !== animationDuration || revealKey.revealSignature !== revealSignature) {
|
|
491
|
+
setRevealKey({ animationDuration, revealSignature });
|
|
492
|
+
setRevealEpoch((n) => n + 1);
|
|
493
|
+
setIsLoaded(false);
|
|
494
|
+
}
|
|
495
|
+
useEffect(() => {
|
|
496
|
+
const timeout = setTimeout(() => {
|
|
497
|
+
setIsLoaded(true);
|
|
498
|
+
}, animationDuration);
|
|
499
|
+
return () => clearTimeout(timeout);
|
|
500
|
+
}, [animationDuration, revealSignature]);
|
|
501
|
+
if (width < 10 || height < 10) {
|
|
502
|
+
return null;
|
|
503
|
+
}
|
|
504
|
+
const mercatorContentProps = {
|
|
505
|
+
animationDuration,
|
|
506
|
+
backdropChildren,
|
|
507
|
+
cameraOptions,
|
|
508
|
+
containerRef,
|
|
509
|
+
data,
|
|
510
|
+
enterTransition,
|
|
511
|
+
height,
|
|
512
|
+
innerHeight,
|
|
513
|
+
innerWidth,
|
|
514
|
+
isLoaded,
|
|
515
|
+
margin,
|
|
516
|
+
overlayChildren,
|
|
517
|
+
revealEpoch,
|
|
518
|
+
svgChildren,
|
|
519
|
+
width
|
|
520
|
+
};
|
|
521
|
+
const content = (zoom) => /* @__PURE__ */ jsx(
|
|
522
|
+
ChoroplethMercatorContent,
|
|
523
|
+
{
|
|
524
|
+
...mercatorContentProps,
|
|
525
|
+
featurePaths,
|
|
526
|
+
mercator,
|
|
527
|
+
zoom
|
|
528
|
+
}
|
|
529
|
+
);
|
|
530
|
+
if (zoomEnabled) {
|
|
531
|
+
return /* @__PURE__ */ jsx(
|
|
532
|
+
ChoroplethZoom,
|
|
533
|
+
{
|
|
534
|
+
height,
|
|
535
|
+
initialTransformMatrix: initialZoom,
|
|
536
|
+
scaleMax: zoomMax,
|
|
537
|
+
scaleMin: zoomMin,
|
|
538
|
+
width,
|
|
539
|
+
children: content
|
|
540
|
+
}
|
|
541
|
+
);
|
|
542
|
+
}
|
|
543
|
+
return content();
|
|
544
|
+
}
|
|
545
|
+
function choroplethFeatureKey(feature, index) {
|
|
546
|
+
return String(
|
|
547
|
+
feature.id ?? feature.properties?.id ?? feature.properties?.name ?? index
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
const choroplethDataCodec = {
|
|
551
|
+
toView: ({ data }) => data.features.map((feature, index) => ({
|
|
552
|
+
...feature.properties,
|
|
553
|
+
id: choroplethFeatureKey(feature, index)
|
|
554
|
+
})),
|
|
555
|
+
fromView: (view, inputs) => {
|
|
556
|
+
if (!Array.isArray(view)) {
|
|
557
|
+
return inputs;
|
|
558
|
+
}
|
|
559
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
560
|
+
inputs.data.features.forEach((feature, index) => {
|
|
561
|
+
byKey.set(choroplethFeatureKey(feature, index), feature);
|
|
562
|
+
});
|
|
563
|
+
const features = [];
|
|
564
|
+
view.forEach((row, index) => {
|
|
565
|
+
if (!row || typeof row !== "object") {
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
const { id, ...properties } = row;
|
|
569
|
+
const feature = byKey.get(String(id)) ?? inputs.data.features[index];
|
|
570
|
+
if (feature) {
|
|
571
|
+
if (feature.properties?.id !== void 0) {
|
|
572
|
+
properties.id = id;
|
|
573
|
+
}
|
|
574
|
+
features.push({
|
|
575
|
+
...feature,
|
|
576
|
+
properties
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
return { data: { ...inputs.data, features } };
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
function ChoroplethChart({
|
|
584
|
+
data: dataProp,
|
|
585
|
+
margin: marginProp,
|
|
586
|
+
animationDuration = 800,
|
|
587
|
+
enterTransition,
|
|
588
|
+
revealSignature,
|
|
589
|
+
aspectRatio = "16 / 9",
|
|
590
|
+
scale,
|
|
591
|
+
center = [0, 20],
|
|
592
|
+
translate,
|
|
593
|
+
zoomEnabled = false,
|
|
594
|
+
zoomMin = 0.5,
|
|
595
|
+
zoomMax = 4,
|
|
596
|
+
initialZoom = DEFAULT_INITIAL_ZOOM,
|
|
597
|
+
clickToZoom = false,
|
|
598
|
+
focusMaxZoom = 6,
|
|
599
|
+
zoomTransition,
|
|
600
|
+
perspective,
|
|
601
|
+
className = "",
|
|
602
|
+
children
|
|
603
|
+
}) {
|
|
604
|
+
const { data } = useChartDataOverride(
|
|
605
|
+
"ChoroplethChart",
|
|
606
|
+
{ data: dataProp },
|
|
607
|
+
choroplethDataCodec
|
|
608
|
+
);
|
|
609
|
+
const margin = { ...DEFAULT_MARGIN, ...marginProp };
|
|
610
|
+
const zoomDuration = zoomTransition?.duration;
|
|
611
|
+
const zoomEase = zoomTransition?.ease?.join(",");
|
|
612
|
+
const perspectiveKey = perspective ? JSON.stringify(perspective) : "";
|
|
613
|
+
const cameraOptions = useMemo(
|
|
614
|
+
() => ({ clickToZoom, focusMaxZoom, zoomTransition, perspective }),
|
|
615
|
+
[clickToZoom, focusMaxZoom, zoomDuration, zoomEase, perspectiveKey]
|
|
616
|
+
);
|
|
617
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domAnimation, children: /* @__PURE__ */ jsx("div", { className: cn("relative w-full", className), style: { aspectRatio }, children: /* @__PURE__ */ jsx(ParentSize, { debounceTime: 10, children: ({ width, height }) => width > 0 && height > 0 ? /* @__PURE__ */ jsx(
|
|
618
|
+
ChoroplethChartInner,
|
|
619
|
+
{
|
|
620
|
+
animationDuration,
|
|
621
|
+
cameraOptions,
|
|
622
|
+
center,
|
|
623
|
+
data,
|
|
624
|
+
enterTransition,
|
|
625
|
+
height,
|
|
626
|
+
initialZoom,
|
|
627
|
+
margin,
|
|
628
|
+
revealSignature,
|
|
629
|
+
scale,
|
|
630
|
+
translate,
|
|
631
|
+
width,
|
|
632
|
+
zoomEnabled,
|
|
633
|
+
zoomMax,
|
|
634
|
+
zoomMin,
|
|
635
|
+
children
|
|
636
|
+
}
|
|
637
|
+
) : null }) }) });
|
|
638
|
+
}
|
|
639
|
+
ChoroplethChart.displayName = "ChoroplethChart";
|
|
640
|
+
var choropleth_chart_default = ChoroplethChart;
|
|
641
|
+
export {
|
|
642
|
+
ChoroplethChart,
|
|
643
|
+
choropleth_chart_default as default
|
|
644
|
+
};
|