@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,197 @@
|
|
|
1
|
+
import {
|
|
2
|
+
curveLinear,
|
|
3
|
+
curveMonotoneX,
|
|
4
|
+
curveNatural,
|
|
5
|
+
curveStep,
|
|
6
|
+
area as d3Area,
|
|
7
|
+
line as d3Line
|
|
8
|
+
} from "d3-shape";
|
|
9
|
+
const curves = {
|
|
10
|
+
linear: curveLinear,
|
|
11
|
+
monotone: curveMonotoneX,
|
|
12
|
+
natural: curveNatural,
|
|
13
|
+
step: curveStep
|
|
14
|
+
};
|
|
15
|
+
function resolveSparklinePadding(padding, fallback) {
|
|
16
|
+
if (typeof padding === "number" || padding === void 0) {
|
|
17
|
+
const p = padding ?? fallback;
|
|
18
|
+
return { top: p, right: p, bottom: p, left: p };
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
top: padding.top ?? fallback,
|
|
22
|
+
right: padding.right ?? fallback,
|
|
23
|
+
bottom: padding.bottom ?? fallback,
|
|
24
|
+
left: padding.left ?? fallback
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function resolveSparklineValues(data, dataKey) {
|
|
28
|
+
return data.map((datum, index) => {
|
|
29
|
+
const raw = typeof dataKey === "function" ? dataKey(datum, index) : datum[dataKey];
|
|
30
|
+
const value = typeof raw === "number" ? raw : Number(raw);
|
|
31
|
+
return raw === null || raw === void 0 ? Number.NaN : value;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function computeSparklineDomain(values, options = {}) {
|
|
35
|
+
let min = Number.POSITIVE_INFINITY;
|
|
36
|
+
let max = Number.NEGATIVE_INFINITY;
|
|
37
|
+
for (const value of values) {
|
|
38
|
+
if (Number.isFinite(value)) {
|
|
39
|
+
if (value < min) {
|
|
40
|
+
min = value;
|
|
41
|
+
}
|
|
42
|
+
if (value > max) {
|
|
43
|
+
max = value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (min === Number.POSITIVE_INFINITY) {
|
|
48
|
+
min = 0;
|
|
49
|
+
max = 0;
|
|
50
|
+
}
|
|
51
|
+
if (options.includeZero) {
|
|
52
|
+
min = Math.min(min, 0);
|
|
53
|
+
max = Math.max(max, 0);
|
|
54
|
+
}
|
|
55
|
+
min = options.yDomain?.[0] ?? min;
|
|
56
|
+
max = options.yDomain?.[1] ?? max;
|
|
57
|
+
if (min === max) {
|
|
58
|
+
return [min - 1, max + 1];
|
|
59
|
+
}
|
|
60
|
+
return [min, max];
|
|
61
|
+
}
|
|
62
|
+
function computeSparklineLayout(values, options) {
|
|
63
|
+
const { width, height, padding, domain, kind } = options;
|
|
64
|
+
const innerWidth = Math.max(0, width - padding.left - padding.right);
|
|
65
|
+
const innerHeight = Math.max(0, height - padding.top - padding.bottom);
|
|
66
|
+
const [d0, d1] = domain;
|
|
67
|
+
const yOf = (value) => padding.top + innerHeight - (value - d0) / (d1 - d0) * innerHeight;
|
|
68
|
+
const n = values.length;
|
|
69
|
+
const band = kind === "band" && n > 0 ? innerWidth / n : 0;
|
|
70
|
+
const step = n > 1 ? innerWidth / (n - 1) : 0;
|
|
71
|
+
const points = values.map((value, i) => ({
|
|
72
|
+
x: kind === "band" ? padding.left + band * (i + 0.5) : padding.left + (n > 1 ? step * i : innerWidth / 2),
|
|
73
|
+
y: Number.isFinite(value) ? yOf(value) : Number.NaN,
|
|
74
|
+
value
|
|
75
|
+
}));
|
|
76
|
+
const baseline = Math.min(Math.max(0, d0), d1);
|
|
77
|
+
return { points, baselineY: yOf(baseline), band, domain };
|
|
78
|
+
}
|
|
79
|
+
const isDefined = (point) => Number.isFinite(point.y);
|
|
80
|
+
function buildSparklineLinePath(points, curve) {
|
|
81
|
+
return d3Line().defined(isDefined).x((p) => p.x).y((p) => p.y).curve(curves[curve])(points) ?? "";
|
|
82
|
+
}
|
|
83
|
+
function buildSparklineAreaPath(points, curve, baselineY) {
|
|
84
|
+
return d3Area().defined(isDefined).x((p) => p.x).y0(baselineY).y1((p) => p.y).curve(curves[curve])(points) ?? "";
|
|
85
|
+
}
|
|
86
|
+
const round = (value) => Math.round(value * 100) / 100;
|
|
87
|
+
function buildSparklineBarSegment(cx, barWidth, y, baselineY, radius) {
|
|
88
|
+
const height = Math.abs(baselineY - y);
|
|
89
|
+
if (height === 0 || barWidth <= 0) {
|
|
90
|
+
return "";
|
|
91
|
+
}
|
|
92
|
+
const x0 = round(cx - barWidth / 2);
|
|
93
|
+
const x1 = round(cx + barWidth / 2);
|
|
94
|
+
const r = Math.min(radius, barWidth / 2, height);
|
|
95
|
+
const up = y < baselineY;
|
|
96
|
+
const tip = round(y);
|
|
97
|
+
const base = round(baselineY);
|
|
98
|
+
if (r <= 0) {
|
|
99
|
+
return `M${x0},${base}V${tip}H${x1}V${base}Z`;
|
|
100
|
+
}
|
|
101
|
+
const dir = up ? 1 : -1;
|
|
102
|
+
const rr = round(r);
|
|
103
|
+
const sweep = up ? 1 : 0;
|
|
104
|
+
return `M${x0},${base}V${round(tip + dir * r)}A${rr},${rr} 0 0 ${sweep} ${round(x0 + r)},${tip}H${round(x1 - r)}A${rr},${rr} 0 0 ${sweep} ${x1},${round(tip + dir * r)}V${base}Z`;
|
|
105
|
+
}
|
|
106
|
+
function sparklineBarWidth(band, gap) {
|
|
107
|
+
return Math.max(1, band - gap);
|
|
108
|
+
}
|
|
109
|
+
function buildSparklineBarsPath(layout, options) {
|
|
110
|
+
const barWidth = sparklineBarWidth(layout.band, options.gap);
|
|
111
|
+
let d = "";
|
|
112
|
+
for (const point of layout.points) {
|
|
113
|
+
if (Number.isFinite(point.y)) {
|
|
114
|
+
d += buildSparklineBarSegment(
|
|
115
|
+
point.x,
|
|
116
|
+
barWidth,
|
|
117
|
+
point.y,
|
|
118
|
+
layout.baselineY,
|
|
119
|
+
options.radius
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return d;
|
|
124
|
+
}
|
|
125
|
+
function sparklineIndexAtX(x, options) {
|
|
126
|
+
const { count, width, padding, kind } = options;
|
|
127
|
+
if (count === 0) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
const innerWidth = width - padding.left - padding.right;
|
|
131
|
+
if (innerWidth <= 0) {
|
|
132
|
+
return 0;
|
|
133
|
+
}
|
|
134
|
+
const t = (x - padding.left) / innerWidth;
|
|
135
|
+
const raw = kind === "band" ? Math.floor(t * count) : Math.round(t * (count - 1));
|
|
136
|
+
return Math.min(count - 1, Math.max(0, raw));
|
|
137
|
+
}
|
|
138
|
+
function formatCompact(value) {
|
|
139
|
+
return new Intl.NumberFormat("en", {
|
|
140
|
+
notation: "compact",
|
|
141
|
+
maximumFractionDigits: 1
|
|
142
|
+
}).format(value);
|
|
143
|
+
}
|
|
144
|
+
function describeSparkline(values) {
|
|
145
|
+
const finite = values.filter(Number.isFinite);
|
|
146
|
+
if (finite.length === 0) {
|
|
147
|
+
return "Sem dados";
|
|
148
|
+
}
|
|
149
|
+
const first = finite[0];
|
|
150
|
+
const last = finite.at(-1);
|
|
151
|
+
let summary = `${finite.length} points, from ${formatCompact(first)} to ${formatCompact(last)}`;
|
|
152
|
+
if (first !== 0) {
|
|
153
|
+
const change = (last - first) / Math.abs(first) * 100;
|
|
154
|
+
const direction = change >= 0 ? "up" : "down";
|
|
155
|
+
summary += `, ${direction} ${Math.abs(Math.round(change))}%`;
|
|
156
|
+
}
|
|
157
|
+
return summary;
|
|
158
|
+
}
|
|
159
|
+
function interpolateSparklineLayout(from, to, t) {
|
|
160
|
+
const m = from.points.length;
|
|
161
|
+
const n = to.points.length;
|
|
162
|
+
const fromYAt = (i) => {
|
|
163
|
+
if (m === 0) {
|
|
164
|
+
return Number.NaN;
|
|
165
|
+
}
|
|
166
|
+
if (m === n) {
|
|
167
|
+
return from.points[i]?.y ?? Number.NaN;
|
|
168
|
+
}
|
|
169
|
+
const position = n > 1 ? i / (n - 1) * (m - 1) : 0;
|
|
170
|
+
const lo = Math.floor(position);
|
|
171
|
+
const a = from.points[lo]?.y ?? Number.NaN;
|
|
172
|
+
const b = from.points[Math.min(m - 1, lo + 1)]?.y ?? Number.NaN;
|
|
173
|
+
return a + (b - a) * (position - lo);
|
|
174
|
+
};
|
|
175
|
+
return {
|
|
176
|
+
...to,
|
|
177
|
+
baselineY: from.baselineY + (to.baselineY - from.baselineY) * t,
|
|
178
|
+
points: to.points.map((point, i) => {
|
|
179
|
+
const fromY = fromYAt(i);
|
|
180
|
+
return Number.isFinite(fromY) && Number.isFinite(point.y) ? { ...point, y: fromY + (point.y - fromY) * t } : point;
|
|
181
|
+
})
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
export {
|
|
185
|
+
buildSparklineAreaPath,
|
|
186
|
+
buildSparklineBarSegment,
|
|
187
|
+
buildSparklineBarsPath,
|
|
188
|
+
buildSparklineLinePath,
|
|
189
|
+
computeSparklineDomain,
|
|
190
|
+
computeSparklineLayout,
|
|
191
|
+
describeSparkline,
|
|
192
|
+
interpolateSparklineLayout,
|
|
193
|
+
resolveSparklinePadding,
|
|
194
|
+
resolveSparklineValues,
|
|
195
|
+
sparklineBarWidth,
|
|
196
|
+
sparklineIndexAtX
|
|
197
|
+
};
|