@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,370 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { bisector } from "d3-array";
|
|
4
|
+
import { scaleLinear, scaleTime } from "d3-scale";
|
|
5
|
+
import { domAnimation, LazyMotion } from "motion/react";
|
|
6
|
+
import {
|
|
7
|
+
Children,
|
|
8
|
+
isValidElement,
|
|
9
|
+
memo,
|
|
10
|
+
useCallback,
|
|
11
|
+
useEffect,
|
|
12
|
+
useMemo,
|
|
13
|
+
useRef,
|
|
14
|
+
useState,
|
|
15
|
+
useSyncExternalStore
|
|
16
|
+
} from "react";
|
|
17
|
+
import { cn } from "../lib/utils";
|
|
18
|
+
import {
|
|
19
|
+
isClipExcludedComponent,
|
|
20
|
+
isPostOverlayComponent,
|
|
21
|
+
isUnderlayComponent,
|
|
22
|
+
renderableChartChild,
|
|
23
|
+
resolveChartChildElement
|
|
24
|
+
} from "./chart-child-passthrough";
|
|
25
|
+
import { ChartProvider } from "./chart-context";
|
|
26
|
+
import { useChartDataOverride } from "./chart-data-override";
|
|
27
|
+
import { shortDateFmt } from "./chart-formatters";
|
|
28
|
+
import { ParentSize } from "./chart-parent-size";
|
|
29
|
+
import { DEFAULT_CHART_LIFECYCLE } from "./chart-phase";
|
|
30
|
+
import {
|
|
31
|
+
decimateOhlcData,
|
|
32
|
+
maxRenderPointsForWidth
|
|
33
|
+
} from "./decimate-time-series";
|
|
34
|
+
import { extractReferenceAreaConfigs } from "./reference-area-config";
|
|
35
|
+
import { useChartInteraction } from "./use-chart-interaction";
|
|
36
|
+
import { wrapSingleYScale } from "./y-axis-scales";
|
|
37
|
+
const DEFAULT_MARGIN = { top: 40, right: 40, bottom: 40, left: 40 };
|
|
38
|
+
function ChartInner(props) {
|
|
39
|
+
const { width, height } = props;
|
|
40
|
+
if (width < 10 || height < 10) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return /* @__PURE__ */ jsx(ChartCore, { ...props });
|
|
44
|
+
}
|
|
45
|
+
const ChartCore = memo(function ChartCore2({
|
|
46
|
+
width,
|
|
47
|
+
height,
|
|
48
|
+
data,
|
|
49
|
+
xDataKey,
|
|
50
|
+
margin,
|
|
51
|
+
animationDuration,
|
|
52
|
+
enterTransition,
|
|
53
|
+
revealSignature = "",
|
|
54
|
+
candleGap,
|
|
55
|
+
candleWidthProp,
|
|
56
|
+
xDomain,
|
|
57
|
+
xDomainSlotCount,
|
|
58
|
+
children,
|
|
59
|
+
containerRef
|
|
60
|
+
}) {
|
|
61
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
62
|
+
const [revealEpoch, setRevealEpoch] = useState(1);
|
|
63
|
+
const innerWidth = width - margin.left - margin.right;
|
|
64
|
+
const innerHeight = height - margin.top - margin.bottom;
|
|
65
|
+
const xAccessor = useCallback(
|
|
66
|
+
(d) => {
|
|
67
|
+
const value = d[xDataKey];
|
|
68
|
+
return value instanceof Date ? value : new Date(value);
|
|
69
|
+
},
|
|
70
|
+
[xDataKey]
|
|
71
|
+
);
|
|
72
|
+
const bisectDate = useMemo(
|
|
73
|
+
() => bisector((d) => xAccessor(d)).left,
|
|
74
|
+
[xAccessor]
|
|
75
|
+
);
|
|
76
|
+
const slotCount = xDomain && xDomainSlotCount != null ? xDomainSlotCount : data.length;
|
|
77
|
+
const slotWidth = innerWidth / Math.max(slotCount, 1);
|
|
78
|
+
const xScale = useMemo(() => {
|
|
79
|
+
const minTime = xDomain ? xDomain[0].getTime() : Math.min(...data.map((d) => xAccessor(d).getTime()));
|
|
80
|
+
const maxTime = xDomain ? xDomain[1].getTime() : Math.max(...data.map((d) => xAccessor(d).getTime()));
|
|
81
|
+
const padding = slotWidth / 2;
|
|
82
|
+
return scaleTime().domain([minTime, maxTime]).range([padding, innerWidth - padding]);
|
|
83
|
+
}, [innerWidth, data, xAccessor, slotWidth, xDomain]);
|
|
84
|
+
const yScale = useMemo(() => {
|
|
85
|
+
let minVal = Number.POSITIVE_INFINITY;
|
|
86
|
+
let maxVal = Number.NEGATIVE_INFINITY;
|
|
87
|
+
for (const d of data) {
|
|
88
|
+
const low = d.low;
|
|
89
|
+
const high = d.high;
|
|
90
|
+
if (typeof low === "number" && low < minVal) {
|
|
91
|
+
minVal = low;
|
|
92
|
+
}
|
|
93
|
+
if (typeof high === "number" && high > maxVal) {
|
|
94
|
+
maxVal = high;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (minVal === Number.POSITIVE_INFINITY) {
|
|
98
|
+
minVal = 0;
|
|
99
|
+
}
|
|
100
|
+
if (maxVal === Number.NEGATIVE_INFINITY) {
|
|
101
|
+
maxVal = 100;
|
|
102
|
+
}
|
|
103
|
+
const padding = (maxVal - minVal) * 0.05 || 1;
|
|
104
|
+
return scaleLinear().domain([minVal - padding, maxVal + padding]).nice().range([innerHeight, 0]);
|
|
105
|
+
}, [innerHeight, data]);
|
|
106
|
+
const columnWidth = slotWidth;
|
|
107
|
+
const bandWidth = candleWidthProp ?? slotWidth * (1 - candleGap);
|
|
108
|
+
const lines = useMemo(
|
|
109
|
+
() => [
|
|
110
|
+
{ dataKey: "close", stroke: "var(--chart-line-primary)", strokeWidth: 0 }
|
|
111
|
+
],
|
|
112
|
+
[]
|
|
113
|
+
);
|
|
114
|
+
const renderData = useMemo(
|
|
115
|
+
() => decimateOhlcData(data, maxRenderPointsForWidth(innerWidth)),
|
|
116
|
+
[data, innerWidth]
|
|
117
|
+
);
|
|
118
|
+
const dateLabels = useMemo(
|
|
119
|
+
() => data.map((d) => shortDateFmt.format(xAccessor(d))),
|
|
120
|
+
[data, xAccessor]
|
|
121
|
+
);
|
|
122
|
+
const [revealKey, setRevealKey] = useState({
|
|
123
|
+
animationDuration,
|
|
124
|
+
revealSignature
|
|
125
|
+
});
|
|
126
|
+
if (revealKey.animationDuration !== animationDuration || revealKey.revealSignature !== revealSignature) {
|
|
127
|
+
setRevealKey({ animationDuration, revealSignature });
|
|
128
|
+
setRevealEpoch((n) => n + 1);
|
|
129
|
+
setIsLoaded(false);
|
|
130
|
+
}
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
const timer = setTimeout(() => setIsLoaded(true), animationDuration);
|
|
133
|
+
return () => clearTimeout(timer);
|
|
134
|
+
}, [animationDuration, revealSignature]);
|
|
135
|
+
const { hoverStore, interactionHandlers, interactionStyle } = useChartInteraction({
|
|
136
|
+
xScale,
|
|
137
|
+
yScale,
|
|
138
|
+
yScales: wrapSingleYScale(yScale),
|
|
139
|
+
data,
|
|
140
|
+
lines,
|
|
141
|
+
margin,
|
|
142
|
+
xAccessor,
|
|
143
|
+
bisectDate,
|
|
144
|
+
canInteract: isLoaded
|
|
145
|
+
});
|
|
146
|
+
const { tooltipData, setTooltipData, selection, clearSelection } = useSyncExternalStore(
|
|
147
|
+
hoverStore.subscribe,
|
|
148
|
+
hoverStore.getSnapshot,
|
|
149
|
+
hoverStore.getSnapshot
|
|
150
|
+
);
|
|
151
|
+
const hoveredCandleIndex = tooltipData?.index ?? null;
|
|
152
|
+
const isDefsComponent = (child) => {
|
|
153
|
+
const displayName = child.type?.displayName || child.type?.name || "";
|
|
154
|
+
return displayName.includes("Gradient") || displayName.includes("Pattern") || displayName === "LinearGradient" || displayName === "RadialGradient" || displayName === "Lines" || displayName === "PatternLines";
|
|
155
|
+
};
|
|
156
|
+
const defsChildren = [];
|
|
157
|
+
const clipExcludedChildren = [];
|
|
158
|
+
const underlayChildren = [];
|
|
159
|
+
const preOverlayChildren = [];
|
|
160
|
+
const postOverlayChildren = [];
|
|
161
|
+
Children.forEach(children, (rawChild) => {
|
|
162
|
+
if (!isValidElement(rawChild)) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const child = renderableChartChild(rawChild);
|
|
166
|
+
const resolvedChild = resolveChartChildElement(rawChild);
|
|
167
|
+
if (isDefsComponent(resolvedChild)) {
|
|
168
|
+
defsChildren.push(child);
|
|
169
|
+
} else if (isPostOverlayComponent(resolvedChild)) {
|
|
170
|
+
postOverlayChildren.push(child);
|
|
171
|
+
} else if (isClipExcludedComponent(resolvedChild)) {
|
|
172
|
+
clipExcludedChildren.push(child);
|
|
173
|
+
} else if (isUnderlayComponent(resolvedChild)) {
|
|
174
|
+
underlayChildren.push(child);
|
|
175
|
+
} else {
|
|
176
|
+
preOverlayChildren.push(child);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
const referenceAreas = useMemo(
|
|
180
|
+
() => extractReferenceAreaConfigs(children),
|
|
181
|
+
[children]
|
|
182
|
+
);
|
|
183
|
+
const yScales = useMemo(() => wrapSingleYScale(yScale), [yScale]);
|
|
184
|
+
const contextValue = useMemo(
|
|
185
|
+
() => ({
|
|
186
|
+
...DEFAULT_CHART_LIFECYCLE,
|
|
187
|
+
data,
|
|
188
|
+
renderData,
|
|
189
|
+
xScale,
|
|
190
|
+
yScale,
|
|
191
|
+
yScales,
|
|
192
|
+
width,
|
|
193
|
+
height,
|
|
194
|
+
innerWidth,
|
|
195
|
+
innerHeight,
|
|
196
|
+
margin,
|
|
197
|
+
columnWidth,
|
|
198
|
+
tooltipData,
|
|
199
|
+
setTooltipData,
|
|
200
|
+
containerRef,
|
|
201
|
+
lines,
|
|
202
|
+
referenceAreas,
|
|
203
|
+
isLoaded,
|
|
204
|
+
animationDuration,
|
|
205
|
+
enterTransition,
|
|
206
|
+
revealEpoch,
|
|
207
|
+
xAccessor,
|
|
208
|
+
dateLabels,
|
|
209
|
+
selection: selection ?? null,
|
|
210
|
+
clearSelection,
|
|
211
|
+
bandWidth,
|
|
212
|
+
hoveredCandleIndex
|
|
213
|
+
}),
|
|
214
|
+
[
|
|
215
|
+
data,
|
|
216
|
+
renderData,
|
|
217
|
+
xScale,
|
|
218
|
+
yScale,
|
|
219
|
+
yScales,
|
|
220
|
+
width,
|
|
221
|
+
height,
|
|
222
|
+
innerWidth,
|
|
223
|
+
innerHeight,
|
|
224
|
+
margin,
|
|
225
|
+
columnWidth,
|
|
226
|
+
tooltipData,
|
|
227
|
+
setTooltipData,
|
|
228
|
+
containerRef,
|
|
229
|
+
lines,
|
|
230
|
+
referenceAreas,
|
|
231
|
+
isLoaded,
|
|
232
|
+
animationDuration,
|
|
233
|
+
enterTransition,
|
|
234
|
+
revealEpoch,
|
|
235
|
+
xAccessor,
|
|
236
|
+
dateLabels,
|
|
237
|
+
selection,
|
|
238
|
+
clearSelection,
|
|
239
|
+
bandWidth,
|
|
240
|
+
hoveredCandleIndex
|
|
241
|
+
]
|
|
242
|
+
);
|
|
243
|
+
return /* @__PURE__ */ jsx(ChartProvider, { value: contextValue, children: /* @__PURE__ */ jsxs(
|
|
244
|
+
"svg",
|
|
245
|
+
{
|
|
246
|
+
"aria-hidden": "true",
|
|
247
|
+
className: "overflow-visible",
|
|
248
|
+
height,
|
|
249
|
+
width,
|
|
250
|
+
children: [
|
|
251
|
+
/* @__PURE__ */ jsxs("defs", { children: [
|
|
252
|
+
/* @__PURE__ */ jsxs("linearGradient", { id: "candlestick-positive", x1: "0", x2: "0", y1: "1", y2: "0", children: [
|
|
253
|
+
/* @__PURE__ */ jsx(
|
|
254
|
+
"stop",
|
|
255
|
+
{
|
|
256
|
+
offset: "0%",
|
|
257
|
+
stopColor: "var(--chart-positive, var(--chart-positive))"
|
|
258
|
+
}
|
|
259
|
+
),
|
|
260
|
+
/* @__PURE__ */ jsx(
|
|
261
|
+
"stop",
|
|
262
|
+
{
|
|
263
|
+
offset: "100%",
|
|
264
|
+
stopColor: "var(--chart-positive, var(--chart-positive))"
|
|
265
|
+
}
|
|
266
|
+
)
|
|
267
|
+
] }),
|
|
268
|
+
/* @__PURE__ */ jsxs("linearGradient", { id: "candlestick-negative", x1: "0", x2: "0", y1: "1", y2: "0", children: [
|
|
269
|
+
/* @__PURE__ */ jsx(
|
|
270
|
+
"stop",
|
|
271
|
+
{
|
|
272
|
+
offset: "0%",
|
|
273
|
+
stopColor: "var(--chart-negative, var(--chart-negative))"
|
|
274
|
+
}
|
|
275
|
+
),
|
|
276
|
+
/* @__PURE__ */ jsx(
|
|
277
|
+
"stop",
|
|
278
|
+
{
|
|
279
|
+
offset: "100%",
|
|
280
|
+
stopColor: "var(--chart-negative, var(--chart-negative))"
|
|
281
|
+
}
|
|
282
|
+
)
|
|
283
|
+
] }),
|
|
284
|
+
defsChildren
|
|
285
|
+
] }),
|
|
286
|
+
/* @__PURE__ */ jsx("rect", { fill: "transparent", height, width, x: 0, y: 0 }),
|
|
287
|
+
/* @__PURE__ */ jsxs(
|
|
288
|
+
"g",
|
|
289
|
+
{
|
|
290
|
+
...interactionHandlers,
|
|
291
|
+
style: interactionStyle,
|
|
292
|
+
transform: `translate(${margin.left},${margin.top})`,
|
|
293
|
+
children: [
|
|
294
|
+
/* @__PURE__ */ jsx(
|
|
295
|
+
"rect",
|
|
296
|
+
{
|
|
297
|
+
fill: "transparent",
|
|
298
|
+
height: innerHeight,
|
|
299
|
+
width: innerWidth,
|
|
300
|
+
x: 0,
|
|
301
|
+
y: 0
|
|
302
|
+
}
|
|
303
|
+
),
|
|
304
|
+
clipExcludedChildren,
|
|
305
|
+
underlayChildren,
|
|
306
|
+
preOverlayChildren,
|
|
307
|
+
postOverlayChildren
|
|
308
|
+
]
|
|
309
|
+
}
|
|
310
|
+
)
|
|
311
|
+
]
|
|
312
|
+
}
|
|
313
|
+
) });
|
|
314
|
+
});
|
|
315
|
+
function CandlestickChart({
|
|
316
|
+
data: dataProp,
|
|
317
|
+
xDataKey = "date",
|
|
318
|
+
margin: marginProp,
|
|
319
|
+
animationDuration = 1100,
|
|
320
|
+
enterTransition,
|
|
321
|
+
revealSignature,
|
|
322
|
+
aspectRatio = "2 / 1",
|
|
323
|
+
className = "",
|
|
324
|
+
style,
|
|
325
|
+
candleGap = 0.2,
|
|
326
|
+
candleWidth,
|
|
327
|
+
xDomain,
|
|
328
|
+
xDomainSlotCount,
|
|
329
|
+
children
|
|
330
|
+
}) {
|
|
331
|
+
const { data } = useChartDataOverride("CandlestickChart", {
|
|
332
|
+
data: dataProp
|
|
333
|
+
});
|
|
334
|
+
const containerRef = useRef(null);
|
|
335
|
+
const margin = { ...DEFAULT_MARGIN, ...marginProp };
|
|
336
|
+
const dataAsRecords = data;
|
|
337
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domAnimation, children: /* @__PURE__ */ jsx(
|
|
338
|
+
"div",
|
|
339
|
+
{
|
|
340
|
+
className: cn("relative w-full", className),
|
|
341
|
+
ref: containerRef,
|
|
342
|
+
style: { aspectRatio, touchAction: "none", ...style },
|
|
343
|
+
children: /* @__PURE__ */ jsx(ParentSize, { debounceTime: 10, children: ({ width, height }) => /* @__PURE__ */ jsx(
|
|
344
|
+
ChartInner,
|
|
345
|
+
{
|
|
346
|
+
animationDuration,
|
|
347
|
+
candleGap,
|
|
348
|
+
candleWidthProp: candleWidth,
|
|
349
|
+
containerRef,
|
|
350
|
+
data: dataAsRecords,
|
|
351
|
+
enterTransition,
|
|
352
|
+
height,
|
|
353
|
+
margin,
|
|
354
|
+
revealSignature,
|
|
355
|
+
width,
|
|
356
|
+
xDataKey,
|
|
357
|
+
xDomain,
|
|
358
|
+
xDomainSlotCount,
|
|
359
|
+
children
|
|
360
|
+
}
|
|
361
|
+
) })
|
|
362
|
+
}
|
|
363
|
+
) });
|
|
364
|
+
}
|
|
365
|
+
CandlestickChart.displayName = "CandlestickChart";
|
|
366
|
+
var candlestick_chart_default = CandlestickChart;
|
|
367
|
+
export {
|
|
368
|
+
CandlestickChart,
|
|
369
|
+
candlestick_chart_default as default
|
|
370
|
+
};
|