@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,253 @@
|
|
|
1
|
+
const BRUSH_SAFE_PIXEL = 2;
|
|
2
|
+
const EMPTY_EXTENT = { x0: -1, x1: -1, y0: -1, y1: -1 };
|
|
3
|
+
function clamp(value, min, max) {
|
|
4
|
+
return Math.min(Math.max(value, min), max);
|
|
5
|
+
}
|
|
6
|
+
function getBrushExtent(start, end, stage) {
|
|
7
|
+
const { direction, width, height } = stage;
|
|
8
|
+
return {
|
|
9
|
+
x0: direction === "vertical" ? 0 : Math.min(start.x || 0, end.x || 0),
|
|
10
|
+
x1: direction === "vertical" ? width : Math.max(start.x || 0, end.x || 0),
|
|
11
|
+
y0: direction === "horizontal" ? 0 : Math.min(start.y || 0, end.y || 0),
|
|
12
|
+
y1: direction === "horizontal" ? height : Math.max(start.y || 0, end.y || 0)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function createBrushState(stage, initial) {
|
|
16
|
+
const extent = initial ? getBrushExtent(initial.start ?? {}, initial.end ?? {}, stage) : { ...EMPTY_EXTENT };
|
|
17
|
+
return {
|
|
18
|
+
start: { x: Math.max(0, extent.x0), y: Math.max(0, extent.y0) },
|
|
19
|
+
end: { x: Math.max(0, extent.x1), y: Math.max(0, extent.y1) },
|
|
20
|
+
extent,
|
|
21
|
+
isBrushing: false,
|
|
22
|
+
brushingType: void 0,
|
|
23
|
+
activeHandle: null
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function idleBrushState() {
|
|
27
|
+
return {
|
|
28
|
+
start: { x: 0, y: 0 },
|
|
29
|
+
end: { x: 0, y: 0 },
|
|
30
|
+
extent: { ...EMPTY_EXTENT },
|
|
31
|
+
isBrushing: false,
|
|
32
|
+
brushingType: void 0,
|
|
33
|
+
activeHandle: null
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function beginBrushSelect(state, point) {
|
|
37
|
+
return {
|
|
38
|
+
...state,
|
|
39
|
+
start: point,
|
|
40
|
+
end: { ...point },
|
|
41
|
+
extent: { ...EMPTY_EXTENT },
|
|
42
|
+
isBrushing: true,
|
|
43
|
+
brushingType: "select"
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function beginBrushDrag(state, type) {
|
|
47
|
+
return { ...state, brushingType: type, isBrushing: true };
|
|
48
|
+
}
|
|
49
|
+
function moveSelection(state, offset, stage) {
|
|
50
|
+
const { start, end } = state;
|
|
51
|
+
const validDx = offset.x > 0 ? Math.min(offset.x, stage.width - end.x) : Math.max(offset.x, 0 - start.x);
|
|
52
|
+
const validDy = offset.y > 0 ? Math.min(offset.y, stage.height - end.y) : Math.max(offset.y, 0 - start.y);
|
|
53
|
+
return {
|
|
54
|
+
...state,
|
|
55
|
+
isBrushing: true,
|
|
56
|
+
extent: {
|
|
57
|
+
...state.extent,
|
|
58
|
+
x0: start.x + validDx,
|
|
59
|
+
x1: end.x + validDx,
|
|
60
|
+
y0: start.y + validDy,
|
|
61
|
+
y1: end.y + validDy
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function dragBrush(state, offset, stage, mode) {
|
|
66
|
+
const { brushingType } = state;
|
|
67
|
+
if (!(state.isBrushing && brushingType)) {
|
|
68
|
+
return state;
|
|
69
|
+
}
|
|
70
|
+
if (brushingType === "move") {
|
|
71
|
+
return moveSelection(state, offset, stage);
|
|
72
|
+
}
|
|
73
|
+
if (brushingType === "select") {
|
|
74
|
+
const end2 = mode === "window" ? {
|
|
75
|
+
x: clamp(state.start.x + offset.x, 0, stage.width),
|
|
76
|
+
y: clamp(state.start.y + offset.y, 0, stage.height)
|
|
77
|
+
} : { x: state.start.x + offset.x, y: state.start.y + offset.y };
|
|
78
|
+
return { ...state, end: end2, extent: getBrushExtent(state.start, end2, stage) };
|
|
79
|
+
}
|
|
80
|
+
if (mode === "window") {
|
|
81
|
+
const { x: x0, y: y0 } = state.start;
|
|
82
|
+
const { x: x1, y: y1 } = state.end;
|
|
83
|
+
return {
|
|
84
|
+
...state,
|
|
85
|
+
isBrushing: true,
|
|
86
|
+
extent: {
|
|
87
|
+
...state.extent,
|
|
88
|
+
...getBrushExtent(
|
|
89
|
+
{
|
|
90
|
+
x: brushingType === "left" ? clamp(x0 + offset.x, 0, stage.width) : x0,
|
|
91
|
+
y: y0
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
x: brushingType === "right" ? clamp(x1 + offset.x, 0, stage.width) : x1,
|
|
95
|
+
y: y1
|
|
96
|
+
},
|
|
97
|
+
stage
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const { start, end } = state;
|
|
103
|
+
if (brushingType === "right") {
|
|
104
|
+
const move2 = Math.max(start.x, end.x) + offset.x;
|
|
105
|
+
return {
|
|
106
|
+
...state,
|
|
107
|
+
activeHandle: "right",
|
|
108
|
+
extent: {
|
|
109
|
+
...state.extent,
|
|
110
|
+
x0: Math.max(Math.min(move2, start.x), 0),
|
|
111
|
+
x1: Math.min(Math.max(move2, start.x), stage.width)
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const move = Math.min(start.x, end.x) + offset.x;
|
|
116
|
+
return {
|
|
117
|
+
...state,
|
|
118
|
+
activeHandle: "left",
|
|
119
|
+
extent: {
|
|
120
|
+
...state.extent,
|
|
121
|
+
x0: Math.min(move, end.x),
|
|
122
|
+
x1: Math.max(move, end.x)
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function endBrush(state, mode) {
|
|
127
|
+
const { brushingType, extent } = state;
|
|
128
|
+
if (!brushingType) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
const idle = {
|
|
132
|
+
isBrushing: false,
|
|
133
|
+
brushingType: void 0,
|
|
134
|
+
activeHandle: null
|
|
135
|
+
};
|
|
136
|
+
if (mode === "window" || brushingType === "move") {
|
|
137
|
+
return {
|
|
138
|
+
state: {
|
|
139
|
+
...state,
|
|
140
|
+
...idle,
|
|
141
|
+
start: {
|
|
142
|
+
x: Math.min(extent.x0, extent.x1),
|
|
143
|
+
y: mode === "window" ? extent.y0 : Math.min(extent.y0, extent.y1)
|
|
144
|
+
},
|
|
145
|
+
end: {
|
|
146
|
+
x: Math.max(extent.x0, extent.x1),
|
|
147
|
+
y: Math.max(extent.y0, extent.y1)
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
changeCount: mode === "window" ? 1 : 2
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
if (brushingType === "select") {
|
|
154
|
+
return {
|
|
155
|
+
state: {
|
|
156
|
+
...state,
|
|
157
|
+
...idle,
|
|
158
|
+
start: { x: extent.x0, y: extent.y0 },
|
|
159
|
+
end: { x: extent.x1, y: extent.y1 }
|
|
160
|
+
},
|
|
161
|
+
changeCount: 1
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
const start = { x: Math.min(extent.x0, extent.x1), y: extent.y0 };
|
|
165
|
+
const end = {
|
|
166
|
+
x: Math.max(extent.x0, extent.x1),
|
|
167
|
+
y: Math.max(extent.y0, extent.y1)
|
|
168
|
+
};
|
|
169
|
+
return {
|
|
170
|
+
state: {
|
|
171
|
+
...state,
|
|
172
|
+
...idle,
|
|
173
|
+
start,
|
|
174
|
+
end,
|
|
175
|
+
extent: {
|
|
176
|
+
x0: Math.min(start.x, end.x),
|
|
177
|
+
x1: Math.max(start.x, end.x),
|
|
178
|
+
y0: Math.min(start.y, end.y),
|
|
179
|
+
y1: Math.max(start.y, end.y)
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
changeCount: 2
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function brushSelectionRect(extent) {
|
|
186
|
+
return {
|
|
187
|
+
x: Math.min(extent.x0, extent.x1),
|
|
188
|
+
y: Math.min(extent.y0, extent.y1),
|
|
189
|
+
width: Math.max(
|
|
190
|
+
Math.max(extent.x0, extent.x1) - Math.min(extent.x0, extent.x1),
|
|
191
|
+
0
|
|
192
|
+
),
|
|
193
|
+
height: Math.max(
|
|
194
|
+
Math.max(extent.y0, extent.y1) - Math.min(extent.y0, extent.y1),
|
|
195
|
+
0
|
|
196
|
+
)
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
function brushHandleRects(extent, handleSize, stageHeight) {
|
|
200
|
+
const offset = handleSize / 2;
|
|
201
|
+
return [
|
|
202
|
+
{
|
|
203
|
+
type: "right",
|
|
204
|
+
x: extent.x1 - offset,
|
|
205
|
+
y: extent.y0 - offset,
|
|
206
|
+
width: handleSize,
|
|
207
|
+
height: stageHeight
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
type: "left",
|
|
211
|
+
x: extent.x0 - offset,
|
|
212
|
+
y: extent.y0 - offset,
|
|
213
|
+
width: handleSize,
|
|
214
|
+
height: stageHeight
|
|
215
|
+
}
|
|
216
|
+
];
|
|
217
|
+
}
|
|
218
|
+
function invertToNumber(invert, value) {
|
|
219
|
+
return Number(invert(value).valueOf());
|
|
220
|
+
}
|
|
221
|
+
function brushExtentToDomain(extent, invert) {
|
|
222
|
+
const { x0, x1 } = extent;
|
|
223
|
+
if (typeof x0 === "undefined" || x0 < 0) {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
const start = x0 || 0;
|
|
227
|
+
const end = x1 || 0;
|
|
228
|
+
const invertedStart = invertToNumber(
|
|
229
|
+
invert,
|
|
230
|
+
start + (start < end ? -BRUSH_SAFE_PIXEL : BRUSH_SAFE_PIXEL)
|
|
231
|
+
);
|
|
232
|
+
const invertedEnd = invertToNumber(
|
|
233
|
+
invert,
|
|
234
|
+
end + (end < start ? -BRUSH_SAFE_PIXEL : BRUSH_SAFE_PIXEL)
|
|
235
|
+
);
|
|
236
|
+
return {
|
|
237
|
+
x0: Math.min(invertedStart, invertedEnd) || 0,
|
|
238
|
+
x1: Math.max(invertedStart, invertedEnd) || 0
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
export {
|
|
242
|
+
BRUSH_SAFE_PIXEL,
|
|
243
|
+
beginBrushDrag,
|
|
244
|
+
beginBrushSelect,
|
|
245
|
+
brushExtentToDomain,
|
|
246
|
+
brushHandleRects,
|
|
247
|
+
brushSelectionRect,
|
|
248
|
+
createBrushState,
|
|
249
|
+
dragBrush,
|
|
250
|
+
endBrush,
|
|
251
|
+
getBrushExtent,
|
|
252
|
+
idleBrushState
|
|
253
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import { useChartPortalContainer, useChartStable } from "./chart-context";
|
|
5
|
+
const BRUSH_TRACK_OUTER_FADE = 0.15;
|
|
6
|
+
function outsidePaneStyle(edge, style) {
|
|
7
|
+
const fadeStop = `${BRUSH_TRACK_OUTER_FADE * 100}%`;
|
|
8
|
+
let mask;
|
|
9
|
+
if (style.fadeOuterEdges) {
|
|
10
|
+
mask = edge === "left" ? `linear-gradient(to right, transparent 0%, black ${fadeStop}, black 100%)` : `linear-gradient(to left, transparent 0%, black ${fadeStop}, black 100%)`;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
pointerEvents: "none",
|
|
14
|
+
backdropFilter: style.blurPx > 0 ? `blur(${style.blurPx}px)` : void 0,
|
|
15
|
+
WebkitBackdropFilter: style.blurPx > 0 ? `blur(${style.blurPx}px)` : void 0,
|
|
16
|
+
maskImage: mask,
|
|
17
|
+
WebkitMaskImage: mask
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function ChartBrushTrackOverlayContent({
|
|
21
|
+
containerRef,
|
|
22
|
+
margin,
|
|
23
|
+
innerWidth,
|
|
24
|
+
innerHeight,
|
|
25
|
+
selectionX0,
|
|
26
|
+
selectionX1,
|
|
27
|
+
blurPx = 1.5,
|
|
28
|
+
fadeOuterEdges = true
|
|
29
|
+
}) {
|
|
30
|
+
const overlayStyle = {
|
|
31
|
+
blurPx: Math.min(5, Math.max(0, blurPx)),
|
|
32
|
+
fadeOuterEdges
|
|
33
|
+
};
|
|
34
|
+
const container = useChartPortalContainer(containerRef);
|
|
35
|
+
if (!container) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const x0 = Math.max(0, Math.min(selectionX0, selectionX1, innerWidth));
|
|
39
|
+
const x1 = Math.max(
|
|
40
|
+
x0,
|
|
41
|
+
Math.min(Math.max(selectionX0, selectionX1), innerWidth)
|
|
42
|
+
);
|
|
43
|
+
const leftWidth = Math.max(0, x0);
|
|
44
|
+
const rightWidth = Math.max(0, innerWidth - x1);
|
|
45
|
+
if (leftWidth <= 0 && rightWidth <= 0) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const plotLeft = margin.left;
|
|
49
|
+
const plotTop = margin.top;
|
|
50
|
+
return createPortal(
|
|
51
|
+
/* @__PURE__ */ jsxs(
|
|
52
|
+
"div",
|
|
53
|
+
{
|
|
54
|
+
"aria-hidden": "true",
|
|
55
|
+
className: "pointer-events-none absolute inset-0 z-[1]",
|
|
56
|
+
children: [
|
|
57
|
+
leftWidth > 0 ? /* @__PURE__ */ jsx(
|
|
58
|
+
"div",
|
|
59
|
+
{
|
|
60
|
+
className: "absolute",
|
|
61
|
+
style: {
|
|
62
|
+
...outsidePaneStyle("left", overlayStyle),
|
|
63
|
+
top: plotTop,
|
|
64
|
+
left: plotLeft,
|
|
65
|
+
width: leftWidth,
|
|
66
|
+
height: innerHeight
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
) : null,
|
|
70
|
+
rightWidth > 0 ? /* @__PURE__ */ jsx(
|
|
71
|
+
"div",
|
|
72
|
+
{
|
|
73
|
+
className: "absolute",
|
|
74
|
+
style: {
|
|
75
|
+
...outsidePaneStyle("right", overlayStyle),
|
|
76
|
+
top: plotTop,
|
|
77
|
+
left: plotLeft + x1,
|
|
78
|
+
width: rightWidth,
|
|
79
|
+
height: innerHeight
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
) : null
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
container
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
function ChartBrushTrackOverlay(props) {
|
|
90
|
+
const { containerRef, margin } = useChartStable();
|
|
91
|
+
return /* @__PURE__ */ jsx(
|
|
92
|
+
ChartBrushTrackOverlayContent,
|
|
93
|
+
{
|
|
94
|
+
...props,
|
|
95
|
+
containerRef,
|
|
96
|
+
margin
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
export {
|
|
101
|
+
ChartBrushTrackOverlay,
|
|
102
|
+
ChartBrushTrackOverlayContent
|
|
103
|
+
};
|