@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,182 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { domAnimation, LazyMotion } from "motion/react";
|
|
4
|
+
import {
|
|
5
|
+
Children,
|
|
6
|
+
isValidElement,
|
|
7
|
+
useCallback,
|
|
8
|
+
useMemo,
|
|
9
|
+
useRef,
|
|
10
|
+
useState
|
|
11
|
+
} from "react";
|
|
12
|
+
import { cn } from "../lib/utils";
|
|
13
|
+
import { useStableMargin } from "./chart-context";
|
|
14
|
+
import { useChartDataOverride } from "./chart-data-override";
|
|
15
|
+
import { InteracaoProvider } from "../aic/interacao";
|
|
16
|
+
import { ChartLoadingLabel } from "./chart-loading-label";
|
|
17
|
+
import { ParentSize } from "./chart-parent-size";
|
|
18
|
+
import {
|
|
19
|
+
DEFAULT_CHART_STATUS,
|
|
20
|
+
DEFAULT_Y_DOMAIN_TWEEN_MS,
|
|
21
|
+
resolveRestingChartPhase
|
|
22
|
+
} from "./chart-phase";
|
|
23
|
+
import { Line } from "./line";
|
|
24
|
+
import {
|
|
25
|
+
TimeSeriesChartInner,
|
|
26
|
+
timeSeriesChartHasRoom
|
|
27
|
+
} from "./time-series-chart-shell";
|
|
28
|
+
const DEFAULT_MARGIN = { top: 40, right: 40, bottom: 40, left: 40 };
|
|
29
|
+
const LINE_DOMAIN_EXCLUDED_NAMES = /* @__PURE__ */ new Set([
|
|
30
|
+
"ProfitLossLine",
|
|
31
|
+
"LineSeriesTerminalMarker",
|
|
32
|
+
"LineBackdrop",
|
|
33
|
+
"Area",
|
|
34
|
+
"SeriesBar",
|
|
35
|
+
"Scatter",
|
|
36
|
+
"Candlestick",
|
|
37
|
+
"Bar",
|
|
38
|
+
"PatternArea",
|
|
39
|
+
"Band",
|
|
40
|
+
"TrendLine"
|
|
41
|
+
]);
|
|
42
|
+
function getChildComponentName(child) {
|
|
43
|
+
const childType = child.type;
|
|
44
|
+
return typeof child.type === "function" ? childType.displayName || childType.name || "" : "";
|
|
45
|
+
}
|
|
46
|
+
function registersLineDomain(child, props) {
|
|
47
|
+
if (!props?.dataKey) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
const componentName = getChildComponentName(child);
|
|
51
|
+
if (componentName === "Line" || child.type === Line) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
if (LINE_DOMAIN_EXCLUDED_NAMES.has(componentName)) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return typeof props.dataKey === "string" && props.dataKey.length > 0;
|
|
58
|
+
}
|
|
59
|
+
function extractLineConfigs(children) {
|
|
60
|
+
const configs = [];
|
|
61
|
+
const visit = (node) => {
|
|
62
|
+
Children.forEach(node, (child) => {
|
|
63
|
+
if (!isValidElement(child)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const props = child.props;
|
|
67
|
+
if (registersLineDomain(child, props) && props?.dataKey) {
|
|
68
|
+
configs.push({
|
|
69
|
+
dataKey: props.dataKey,
|
|
70
|
+
stroke: props.stroke || "var(--chart-line-primary)",
|
|
71
|
+
strokeWidth: props.strokeWidth || 2.5,
|
|
72
|
+
yAxisId: props.yAxisId
|
|
73
|
+
});
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const childProps = child.props;
|
|
77
|
+
if (childProps?.children) {
|
|
78
|
+
visit(childProps.children);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
visit(children);
|
|
83
|
+
return configs;
|
|
84
|
+
}
|
|
85
|
+
function LineChart({
|
|
86
|
+
data: dataProp,
|
|
87
|
+
xDataKey = "date",
|
|
88
|
+
margin: marginProp,
|
|
89
|
+
animationDuration = 1100,
|
|
90
|
+
animationEasing,
|
|
91
|
+
enterTransition,
|
|
92
|
+
revealSignature,
|
|
93
|
+
aspectRatio = "2 / 1",
|
|
94
|
+
className = "",
|
|
95
|
+
status = DEFAULT_CHART_STATUS,
|
|
96
|
+
loadingLabel,
|
|
97
|
+
yDomainTweenDuration = DEFAULT_Y_DOMAIN_TWEEN_MS,
|
|
98
|
+
yDomainTween = true,
|
|
99
|
+
xDomain,
|
|
100
|
+
xDomainSlotCount,
|
|
101
|
+
tweenYDomainOnXDomainChange = false,
|
|
102
|
+
yScaleDomainMax,
|
|
103
|
+
style,
|
|
104
|
+
onPhaseChange,
|
|
105
|
+
children,
|
|
106
|
+
onPointClick
|
|
107
|
+
}) {
|
|
108
|
+
const { data } = useChartDataOverride("LineChart", {
|
|
109
|
+
data: dataProp
|
|
110
|
+
});
|
|
111
|
+
const containerRef = useRef(null);
|
|
112
|
+
const margin = useStableMargin({ ...DEFAULT_MARGIN, ...marginProp });
|
|
113
|
+
const lines = useMemo(() => extractLineConfigs(children), [children]);
|
|
114
|
+
const [chartPhase, setChartPhase] = useState(
|
|
115
|
+
() => resolveRestingChartPhase(status)
|
|
116
|
+
);
|
|
117
|
+
const handlePhaseChange = useCallback(
|
|
118
|
+
(phase) => {
|
|
119
|
+
setChartPhase(phase);
|
|
120
|
+
onPhaseChange?.(phase);
|
|
121
|
+
},
|
|
122
|
+
[onPhaseChange]
|
|
123
|
+
);
|
|
124
|
+
const showLoadingLabel = Boolean(
|
|
125
|
+
loadingLabel?.trim() && (chartPhase === "loading" || chartPhase === "exiting" || chartPhase === "gridTweenReady" || chartPhase === "revealingLoading")
|
|
126
|
+
);
|
|
127
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domAnimation, children: /* @__PURE__ */ jsx(InteracaoProvider, { aoClicar: onPointClick, data, selecao: void 0, children: /* @__PURE__ */ jsxs(
|
|
128
|
+
"div",
|
|
129
|
+
{
|
|
130
|
+
className: cn("relative w-full", className),
|
|
131
|
+
ref: containerRef,
|
|
132
|
+
style: {
|
|
133
|
+
...aspectRatio ? { aspectRatio } : void 0,
|
|
134
|
+
touchAction: "none",
|
|
135
|
+
...style
|
|
136
|
+
},
|
|
137
|
+
children: [
|
|
138
|
+
/* @__PURE__ */ jsx(ParentSize, { debounceTime: 10, children: ({ width, height }) => timeSeriesChartHasRoom(width, height) ? /* @__PURE__ */ jsx(
|
|
139
|
+
TimeSeriesChartInner,
|
|
140
|
+
{
|
|
141
|
+
animationDuration,
|
|
142
|
+
animationEasing,
|
|
143
|
+
chartStatus: status,
|
|
144
|
+
clipPathId: "chart-grow-clip",
|
|
145
|
+
containerRef,
|
|
146
|
+
data,
|
|
147
|
+
enterTransition,
|
|
148
|
+
height,
|
|
149
|
+
lines,
|
|
150
|
+
loadingLabel,
|
|
151
|
+
margin,
|
|
152
|
+
onPhaseChange: handlePhaseChange,
|
|
153
|
+
revealSignature,
|
|
154
|
+
tweenYDomainOnXDomainChange,
|
|
155
|
+
width,
|
|
156
|
+
xDataKey,
|
|
157
|
+
xDomain,
|
|
158
|
+
xDomainSlotCount,
|
|
159
|
+
yDomainTween,
|
|
160
|
+
yDomainTweenDuration,
|
|
161
|
+
yScaleDomainMax,
|
|
162
|
+
children
|
|
163
|
+
}
|
|
164
|
+
) : null }),
|
|
165
|
+
showLoadingLabel ? /* @__PURE__ */ jsx(
|
|
166
|
+
ChartLoadingLabel,
|
|
167
|
+
{
|
|
168
|
+
exiting: chartPhase !== "loading",
|
|
169
|
+
text: loadingLabel
|
|
170
|
+
}
|
|
171
|
+
) : null
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
) }) });
|
|
175
|
+
}
|
|
176
|
+
import { Line as Line2 } from "./line";
|
|
177
|
+
var line_chart_default = LineChart;
|
|
178
|
+
export {
|
|
179
|
+
Line2 as Line,
|
|
180
|
+
LineChart,
|
|
181
|
+
line_chart_default as default
|
|
182
|
+
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { animate, m, useMotionValue, useTransform } from "motion/react";
|
|
4
|
+
import { useEffect, useId } from "react";
|
|
5
|
+
import { chartCssVars, useChartStable } from "./chart-context";
|
|
6
|
+
import {
|
|
7
|
+
fadeGradientStops,
|
|
8
|
+
resolveFadeSides,
|
|
9
|
+
viewportFadeGradientAttrs
|
|
10
|
+
} from "./fade-edges";
|
|
11
|
+
import {
|
|
12
|
+
LINE_LOADING_PULSE_CYCLE_S,
|
|
13
|
+
LINE_LOADING_PULSE_EASE
|
|
14
|
+
} from "./line-loading-timing";
|
|
15
|
+
const CLIP_PADDING = 10;
|
|
16
|
+
function resolveLineLoadingPulseMode(phase) {
|
|
17
|
+
switch (phase) {
|
|
18
|
+
case "loading":
|
|
19
|
+
return "loop";
|
|
20
|
+
case "exiting":
|
|
21
|
+
return "exit";
|
|
22
|
+
case "revealingLoading":
|
|
23
|
+
return "enter";
|
|
24
|
+
default:
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function useGrowExitClip(innerWidth, mode, loopEpoch, onComplete) {
|
|
29
|
+
const progress = useMotionValue(0);
|
|
30
|
+
const paddedFullWidth = innerWidth + CLIP_PADDING * 2;
|
|
31
|
+
const rightEdge = innerWidth + CLIP_PADDING;
|
|
32
|
+
const clipWidth = useTransform(progress, (p) => {
|
|
33
|
+
if (p <= 0.5) {
|
|
34
|
+
return p / 0.5 * paddedFullWidth;
|
|
35
|
+
}
|
|
36
|
+
const shrink = (p - 0.5) / 0.5;
|
|
37
|
+
return (1 - shrink) * paddedFullWidth;
|
|
38
|
+
});
|
|
39
|
+
const clipX = useTransform(progress, (p) => {
|
|
40
|
+
if (p <= 0.5) {
|
|
41
|
+
return -CLIP_PADDING;
|
|
42
|
+
}
|
|
43
|
+
const shrink = (p - 0.5) / 0.5;
|
|
44
|
+
return rightEdge - (1 - shrink) * paddedFullWidth;
|
|
45
|
+
});
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (innerWidth <= 0) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const halfCycleS = LINE_LOADING_PULSE_CYCLE_S / 2;
|
|
51
|
+
let cancelled = false;
|
|
52
|
+
let controls;
|
|
53
|
+
const finish = () => {
|
|
54
|
+
if (!cancelled) {
|
|
55
|
+
onComplete?.();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const runShrink = (from) => {
|
|
59
|
+
const shrinkDuration = halfCycleS * ((1 - from) / 0.5);
|
|
60
|
+
controls = animate(progress, 1, {
|
|
61
|
+
duration: Math.max(shrinkDuration, 0.01),
|
|
62
|
+
ease: [...LINE_LOADING_PULSE_EASE],
|
|
63
|
+
onComplete: finish
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
if (mode === "loop") {
|
|
67
|
+
progress.set(0);
|
|
68
|
+
controls = animate(progress, 1, {
|
|
69
|
+
duration: LINE_LOADING_PULSE_CYCLE_S,
|
|
70
|
+
ease: [...LINE_LOADING_PULSE_EASE],
|
|
71
|
+
onComplete: finish
|
|
72
|
+
});
|
|
73
|
+
return () => {
|
|
74
|
+
cancelled = true;
|
|
75
|
+
controls?.stop();
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (mode === "exit") {
|
|
79
|
+
const current = progress.get();
|
|
80
|
+
if (current < 0.5) {
|
|
81
|
+
const growDuration = halfCycleS * ((0.5 - current) / 0.5);
|
|
82
|
+
controls = animate(progress, 0.5, {
|
|
83
|
+
duration: Math.max(growDuration, 0.01),
|
|
84
|
+
ease: [...LINE_LOADING_PULSE_EASE],
|
|
85
|
+
onComplete: () => {
|
|
86
|
+
if (!cancelled) {
|
|
87
|
+
runShrink(0.5);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
} else {
|
|
92
|
+
runShrink(current);
|
|
93
|
+
}
|
|
94
|
+
return () => {
|
|
95
|
+
cancelled = true;
|
|
96
|
+
controls?.stop();
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
if (mode === "enter") {
|
|
100
|
+
progress.set(0);
|
|
101
|
+
controls = animate(progress, 0.5, {
|
|
102
|
+
duration: halfCycleS,
|
|
103
|
+
ease: [...LINE_LOADING_PULSE_EASE],
|
|
104
|
+
onComplete: finish
|
|
105
|
+
});
|
|
106
|
+
return () => {
|
|
107
|
+
cancelled = true;
|
|
108
|
+
controls?.stop();
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}, [innerWidth, loopEpoch, mode, onComplete, progress]);
|
|
112
|
+
return { clipX, clipWidth };
|
|
113
|
+
}
|
|
114
|
+
function LineLoadingPulseStroke({
|
|
115
|
+
pathD,
|
|
116
|
+
mode = "loop",
|
|
117
|
+
loopEpoch = 0,
|
|
118
|
+
stroke = chartCssVars.foreground,
|
|
119
|
+
strokeOpacity = 0.5,
|
|
120
|
+
strokeWidth = 2.5,
|
|
121
|
+
onCycleComplete
|
|
122
|
+
}) {
|
|
123
|
+
const { innerWidth, innerHeight } = useChartStable();
|
|
124
|
+
const reactId = useId();
|
|
125
|
+
const clipPathId = `line-loading-clip-${reactId}`;
|
|
126
|
+
const gradientId = `line-loading-gradient-${reactId}`;
|
|
127
|
+
const fadeStops = fadeGradientStops(resolveFadeSides(true));
|
|
128
|
+
const clipHeight = innerHeight + CLIP_PADDING * 2;
|
|
129
|
+
const { clipX, clipWidth } = useGrowExitClip(
|
|
130
|
+
innerWidth,
|
|
131
|
+
mode,
|
|
132
|
+
loopEpoch,
|
|
133
|
+
onCycleComplete
|
|
134
|
+
);
|
|
135
|
+
if (innerWidth <= 0) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
139
|
+
/* @__PURE__ */ jsxs("defs", { children: [
|
|
140
|
+
/* @__PURE__ */ jsx("clipPath", { id: clipPathId, children: /* @__PURE__ */ jsx(
|
|
141
|
+
m.rect,
|
|
142
|
+
{
|
|
143
|
+
height: clipHeight,
|
|
144
|
+
style: { width: clipWidth, x: clipX },
|
|
145
|
+
y: -CLIP_PADDING
|
|
146
|
+
}
|
|
147
|
+
) }),
|
|
148
|
+
/* @__PURE__ */ jsx(
|
|
149
|
+
"linearGradient",
|
|
150
|
+
{
|
|
151
|
+
id: gradientId,
|
|
152
|
+
...viewportFadeGradientAttrs(innerWidth),
|
|
153
|
+
children: fadeStops.map((stop) => /* @__PURE__ */ jsx(
|
|
154
|
+
"stop",
|
|
155
|
+
{
|
|
156
|
+
offset: stop.offset,
|
|
157
|
+
stopColor: stroke,
|
|
158
|
+
stopOpacity: stop.opacity
|
|
159
|
+
},
|
|
160
|
+
stop.offset
|
|
161
|
+
))
|
|
162
|
+
}
|
|
163
|
+
)
|
|
164
|
+
] }),
|
|
165
|
+
/* @__PURE__ */ jsx(
|
|
166
|
+
"path",
|
|
167
|
+
{
|
|
168
|
+
clipPath: `url(#${clipPathId})`,
|
|
169
|
+
d: pathD,
|
|
170
|
+
fill: "none",
|
|
171
|
+
opacity: strokeOpacity,
|
|
172
|
+
stroke: `url(#${gradientId})`,
|
|
173
|
+
strokeLinecap: "round",
|
|
174
|
+
strokeWidth
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
] });
|
|
178
|
+
}
|
|
179
|
+
LineLoadingPulseStroke.displayName = "LineLoadingPulseStroke";
|
|
180
|
+
var line_loading_pulse_default = LineLoadingPulseStroke;
|
|
181
|
+
export {
|
|
182
|
+
LineLoadingPulseStroke,
|
|
183
|
+
line_loading_pulse_default as default,
|
|
184
|
+
resolveLineLoadingPulseMode
|
|
185
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const LINE_LOADING_PULSE_CYCLE_S = 2.2;
|
|
2
|
+
const LINE_LOADING_LOOP_PAUSE_MS = 280;
|
|
3
|
+
const LOADING_LABEL_EXIT_S = 0.45;
|
|
4
|
+
const LOADING_LABEL_EXIT_Y_PX = 30;
|
|
5
|
+
const LINE_LOADING_PULSE_EASE = [0.85, 0, 0.15, 1];
|
|
6
|
+
export {
|
|
7
|
+
LINE_LOADING_LOOP_PAUSE_MS,
|
|
8
|
+
LINE_LOADING_PULSE_CYCLE_S,
|
|
9
|
+
LINE_LOADING_PULSE_EASE,
|
|
10
|
+
LOADING_LABEL_EXIT_S,
|
|
11
|
+
LOADING_LABEL_EXIT_Y_PX
|
|
12
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { area, line } from "d3-shape";
|
|
3
|
+
import { fastShapePath } from "./fast-path";
|
|
4
|
+
function linePathD(data, { x, y, defined, curve }) {
|
|
5
|
+
const path = line();
|
|
6
|
+
if (x) {
|
|
7
|
+
path.x(x);
|
|
8
|
+
}
|
|
9
|
+
if (y) {
|
|
10
|
+
path.y(y);
|
|
11
|
+
}
|
|
12
|
+
if (defined) {
|
|
13
|
+
path.defined(defined);
|
|
14
|
+
}
|
|
15
|
+
if (curve) {
|
|
16
|
+
path.curve(curve);
|
|
17
|
+
}
|
|
18
|
+
return fastShapePath(path, data);
|
|
19
|
+
}
|
|
20
|
+
function areaClosedD(data, { x, y, y0, yScale, defined, curve }) {
|
|
21
|
+
const path = area();
|
|
22
|
+
if (x) {
|
|
23
|
+
path.x(x);
|
|
24
|
+
}
|
|
25
|
+
if (defined) {
|
|
26
|
+
path.defined(defined);
|
|
27
|
+
}
|
|
28
|
+
if (curve) {
|
|
29
|
+
path.curve(curve);
|
|
30
|
+
}
|
|
31
|
+
if (y0 == null) {
|
|
32
|
+
const baseline = yScale?.range()[0];
|
|
33
|
+
if (baseline !== void 0) {
|
|
34
|
+
path.y0(baseline);
|
|
35
|
+
}
|
|
36
|
+
} else if (typeof y0 === "number") {
|
|
37
|
+
path.y0(y0);
|
|
38
|
+
} else {
|
|
39
|
+
path.y0(y0);
|
|
40
|
+
}
|
|
41
|
+
if (y) {
|
|
42
|
+
path.y1(y);
|
|
43
|
+
}
|
|
44
|
+
return fastShapePath(path, data);
|
|
45
|
+
}
|
|
46
|
+
function LinePath({
|
|
47
|
+
d,
|
|
48
|
+
fill = "transparent",
|
|
49
|
+
innerRef,
|
|
50
|
+
...rest
|
|
51
|
+
}) {
|
|
52
|
+
return /* @__PURE__ */ jsx("path", { d, fill, ref: innerRef, strokeLinecap: "round", ...rest });
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
LinePath,
|
|
56
|
+
areaClosedD,
|
|
57
|
+
linePathD
|
|
58
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { m } from "motion/react";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { useChartStable, useYScale } from "./chart-context";
|
|
6
|
+
import { StaticSeriesPointMarker } from "./series-point-marker";
|
|
7
|
+
function isTerminalMarkerPhaseVisible(phase) {
|
|
8
|
+
return phase === "ready" || phase === "exitingReady";
|
|
9
|
+
}
|
|
10
|
+
function LineSeriesTerminalMarker({
|
|
11
|
+
dataKey,
|
|
12
|
+
yAxisId,
|
|
13
|
+
fill,
|
|
14
|
+
stroke = "var(--chart-1)",
|
|
15
|
+
radius = 5,
|
|
16
|
+
ringGap = 0,
|
|
17
|
+
strokeWidth = 1.5
|
|
18
|
+
}) {
|
|
19
|
+
const { data, xScale, xAccessor, chartPhase, revealEpoch, enterTransition } = useChartStable();
|
|
20
|
+
const yScale = useYScale(yAxisId);
|
|
21
|
+
const point = useMemo(() => {
|
|
22
|
+
const lastRow = data.at(-1);
|
|
23
|
+
if (!lastRow) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const value = lastRow[dataKey];
|
|
27
|
+
if (typeof value !== "number") {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
cx: xScale(xAccessor(lastRow)) ?? 0,
|
|
32
|
+
cy: yScale(value) ?? 0
|
|
33
|
+
};
|
|
34
|
+
}, [data, dataKey, xAccessor, xScale, yScale]);
|
|
35
|
+
const visible = isTerminalMarkerPhaseVisible(chartPhase);
|
|
36
|
+
const fadeTransition = enterTransition && typeof enterTransition === "object" ? enterTransition : { duration: 0.28, ease: [0.22, 1, 0.36, 1] };
|
|
37
|
+
if (!point) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return /* @__PURE__ */ jsx(
|
|
41
|
+
m.g,
|
|
42
|
+
{
|
|
43
|
+
animate: {
|
|
44
|
+
opacity: visible ? 1 : 0,
|
|
45
|
+
scale: visible ? 1 : 0.55
|
|
46
|
+
},
|
|
47
|
+
initial: { opacity: 0, scale: 0.55 },
|
|
48
|
+
style: {
|
|
49
|
+
transformBox: "fill-box",
|
|
50
|
+
transformOrigin: `${point.cx}px ${point.cy}px`
|
|
51
|
+
},
|
|
52
|
+
transition: fadeTransition,
|
|
53
|
+
children: /* @__PURE__ */ jsx(
|
|
54
|
+
StaticSeriesPointMarker,
|
|
55
|
+
{
|
|
56
|
+
cx: point.cx,
|
|
57
|
+
cy: point.cy,
|
|
58
|
+
fill: fill ?? stroke,
|
|
59
|
+
radius,
|
|
60
|
+
ringGap,
|
|
61
|
+
stroke,
|
|
62
|
+
strokeWidth
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
},
|
|
66
|
+
revealEpoch ?? 0
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
LineSeriesTerminalMarker.displayName = "LineSeriesTerminalMarker";
|
|
70
|
+
LineSeriesTerminalMarker.__isPostOverlay = true;
|
|
71
|
+
var line_series_terminal_marker_default = LineSeriesTerminalMarker;
|
|
72
|
+
export {
|
|
73
|
+
LineSeriesTerminalMarker,
|
|
74
|
+
line_series_terminal_marker_default as default
|
|
75
|
+
};
|