@aiconstructions/graficos 0.0.0-stage → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ALTERACOES.md +53 -0
- package/LICENSE-BKLIT +21 -0
- package/LICENSE-visx-pattern +21 -0
- package/README.md +188 -2
- package/dist/aic/cores.js +83 -0
- package/dist/aic/index.js +22 -0
- package/dist/aic/interacao.js +55 -0
- package/dist/charts/animation.js +55 -0
- package/dist/charts/arc-geometry.js +58 -0
- package/dist/charts/arc-path.js +15 -0
- package/dist/charts/area-chart-loading.js +89 -0
- package/dist/charts/area-chart.js +149 -0
- package/dist/charts/area-gradient-defs.js +90 -0
- package/dist/charts/area-value-label-layout.js +70 -0
- package/dist/charts/area-value-labels.js +211 -0
- package/dist/charts/area.js +272 -0
- package/dist/charts/background.js +198 -0
- package/dist/charts/band-config.js +82 -0
- package/dist/charts/band-geometry.js +186 -0
- package/dist/charts/band.js +346 -0
- package/dist/charts/bar-chart-loading.js +27 -0
- package/dist/charts/bar-chart.js +545 -0
- package/dist/charts/bar-depth-geometry.js +18 -0
- package/dist/charts/bar-depth.js +608 -0
- package/dist/charts/bar-lollipop.js +278 -0
- package/dist/charts/bar-squares-layout.js +66 -0
- package/dist/charts/bar-squares.js +467 -0
- package/dist/charts/bar-value-label-layout.js +42 -0
- package/dist/charts/bar-x-axis.js +133 -0
- package/dist/charts/bar-y-axis.js +116 -0
- package/dist/charts/bar.js +457 -0
- package/dist/charts/bollinger.js +49 -0
- package/dist/charts/candlestick-chart.js +370 -0
- package/dist/charts/candlestick.js +368 -0
- package/dist/charts/chart-brush-handle.js +91 -0
- package/dist/charts/chart-brush-layout.js +91 -0
- package/dist/charts/chart-brush-selection-overlay.js +87 -0
- package/dist/charts/chart-brush-state.js +253 -0
- package/dist/charts/chart-brush-track-overlay.js +103 -0
- package/dist/charts/chart-brush.js +517 -0
- package/dist/charts/chart-center-typography.js +8 -0
- package/dist/charts/chart-child-passthrough.js +119 -0
- package/dist/charts/chart-config-context.js +56 -0
- package/dist/charts/chart-context.js +337 -0
- package/dist/charts/chart-crosshair.js +262 -0
- package/dist/charts/chart-data-override.js +186 -0
- package/dist/charts/chart-defs.js +56 -0
- package/dist/charts/chart-formatters.js +77 -0
- package/dist/charts/chart-legend-hover.js +27 -0
- package/dist/charts/chart-legend.js +163 -0
- package/dist/charts/chart-loading-label.js +52 -0
- package/dist/charts/chart-parent-size.js +138 -0
- package/dist/charts/chart-phase.js +29 -0
- package/dist/charts/chart-reveal-clip.js +62 -0
- package/dist/charts/chart-scale.js +19 -0
- package/dist/charts/chart-stat-flow.js +72 -0
- package/dist/charts/choropleth/choropleth-background.js +29 -0
- package/dist/charts/choropleth/choropleth-camera.js +379 -0
- package/dist/charts/choropleth/choropleth-chart.js +644 -0
- package/dist/charts/choropleth/choropleth-context.js +152 -0
- package/dist/charts/choropleth/choropleth-dot-grid.js +293 -0
- package/dist/charts/choropleth/choropleth-feature.js +291 -0
- package/dist/charts/choropleth/choropleth-graticule.js +40 -0
- package/dist/charts/choropleth/choropleth-marker.js +222 -0
- package/dist/charts/choropleth/choropleth-projection.js +37 -0
- package/dist/charts/choropleth/choropleth-tooltip.js +82 -0
- package/dist/charts/choropleth/choropleth-zoom-matrix.js +150 -0
- package/dist/charts/choropleth/index.js +44 -0
- package/dist/charts/choropleth/use-choropleth-zoom-state.js +636 -0
- package/dist/charts/composed-chart.js +346 -0
- package/dist/charts/crosshair-store.js +49 -0
- package/dist/charts/dash-tail-stroke.js +58 -0
- package/dist/charts/date-pill-store.js +50 -0
- package/dist/charts/date-ranges.js +131 -0
- package/dist/charts/deadline.js +295 -0
- package/dist/charts/decimate-time-series.js +112 -0
- package/dist/charts/fade-edges.js +171 -0
- package/dist/charts/fast-path.js +78 -0
- package/dist/charts/filter-data-by-x-domain.js +45 -0
- package/dist/charts/funnel-chart.js +773 -0
- package/dist/charts/gauge-arc-layers.js +479 -0
- package/dist/charts/gauge-dial.js +329 -0
- package/dist/charts/gauge-label-layout.js +148 -0
- package/dist/charts/gauge.js +946 -0
- package/dist/charts/generate-chart-skeleton-data.js +27 -0
- package/dist/charts/gradients.js +158 -0
- package/dist/charts/grid-lines.js +114 -0
- package/dist/charts/grid.js +225 -0
- package/dist/charts/heatmap/generate-heatmap-skeleton-data.js +13 -0
- package/dist/charts/heatmap/heatmap-animation.js +128 -0
- package/dist/charts/heatmap/heatmap-cells.js +519 -0
- package/dist/charts/heatmap/heatmap-chart-loading.js +44 -0
- package/dist/charts/heatmap/heatmap-chart.js +548 -0
- package/dist/charts/heatmap/heatmap-colors.js +127 -0
- package/dist/charts/heatmap/heatmap-context.js +107 -0
- package/dist/charts/heatmap/heatmap-legend-gradient.js +97 -0
- package/dist/charts/heatmap/heatmap-legend-swatch.js +76 -0
- package/dist/charts/heatmap/heatmap-legend.js +165 -0
- package/dist/charts/heatmap/heatmap-pattern-defs.js +37 -0
- package/dist/charts/heatmap/heatmap-rect-cells.js +39 -0
- package/dist/charts/heatmap/heatmap-resolve-separator.js +84 -0
- package/dist/charts/heatmap/heatmap-separator.js +168 -0
- package/dist/charts/heatmap/heatmap-tooltip.js +73 -0
- package/dist/charts/heatmap/heatmap-utils.js +633 -0
- package/dist/charts/heatmap/heatmap-x-axis.js +79 -0
- package/dist/charts/heatmap/heatmap-y-axis.js +72 -0
- package/dist/charts/heatmap/index.js +208 -0
- package/dist/charts/highlight-segment-bounds.js +34 -0
- package/dist/charts/highlight-segment.js +119 -0
- package/dist/charts/index.js +944 -0
- package/dist/charts/indicator-fade.js +44 -0
- package/dist/charts/legend/index.js +22 -0
- package/dist/charts/legend/legend-context.js +47 -0
- package/dist/charts/legend/legend-item.js +30 -0
- package/dist/charts/legend/legend-label.js +14 -0
- package/dist/charts/legend/legend-marker.js +18 -0
- package/dist/charts/legend/legend-progress.js +39 -0
- package/dist/charts/legend/legend-value.js +31 -0
- package/dist/charts/legend/legend.js +69 -0
- package/dist/charts/line-backdrop.js +129 -0
- package/dist/charts/line-chart-loading.js +85 -0
- package/dist/charts/line-chart.js +182 -0
- package/dist/charts/line-loading-pulse.js +185 -0
- package/dist/charts/line-loading-timing.js +12 -0
- package/dist/charts/line-path.js +58 -0
- package/dist/charts/line-series-terminal-marker.js +75 -0
- package/dist/charts/line.js +499 -0
- package/dist/charts/live-line-chart.js +494 -0
- package/dist/charts/live-line.js +277 -0
- package/dist/charts/live-x-axis.js +116 -0
- package/dist/charts/live-y-axis.js +164 -0
- package/dist/charts/loading-sweep.js +344 -0
- package/dist/charts/local-point.js +56 -0
- package/dist/charts/markers/chart-markers.js +149 -0
- package/dist/charts/markers/index.js +14 -0
- package/dist/charts/markers/marker-group.js +411 -0
- package/dist/charts/motion-utils.js +29 -0
- package/dist/charts/notch-gauge-shared.js +146 -0
- package/dist/charts/particle-line.js +1340 -0
- package/dist/charts/path-stroke-utils.js +51 -0
- package/dist/charts/pattern-area.js +127 -0
- package/dist/charts/pattern-preset.js +287 -0
- package/dist/charts/pattern-tile.js +31 -0
- package/dist/charts/patterns/circles.js +62 -0
- package/dist/charts/patterns/constants.js +9 -0
- package/dist/charts/patterns/hexagons.js +38 -0
- package/dist/charts/patterns/index.js +16 -0
- package/dist/charts/patterns/lines.js +65 -0
- package/dist/charts/patterns/path.js +37 -0
- package/dist/charts/patterns/pattern.js +16 -0
- package/dist/charts/patterns/waves.js +40 -0
- package/dist/charts/pie-center-shell.js +127 -0
- package/dist/charts/pie-center.js +87 -0
- package/dist/charts/pie-chart.js +377 -0
- package/dist/charts/pie-context.js +116 -0
- package/dist/charts/pie-slice.js +394 -0
- package/dist/charts/pie-ticks.js +332 -0
- package/dist/charts/profit-loss-legend-hover.js +18 -0
- package/dist/charts/profit-loss-legend.js +53 -0
- package/dist/charts/profit-loss-line.js +162 -0
- package/dist/charts/profit-loss-segments.js +88 -0
- package/dist/charts/projection-config.js +90 -0
- package/dist/charts/projection-line-end-marker.js +50 -0
- package/dist/charts/projection-line.js +466 -0
- package/dist/charts/projection-utils.js +303 -0
- package/dist/charts/radar-area.js +192 -0
- package/dist/charts/radar-axis.js +41 -0
- package/dist/charts/radar-chart.js +184 -0
- package/dist/charts/radar-context.js +104 -0
- package/dist/charts/radar-grid.js +121 -0
- package/dist/charts/radar-labels.js +62 -0
- package/dist/charts/radial-area.js +498 -0
- package/dist/charts/radial-axis.js +652 -0
- package/dist/charts/radial-bar.js +316 -0
- package/dist/charts/radial-center.js +67 -0
- package/dist/charts/radial-chart.js +740 -0
- package/dist/charts/radial-dot-bar-layout.js +68 -0
- package/dist/charts/radial-dot-bar.js +387 -0
- package/dist/charts/radial-geometry.js +114 -0
- package/dist/charts/radial-legend.js +66 -0
- package/dist/charts/radial-line.js +280 -0
- package/dist/charts/radial-ring-bar.js +255 -0
- package/dist/charts/radial-scrubber.js +120 -0
- package/dist/charts/radial-series-color.js +10 -0
- package/dist/charts/reference-area-config.js +43 -0
- package/dist/charts/reference-area-geometry.js +76 -0
- package/dist/charts/reference-area-registration-context.js +10 -0
- package/dist/charts/reference-area.js +241 -0
- package/dist/charts/responsive-chart-label-count.js +18 -0
- package/dist/charts/ring-center.js +78 -0
- package/dist/charts/ring-chart.js +362 -0
- package/dist/charts/ring-context.js +122 -0
- package/dist/charts/ring-grid.js +175 -0
- package/dist/charts/ring-labels.js +109 -0
- package/dist/charts/ring.js +237 -0
- package/dist/charts/sankey/index.js +22 -0
- package/dist/charts/sankey/sankey-chart.js +199 -0
- package/dist/charts/sankey/sankey-context.js +32 -0
- package/dist/charts/sankey/sankey-link.js +232 -0
- package/dist/charts/sankey/sankey-node.js +348 -0
- package/dist/charts/sankey/sankey-tooltip.js +94 -0
- package/dist/charts/scatter-chart-shell.js +279 -0
- package/dist/charts/scatter-chart.js +150 -0
- package/dist/charts/scatter-jitter.js +86 -0
- package/dist/charts/scatter-svg.js +17 -0
- package/dist/charts/scatter.js +92 -0
- package/dist/charts/segment.js +107 -0
- package/dist/charts/series-bar-layout.js +42 -0
- package/dist/charts/series-bar.js +241 -0
- package/dist/charts/series-dash-tail-overlay.js +53 -0
- package/dist/charts/series-highlight-layer.js +43 -0
- package/dist/charts/series-hover-dim.js +32 -0
- package/dist/charts/series-markers.js +239 -0
- package/dist/charts/series-path-utils.js +185 -0
- package/dist/charts/series-point-marker.js +150 -0
- package/dist/charts/sparkline-geometry.js +197 -0
- package/dist/charts/sparkline.js +910 -0
- package/dist/charts/static-chart-preview-context.js +16 -0
- package/dist/charts/sunburst-breadcrumb.js +33 -0
- package/dist/charts/sunburst-center.js +37 -0
- package/dist/charts/sunburst-chart.js +408 -0
- package/dist/charts/sunburst-context.js +140 -0
- package/dist/charts/sunburst-data.js +0 -0
- package/dist/charts/sunburst-hint.js +42 -0
- package/dist/charts/sunburst-labels.js +130 -0
- package/dist/charts/sunburst-segment.js +144 -0
- package/dist/charts/sunburst.js +419 -0
- package/dist/charts/time-series-chart-shell.js +688 -0
- package/dist/charts/tooltip/chart-tooltip.js +516 -0
- package/dist/charts/tooltip/cursor-tooltip-box.js +183 -0
- package/dist/charts/tooltip/date-ticker.js +376 -0
- package/dist/charts/tooltip/index.js +32 -0
- package/dist/charts/tooltip/liquid-glass.js +142 -0
- package/dist/charts/tooltip/tooltip-box.js +502 -0
- package/dist/charts/tooltip/tooltip-content.js +59 -0
- package/dist/charts/tooltip/tooltip-dot.js +170 -0
- package/dist/charts/tooltip/tooltip-indicator.js +175 -0
- package/dist/charts/tooltip/use-delayed-tooltip-data.js +41 -0
- package/dist/charts/tooltip/use-velocity-stretch.js +52 -0
- package/dist/charts/trend-line-utils.js +64 -0
- package/dist/charts/trend-line.js +318 -0
- package/dist/charts/use-animated-band.js +175 -0
- package/dist/charts/use-animated-series-path.js +208 -0
- package/dist/charts/use-animated-y-domains.js +192 -0
- package/dist/charts/use-category-slots.js +29 -0
- package/dist/charts/use-chart-interaction.js +296 -0
- package/dist/charts/use-chart-phase-orchestrator.js +183 -0
- package/dist/charts/use-enter-complete.js +18 -0
- package/dist/charts/use-grid-shimmer.js +88 -0
- package/dist/charts/use-highlight-segment.js +65 -0
- package/dist/charts/use-mount-progress.js +23 -0
- package/dist/charts/use-scatter-chart-interaction.js +364 -0
- package/dist/charts/use-scheduled-tooltip.js +84 -0
- package/dist/charts/visx-pattern.js +30 -0
- package/dist/charts/weekends.js +174 -0
- package/dist/charts/x-axis-hover.js +46 -0
- package/dist/charts/x-axis.js +523 -0
- package/dist/charts/y-axis-scales.js +71 -0
- package/dist/charts/y-axis-ticks.js +22 -0
- package/dist/charts/y-axis.js +233 -0
- package/dist/charts/y-domain-utils.js +189 -0
- package/dist/index.d.ts +7346 -0
- package/dist/index.js +2 -0
- package/dist/lib/utils.js +8 -0
- package/dist/shimmering-text.js +54 -0
- package/package.json +78 -4
- package/tema.css +202 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { AnimatePresence, m } from "motion/react";
|
|
4
|
+
import { useId } from "react";
|
|
5
|
+
import { chartCssVars, useChart } from "./chart-context";
|
|
6
|
+
function useSegmentVisibility() {
|
|
7
|
+
const { selection, innerHeight } = useChart();
|
|
8
|
+
const isVisible = selection?.active === true && Math.abs(selection.endX - selection.startX) > 5;
|
|
9
|
+
return { selection, innerHeight, isVisible };
|
|
10
|
+
}
|
|
11
|
+
function SegmentBackground({
|
|
12
|
+
fill = chartCssVars.segmentBackground
|
|
13
|
+
}) {
|
|
14
|
+
const { selection, innerHeight, isVisible } = useSegmentVisibility();
|
|
15
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: isVisible && selection && /* @__PURE__ */ jsx(
|
|
16
|
+
m.rect,
|
|
17
|
+
{
|
|
18
|
+
animate: { opacity: 1 },
|
|
19
|
+
exit: { opacity: 0 },
|
|
20
|
+
fill,
|
|
21
|
+
height: innerHeight,
|
|
22
|
+
initial: { opacity: 0 },
|
|
23
|
+
transition: { duration: 0.15 },
|
|
24
|
+
width: selection.endX - selection.startX,
|
|
25
|
+
x: selection.startX,
|
|
26
|
+
y: 0
|
|
27
|
+
}
|
|
28
|
+
) });
|
|
29
|
+
}
|
|
30
|
+
SegmentBackground.displayName = "SegmentBackground";
|
|
31
|
+
function SegmentLine({
|
|
32
|
+
x,
|
|
33
|
+
stroke = chartCssVars.segmentLine,
|
|
34
|
+
strokeWidth = 1,
|
|
35
|
+
variant = "dashed",
|
|
36
|
+
visible,
|
|
37
|
+
innerHeight
|
|
38
|
+
}) {
|
|
39
|
+
const gradientId = `segment-line-grad-${useId().replace(/:/g, "")}`;
|
|
40
|
+
if (!visible) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
if (variant === "gradient") {
|
|
44
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
45
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: gradientId, x1: "0%", x2: "0%", y1: "0%", y2: "100%", children: [
|
|
46
|
+
/* @__PURE__ */ jsx("stop", { offset: "0%", style: { stopColor: stroke, stopOpacity: 0 } }),
|
|
47
|
+
/* @__PURE__ */ jsx("stop", { offset: "10%", style: { stopColor: stroke, stopOpacity: 1 } }),
|
|
48
|
+
/* @__PURE__ */ jsx("stop", { offset: "90%", style: { stopColor: stroke, stopOpacity: 1 } }),
|
|
49
|
+
/* @__PURE__ */ jsx("stop", { offset: "100%", style: { stopColor: stroke, stopOpacity: 0 } })
|
|
50
|
+
] }) }),
|
|
51
|
+
/* @__PURE__ */ jsx(
|
|
52
|
+
"line",
|
|
53
|
+
{
|
|
54
|
+
stroke: `url(#${gradientId})`,
|
|
55
|
+
strokeWidth,
|
|
56
|
+
x1: x,
|
|
57
|
+
x2: x,
|
|
58
|
+
y1: 0,
|
|
59
|
+
y2: innerHeight
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
] });
|
|
63
|
+
}
|
|
64
|
+
return /* @__PURE__ */ jsx(
|
|
65
|
+
"line",
|
|
66
|
+
{
|
|
67
|
+
stroke,
|
|
68
|
+
strokeDasharray: variant === "dashed" ? "4,4" : void 0,
|
|
69
|
+
strokeWidth,
|
|
70
|
+
x1: x,
|
|
71
|
+
x2: x,
|
|
72
|
+
y1: 0,
|
|
73
|
+
y2: innerHeight
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
function SegmentLineFrom(props) {
|
|
78
|
+
const { selection, innerHeight, isVisible } = useSegmentVisibility();
|
|
79
|
+
return /* @__PURE__ */ jsx(
|
|
80
|
+
SegmentLine,
|
|
81
|
+
{
|
|
82
|
+
...props,
|
|
83
|
+
innerHeight,
|
|
84
|
+
visible: isVisible,
|
|
85
|
+
x: selection?.startX ?? 0
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
SegmentLineFrom.displayName = "SegmentLineFrom";
|
|
90
|
+
function SegmentLineTo(props) {
|
|
91
|
+
const { selection, innerHeight, isVisible } = useSegmentVisibility();
|
|
92
|
+
return /* @__PURE__ */ jsx(
|
|
93
|
+
SegmentLine,
|
|
94
|
+
{
|
|
95
|
+
...props,
|
|
96
|
+
innerHeight,
|
|
97
|
+
visible: isVisible,
|
|
98
|
+
x: selection?.endX ?? 0
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
SegmentLineTo.displayName = "SegmentLineTo";
|
|
103
|
+
export {
|
|
104
|
+
SegmentBackground,
|
|
105
|
+
SegmentLineFrom,
|
|
106
|
+
SegmentLineTo
|
|
107
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
function computeSeriesBarWidth(input) {
|
|
2
|
+
const {
|
|
3
|
+
innerWidth,
|
|
4
|
+
dataLength,
|
|
5
|
+
columnWidth,
|
|
6
|
+
seriesCount,
|
|
7
|
+
composedBarSize,
|
|
8
|
+
composedMaxBarSize,
|
|
9
|
+
composedBarGap = 4,
|
|
10
|
+
stacked = false
|
|
11
|
+
} = input;
|
|
12
|
+
const gap = composedBarGap;
|
|
13
|
+
const groupCount = stacked ? 1 : Math.max(1, seriesCount);
|
|
14
|
+
let slot = columnWidth;
|
|
15
|
+
if (slot <= 0) {
|
|
16
|
+
slot = dataLength < 2 ? innerWidth : innerWidth / (dataLength - 1);
|
|
17
|
+
}
|
|
18
|
+
let width = composedBarSize ?? Math.min(slot * 0.88, composedMaxBarSize ?? Number.POSITIVE_INFINITY);
|
|
19
|
+
if (composedMaxBarSize != null) {
|
|
20
|
+
width = Math.min(width, composedMaxBarSize);
|
|
21
|
+
}
|
|
22
|
+
if (groupCount > 1) {
|
|
23
|
+
const maxGroup = slot * 0.92;
|
|
24
|
+
const needed = groupCount * width + (groupCount - 1) * gap;
|
|
25
|
+
if (needed > maxGroup && maxGroup > 0) {
|
|
26
|
+
width = Math.max(4, (maxGroup - (groupCount - 1) * gap) / groupCount);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return Math.max(2, width);
|
|
30
|
+
}
|
|
31
|
+
function computeSeriesBarRevealClipPadding(input) {
|
|
32
|
+
const { barWidth, seriesCount, gap = 4, stacked = false } = input;
|
|
33
|
+
if (stacked || seriesCount <= 1) {
|
|
34
|
+
return Math.ceil(barWidth / 2);
|
|
35
|
+
}
|
|
36
|
+
const groupWidth = seriesCount * barWidth + (seriesCount - 1) * gap;
|
|
37
|
+
return Math.ceil(groupWidth / 2);
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
computeSeriesBarRevealClipPadding,
|
|
41
|
+
computeSeriesBarWidth
|
|
42
|
+
};
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { m } from "motion/react";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { chartCssVars, useChart, useYScale } from "./chart-context";
|
|
6
|
+
import { useChartLegendHover } from "./chart-legend-hover";
|
|
7
|
+
import { transitionWithDelay } from "./motion-utils";
|
|
8
|
+
import { computeSeriesBarWidth } from "./series-bar-layout";
|
|
9
|
+
function computeSeriesBarLayout(input) {
|
|
10
|
+
const {
|
|
11
|
+
stacked,
|
|
12
|
+
composedStackOffsets,
|
|
13
|
+
rowIndex,
|
|
14
|
+
dataKey,
|
|
15
|
+
value,
|
|
16
|
+
yScale,
|
|
17
|
+
innerHeight,
|
|
18
|
+
xCenter,
|
|
19
|
+
barWidth,
|
|
20
|
+
seriesCount,
|
|
21
|
+
gap,
|
|
22
|
+
seriesIndex,
|
|
23
|
+
stackGap,
|
|
24
|
+
isLastSeries,
|
|
25
|
+
radius
|
|
26
|
+
} = input;
|
|
27
|
+
if (stacked && composedStackOffsets) {
|
|
28
|
+
const offset = composedStackOffsets.get(rowIndex)?.get(dataKey) ?? 0;
|
|
29
|
+
const valuePos = yScale(value) ?? 0;
|
|
30
|
+
let barHeight = innerHeight - valuePos;
|
|
31
|
+
const offsetY = yScale(offset) ?? innerHeight;
|
|
32
|
+
const gapOffset = seriesIndex * stackGap;
|
|
33
|
+
const valueY2 = offsetY - barHeight - gapOffset;
|
|
34
|
+
if (!isLastSeries && stackGap > 0) {
|
|
35
|
+
barHeight = Math.max(0, barHeight - stackGap);
|
|
36
|
+
}
|
|
37
|
+
const barLeft = xCenter - barWidth / 2;
|
|
38
|
+
const applyRounding = stackGap > 0 || isLastSeries;
|
|
39
|
+
return {
|
|
40
|
+
barLeft,
|
|
41
|
+
barHeight,
|
|
42
|
+
effectiveRadius: applyRounding ? radius : 0,
|
|
43
|
+
valueY: valueY2
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const groupWidth = seriesCount * barWidth + (seriesCount > 1 ? (seriesCount - 1) * gap : 0);
|
|
47
|
+
const valueY = yScale(value) ?? innerHeight;
|
|
48
|
+
return {
|
|
49
|
+
barLeft: xCenter - groupWidth / 2 + seriesIndex * (barWidth + gap),
|
|
50
|
+
barHeight: innerHeight - valueY,
|
|
51
|
+
effectiveRadius: radius,
|
|
52
|
+
valueY
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function SeriesBar({
|
|
56
|
+
dataKey,
|
|
57
|
+
fill = chartCssVars.linePrimary,
|
|
58
|
+
radius = 0,
|
|
59
|
+
animate = true,
|
|
60
|
+
fadedOpacity = 0.3,
|
|
61
|
+
yAxisId
|
|
62
|
+
}) {
|
|
63
|
+
const yScale = useYScale(yAxisId);
|
|
64
|
+
const {
|
|
65
|
+
data,
|
|
66
|
+
xScale,
|
|
67
|
+
xAccessor,
|
|
68
|
+
innerHeight,
|
|
69
|
+
innerWidth,
|
|
70
|
+
columnWidth,
|
|
71
|
+
isLoaded,
|
|
72
|
+
animationDuration,
|
|
73
|
+
enterTransition,
|
|
74
|
+
revealEpoch = 0,
|
|
75
|
+
barScale,
|
|
76
|
+
composedBarDataKeys,
|
|
77
|
+
composedBarSize,
|
|
78
|
+
composedMaxBarSize,
|
|
79
|
+
composedBarGap,
|
|
80
|
+
composedStacked,
|
|
81
|
+
composedStackOffsets,
|
|
82
|
+
composedStackGap,
|
|
83
|
+
tooltipData
|
|
84
|
+
} = useChart();
|
|
85
|
+
const barKeys = useMemo(() => {
|
|
86
|
+
if (composedBarDataKeys && composedBarDataKeys.length > 0) {
|
|
87
|
+
return composedBarDataKeys;
|
|
88
|
+
}
|
|
89
|
+
return [dataKey];
|
|
90
|
+
}, [composedBarDataKeys, dataKey]);
|
|
91
|
+
const seriesIndex = useMemo(() => {
|
|
92
|
+
const idx = barKeys.indexOf(dataKey);
|
|
93
|
+
return idx >= 0 ? idx : 0;
|
|
94
|
+
}, [barKeys, dataKey]);
|
|
95
|
+
const n = barKeys.length;
|
|
96
|
+
const gap = composedBarGap ?? 4;
|
|
97
|
+
const stackGap = composedStackGap ?? 0;
|
|
98
|
+
const stacked = Boolean(composedStacked) && composedStackOffsets != null && composedBarDataKeys != null && composedBarDataKeys.length > 0;
|
|
99
|
+
const isLastSeries = seriesIndex === n - 1;
|
|
100
|
+
const barWidth = useMemo(
|
|
101
|
+
() => computeSeriesBarWidth({
|
|
102
|
+
innerWidth,
|
|
103
|
+
dataLength: data.length,
|
|
104
|
+
columnWidth,
|
|
105
|
+
seriesCount: n,
|
|
106
|
+
composedBarSize,
|
|
107
|
+
composedMaxBarSize,
|
|
108
|
+
composedBarGap: gap,
|
|
109
|
+
stacked
|
|
110
|
+
}),
|
|
111
|
+
[
|
|
112
|
+
columnWidth,
|
|
113
|
+
composedBarSize,
|
|
114
|
+
composedMaxBarSize,
|
|
115
|
+
data.length,
|
|
116
|
+
gap,
|
|
117
|
+
innerWidth,
|
|
118
|
+
n,
|
|
119
|
+
stacked
|
|
120
|
+
]
|
|
121
|
+
);
|
|
122
|
+
const totalAnimDuration = animationDuration || 1100;
|
|
123
|
+
const staggerSpread = totalAnimDuration * 0.4;
|
|
124
|
+
const calculatedStaggerDelay = data.length > 1 ? staggerSpread / 1e3 / data.length : 0;
|
|
125
|
+
const { hoveredIndex: legendHoveredIndex } = useChartLegendHover();
|
|
126
|
+
const isLegendDimmed = legendHoveredIndex !== null && legendHoveredIndex !== seriesIndex;
|
|
127
|
+
const hoveredIndex = tooltipData?.index ?? null;
|
|
128
|
+
if (barScale) {
|
|
129
|
+
console.warn(
|
|
130
|
+
"SeriesBar is for time-based ComposedChart / LineChart context. Use Bar inside BarChart for categorical x."
|
|
131
|
+
);
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
return /* @__PURE__ */ jsx("g", { className: "series-bar", children: data.map((d, i) => {
|
|
135
|
+
const value = d[dataKey];
|
|
136
|
+
if (typeof value !== "number") {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const xCenter = xScale(xAccessor(d)) ?? 0;
|
|
140
|
+
const { barLeft, valueY, barHeight, effectiveRadius } = computeSeriesBarLayout({
|
|
141
|
+
stacked,
|
|
142
|
+
composedStackOffsets,
|
|
143
|
+
rowIndex: i,
|
|
144
|
+
dataKey,
|
|
145
|
+
value,
|
|
146
|
+
yScale,
|
|
147
|
+
innerHeight,
|
|
148
|
+
xCenter,
|
|
149
|
+
barWidth,
|
|
150
|
+
seriesCount: n,
|
|
151
|
+
gap,
|
|
152
|
+
seriesIndex,
|
|
153
|
+
stackGap,
|
|
154
|
+
isLastSeries,
|
|
155
|
+
radius
|
|
156
|
+
});
|
|
157
|
+
const categoryLabel = String(xAccessor(d).getTime());
|
|
158
|
+
const isFaded = hoveredIndex !== null && hoveredIndex !== i || isLegendDimmed;
|
|
159
|
+
if (animate && !isLoaded) {
|
|
160
|
+
return /* @__PURE__ */ jsx(
|
|
161
|
+
SeriesBarRect,
|
|
162
|
+
{
|
|
163
|
+
barHeight,
|
|
164
|
+
barWidth,
|
|
165
|
+
calculatedStaggerDelay,
|
|
166
|
+
enterTransition,
|
|
167
|
+
fadedOpacity,
|
|
168
|
+
fill,
|
|
169
|
+
index: i,
|
|
170
|
+
innerHeight,
|
|
171
|
+
isFaded,
|
|
172
|
+
radius: effectiveRadius,
|
|
173
|
+
revealEpoch,
|
|
174
|
+
x: barLeft,
|
|
175
|
+
y: valueY
|
|
176
|
+
},
|
|
177
|
+
`${dataKey}-${categoryLabel}-${revealEpoch}`
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
return /* @__PURE__ */ jsx(
|
|
181
|
+
m.rect,
|
|
182
|
+
{
|
|
183
|
+
animate: { opacity: isFaded ? fadedOpacity : 1 },
|
|
184
|
+
fill,
|
|
185
|
+
height: barHeight,
|
|
186
|
+
initial: false,
|
|
187
|
+
rx: effectiveRadius,
|
|
188
|
+
ry: effectiveRadius,
|
|
189
|
+
transition: { opacity: { duration: 0.12 } },
|
|
190
|
+
width: barWidth,
|
|
191
|
+
x: barLeft,
|
|
192
|
+
y: valueY
|
|
193
|
+
},
|
|
194
|
+
`${dataKey}-${categoryLabel}`
|
|
195
|
+
);
|
|
196
|
+
}) });
|
|
197
|
+
}
|
|
198
|
+
SeriesBar.displayName = "SeriesBar";
|
|
199
|
+
function SeriesBarRect({
|
|
200
|
+
x,
|
|
201
|
+
y,
|
|
202
|
+
barWidth,
|
|
203
|
+
barHeight,
|
|
204
|
+
fill,
|
|
205
|
+
radius,
|
|
206
|
+
index,
|
|
207
|
+
innerHeight,
|
|
208
|
+
calculatedStaggerDelay,
|
|
209
|
+
enterTransition,
|
|
210
|
+
revealEpoch,
|
|
211
|
+
isFaded,
|
|
212
|
+
fadedOpacity
|
|
213
|
+
}) {
|
|
214
|
+
const enterAnim = transitionWithDelay(
|
|
215
|
+
enterTransition,
|
|
216
|
+
index * calculatedStaggerDelay
|
|
217
|
+
);
|
|
218
|
+
return /* @__PURE__ */ jsx(
|
|
219
|
+
m.rect,
|
|
220
|
+
{
|
|
221
|
+
animate: {
|
|
222
|
+
height: barHeight,
|
|
223
|
+
y,
|
|
224
|
+
opacity: isFaded ? fadedOpacity : 1
|
|
225
|
+
},
|
|
226
|
+
fill,
|
|
227
|
+
initial: { height: 0, y: innerHeight, opacity: 1 },
|
|
228
|
+
rx: radius,
|
|
229
|
+
ry: radius,
|
|
230
|
+
transition: enterAnim,
|
|
231
|
+
width: barWidth,
|
|
232
|
+
x
|
|
233
|
+
},
|
|
234
|
+
`series-bar-${index}-${revealEpoch}`
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
var series_bar_default = SeriesBar;
|
|
238
|
+
export {
|
|
239
|
+
SeriesBar,
|
|
240
|
+
series_bar_default as default
|
|
241
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { memo, useMemo } from "react";
|
|
4
|
+
import { DashTailStroke } from "./dash-tail-stroke";
|
|
5
|
+
import { resolveDashStartX, resolveDashTailBounds } from "./path-stroke-utils";
|
|
6
|
+
function SeriesDashTailOverlayImpl({
|
|
7
|
+
dashFromIndex,
|
|
8
|
+
dashArray,
|
|
9
|
+
data,
|
|
10
|
+
pathD,
|
|
11
|
+
pathLength,
|
|
12
|
+
innerWidth,
|
|
13
|
+
innerHeight,
|
|
14
|
+
stroke,
|
|
15
|
+
strokeWidth,
|
|
16
|
+
xScale,
|
|
17
|
+
xAccessor
|
|
18
|
+
}) {
|
|
19
|
+
const hasDashTail = resolveDashTailBounds(dashFromIndex, data.length);
|
|
20
|
+
const dashStartX = useMemo(() => {
|
|
21
|
+
if (!hasDashTail || dashFromIndex == null) {
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
return resolveDashStartX(data, dashFromIndex, xScale, xAccessor);
|
|
25
|
+
}, [hasDashTail, dashFromIndex, data, xScale, xAccessor]);
|
|
26
|
+
const dashStartLength = useMemo(() => {
|
|
27
|
+
if (!hasDashTail || dashFromIndex == null || pathLength <= 0) {
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
return dashFromIndex / Math.max(1, data.length - 1) * pathLength;
|
|
31
|
+
}, [hasDashTail, dashFromIndex, data.length, pathLength]);
|
|
32
|
+
if (!hasDashTail || dashFromIndex == null || pathLength <= 0) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return /* @__PURE__ */ jsx(
|
|
36
|
+
DashTailStroke,
|
|
37
|
+
{
|
|
38
|
+
dashArray,
|
|
39
|
+
dashStartLength,
|
|
40
|
+
dashStartX,
|
|
41
|
+
innerHeight,
|
|
42
|
+
innerWidth,
|
|
43
|
+
pathD,
|
|
44
|
+
pathLength,
|
|
45
|
+
stroke,
|
|
46
|
+
strokeWidth
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
const SeriesDashTailOverlay = memo(SeriesDashTailOverlayImpl);
|
|
51
|
+
export {
|
|
52
|
+
SeriesDashTailOverlay
|
|
53
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useChartStable } from "./chart-context";
|
|
4
|
+
import {
|
|
5
|
+
HighlightSegment
|
|
6
|
+
} from "./highlight-segment";
|
|
7
|
+
import { useHighlightSegment } from "./use-highlight-segment";
|
|
8
|
+
function SeriesHighlightLayer({
|
|
9
|
+
enabled,
|
|
10
|
+
height,
|
|
11
|
+
pathRef,
|
|
12
|
+
stroke,
|
|
13
|
+
strokeWidth,
|
|
14
|
+
span,
|
|
15
|
+
fadeLength,
|
|
16
|
+
glow
|
|
17
|
+
}) {
|
|
18
|
+
const { isLoaded } = useChartStable();
|
|
19
|
+
const { xSpring, widthSpring, isActive } = useHighlightSegment({
|
|
20
|
+
enabled,
|
|
21
|
+
span
|
|
22
|
+
});
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
HighlightSegment,
|
|
25
|
+
{
|
|
26
|
+
fadeLength,
|
|
27
|
+
glow,
|
|
28
|
+
height,
|
|
29
|
+
pathRef,
|
|
30
|
+
stroke,
|
|
31
|
+
strokeWidth,
|
|
32
|
+
visible: enabled && isActive && isLoaded,
|
|
33
|
+
width: widthSpring,
|
|
34
|
+
x: xSpring
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
SeriesHighlightLayer.displayName = "SeriesHighlightLayer";
|
|
39
|
+
var series_highlight_layer_default = SeriesHighlightLayer;
|
|
40
|
+
export {
|
|
41
|
+
SeriesHighlightLayer,
|
|
42
|
+
series_highlight_layer_default as default
|
|
43
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { m } from "motion/react";
|
|
4
|
+
import { selectIsChartHovering, useChartHoverSelector } from "./chart-context";
|
|
5
|
+
import { useChartLegendHover } from "./chart-legend-hover";
|
|
6
|
+
function SeriesHoverDim({
|
|
7
|
+
enabled = true,
|
|
8
|
+
dimOpacity = 0.5,
|
|
9
|
+
durationSec = 0.4,
|
|
10
|
+
seriesIndex,
|
|
11
|
+
children
|
|
12
|
+
}) {
|
|
13
|
+
const isChartHovering = useChartHoverSelector(selectIsChartHovering);
|
|
14
|
+
const { hoveredIndex: legendHoveredIndex } = useChartLegendHover();
|
|
15
|
+
const isLegendDimmed = legendHoveredIndex !== null && seriesIndex !== void 0 && legendHoveredIndex !== seriesIndex;
|
|
16
|
+
const opacity = enabled && (isChartHovering || isLegendDimmed) ? dimOpacity : 1;
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
m.g,
|
|
19
|
+
{
|
|
20
|
+
animate: { opacity },
|
|
21
|
+
initial: { opacity: 1 },
|
|
22
|
+
transition: { duration: durationSec, ease: "easeInOut" },
|
|
23
|
+
children
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
SeriesHoverDim.displayName = "SeriesHoverDim";
|
|
28
|
+
var series_hover_dim_default = SeriesHoverDim;
|
|
29
|
+
export {
|
|
30
|
+
SeriesHoverDim,
|
|
31
|
+
series_hover_dim_default as default
|
|
32
|
+
};
|