basalt-ui 2.21.0 → 2.23.0
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/CHANGELOG.md +60 -0
- package/MIGRATING.md +452 -12
- package/agent/agents/basalt-design-reviewer.md +1 -1
- package/agent/rules/basalt-tokens.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +1 -1
- package/agent/skills/basalt-design/references/anti-defaults.md +1 -1
- package/agent/skills/basalt-design/references/catalogue.md +1 -0
- package/dist/charts/BandStrip.d.ts.map +1 -1
- package/dist/charts/BandStrip.js +73 -3
- package/dist/charts/Bars.d.ts.map +1 -1
- package/dist/charts/Bars.js +6 -0
- package/dist/charts/CartesianChart.d.ts +10 -0
- package/dist/charts/CartesianChart.d.ts.map +1 -1
- package/dist/charts/CartesianChart.js +8 -5
- package/dist/charts/ChartCard.d.ts +12 -3
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +39 -8
- package/dist/charts/DualPanel.d.ts.map +1 -1
- package/dist/charts/DualPanel.js +5 -8
- package/dist/charts/Heatmap.d.ts +12 -1
- package/dist/charts/Heatmap.d.ts.map +1 -1
- package/dist/charts/Heatmap.js +34 -5
- package/dist/charts/Lines.d.ts +3 -0
- package/dist/charts/Lines.d.ts.map +1 -1
- package/dist/charts/Lines.js +29 -6
- package/dist/charts/MirroredBars.d.ts.map +1 -1
- package/dist/charts/MirroredBars.js +4 -6
- package/dist/charts/Sparkline.d.ts +14 -2
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +101 -22
- package/dist/charts/StackedArea.d.ts +4 -1
- package/dist/charts/StackedArea.d.ts.map +1 -1
- package/dist/charts/StackedArea.js +9 -3
- package/dist/charts/band-fold.d.ts +38 -1
- package/dist/charts/band-fold.d.ts.map +1 -1
- package/dist/charts/band-fold.js +18 -1
- package/dist/charts/chart-box.module.css +19 -0
- package/dist/charts/chart-card.module.css +25 -0
- package/dist/charts/chart-dates.d.ts +12 -0
- package/dist/charts/chart-dates.d.ts.map +1 -0
- package/dist/charts/chart-dates.js +16 -0
- package/dist/charts/chart-legend.module.css +7 -0
- package/dist/charts/compile.d.ts +25 -6
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +152 -72
- package/dist/charts/date-tick-format.d.ts +5 -5
- package/dist/charts/date-tick-format.d.ts.map +1 -1
- package/dist/charts/date-tick-format.js +3 -7
- package/dist/charts/labels.d.ts +21 -6
- package/dist/charts/labels.d.ts.map +1 -1
- package/dist/charts/labels.js +52 -17
- package/dist/charts/legend.d.ts +2 -0
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +7 -21
- package/dist/charts/marks.js +1 -1
- package/dist/charts/panel.d.ts +0 -6
- package/dist/charts/panel.d.ts.map +1 -1
- package/dist/charts/panel.js +1 -10
- package/dist/charts/ref-label.d.ts +43 -0
- package/dist/charts/ref-label.d.ts.map +1 -0
- package/dist/charts/ref-label.js +75 -0
- package/dist/charts/scales.d.ts +4 -1
- package/dist/charts/scales.d.ts.map +1 -1
- package/dist/charts/scales.js +14 -3
- package/dist/charts/sparkline.module.css +13 -17
- package/dist/charts/sparkline.module.css.d.ts +1 -2
- package/dist/charts/state.d.ts +2 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +5 -2
- package/dist/charts/types.d.ts +18 -8
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.d.ts +1 -0
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +1 -0
- package/dist/cli/init.d.ts +2 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +68 -4
- package/dist/cli/shot/capture.d.ts +21 -2
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +202 -36
- package/dist/cli/shot/detect.d.ts.map +1 -1
- package/dist/cli/shot/detect.js +17 -1
- package/dist/cli/shot/playwright.d.ts +13 -2
- package/dist/cli/shot/playwright.d.ts.map +1 -1
- package/dist/cli/shot/playwright.js +5 -1
- package/dist/cli/shot/types.d.ts +4 -0
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/shot/types.js +2 -0
- package/dist/cli/tokens-css.d.ts +5 -7
- package/dist/cli/tokens-css.d.ts.map +1 -1
- package/dist/cli/tokens-css.js +11 -12
- package/dist/controls/controls.module.css +11 -1
- package/dist/controls/filter-pill.d.ts.map +1 -1
- package/dist/controls/filter-pill.js +1 -0
- package/dist/controls/sync-button.d.ts.map +1 -1
- package/dist/controls/sync-button.js +22 -3
- package/dist/controls/sync-button.module.css +34 -2
- package/dist/controls/sync-button.module.css.d.ts +1 -0
- package/dist/dashboard/bar-list.d.ts +6 -1
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +15 -8
- package/dist/dashboard/bar-list.module.css +83 -0
- package/dist/dashboard/bar-list.module.css.d.ts +1 -0
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +2 -2
- package/dist/dashboard/index.d.ts +1 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +2 -0
- package/dist/dashboard/meter-model.d.ts +84 -5
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +100 -15
- package/dist/dashboard/meter-parts.d.ts +9 -1
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +276 -74
- package/dist/dashboard/meter.d.ts +54 -65
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +21 -4
- package/dist/dashboard/meter.module.css +76 -0
- package/dist/dashboard/meter.module.css.d.ts +6 -0
- package/dist/dashboard/page-summary.d.ts +20 -0
- package/dist/dashboard/page-summary.d.ts.map +1 -0
- package/dist/dashboard/page-summary.js +28 -0
- package/dist/dashboard/page-summary.module.css +89 -0
- package/dist/dashboard/page-summary.module.css.d.ts +15 -0
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +1 -1
- package/dist/dashboard/section.d.ts +25 -2
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.js +10 -5
- package/dist/dashboard/section.module.css +23 -0
- package/dist/dashboard/section.module.css.d.ts +1 -0
- package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
- package/dist/dashboard/stat-card-parts.js +1 -1
- package/dist/dashboard/stat-card.d.ts +4 -2
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +7 -5
- package/dist/dashboard/stat-card.module.css +36 -0
- package/dist/dashboard/stat-group.module.css +7 -0
- package/dist/dashboard/stat-strip.d.ts +22 -6
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +104 -60
- package/dist/dashboard/stat-strip.module.css +122 -53
- package/dist/dashboard/stat-strip.module.css.d.ts +4 -0
- package/dist/dashboard/visual-slot.d.ts +7 -1
- package/dist/dashboard/visual-slot.d.ts.map +1 -1
- package/dist/dashboard/visual-slot.js +3 -1
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +0 -5
- package/dist/guard/vx-names.d.ts.map +1 -1
- package/dist/guard/vx-names.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/styles.css +43 -4
- package/dist/theme/chrome-vars.d.ts +20 -5
- package/dist/theme/chrome-vars.d.ts.map +1 -1
- package/dist/theme/chrome-vars.js +46 -3
- package/dist/theme/controls.module.css +37 -0
- package/dist/theme/controls.module.css.d.ts +2 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +18 -27
- package/dist/theme/status-verdict.d.ts.map +1 -1
- package/dist/theme/status-verdict.js +9 -1
- package/dist/tokens/core.d.ts +2 -1
- package/dist/tokens/core.d.ts.map +1 -1
- package/dist/tokens/core.js +6 -1
- package/dist/tokens/derive.d.ts +3 -1
- package/dist/tokens/derive.d.ts.map +1 -1
- package/dist/tokens/derive.js +16 -1
- package/dist/tokens/palette.d.ts +11 -10
- package/dist/tokens/palette.d.ts.map +1 -1
- package/dist/tokens/palette.js +11 -10
- package/dist/tokens/status-text.d.ts.map +1 -1
- package/dist/tokens/status-text.js +3 -1
- package/llms.txt +42 -22
- package/package.json +1 -1
- package/src/charts/BandStrip.tsx +83 -3
- package/src/charts/Bars.tsx +7 -0
- package/src/charts/CartesianChart.tsx +18 -3
- package/src/charts/ChartCard.tsx +54 -13
- package/src/charts/DualPanel.tsx +3 -6
- package/src/charts/Heatmap.tsx +54 -5
- package/src/charts/Lines.tsx +56 -10
- package/src/charts/MirroredBars.tsx +3 -5
- package/src/charts/Sparkline.tsx +135 -25
- package/src/charts/StackedArea.tsx +14 -4
- package/src/charts/band-fold.ts +50 -1
- package/src/charts/chart-box.module.css +19 -0
- package/src/charts/chart-card.module.css +25 -0
- package/src/charts/chart-dates.ts +30 -0
- package/src/charts/chart-legend.module.css +7 -0
- package/src/charts/compile.ts +253 -87
- package/src/charts/date-tick-format.ts +10 -13
- package/src/charts/labels.ts +81 -26
- package/src/charts/legend.tsx +10 -20
- package/src/charts/marks.ts +1 -1
- package/src/charts/panel.tsx +1 -16
- package/src/charts/ref-label.ts +131 -0
- package/src/charts/scales.ts +22 -2
- package/src/charts/sparkline.module.css +13 -17
- package/src/charts/sparkline.module.css.d.ts +1 -2
- package/src/charts/state.tsx +9 -4
- package/src/charts/types.ts +18 -8
- package/src/cli/doctor-upgrade.ts +1 -1
- package/src/cli/init.ts +100 -3
- package/src/cli/shot/capture.ts +266 -35
- package/src/cli/shot/detect.ts +18 -1
- package/src/cli/shot/playwright.ts +20 -4
- package/src/cli/shot/types.ts +5 -0
- package/src/cli/tokens-css.ts +18 -20
- package/src/controls/controls.module.css +11 -1
- package/src/controls/filter-pill.tsx +2 -0
- package/src/controls/sync-button.module.css +34 -2
- package/src/controls/sync-button.module.css.d.ts +1 -0
- package/src/controls/sync-button.tsx +40 -4
- package/src/dashboard/bar-list.module.css +83 -0
- package/src/dashboard/bar-list.module.css.d.ts +1 -0
- package/src/dashboard/bar-list.tsx +107 -69
- package/src/dashboard/delta-badge.tsx +6 -2
- package/src/dashboard/index.ts +1 -0
- package/src/dashboard/meter-model.ts +207 -24
- package/src/dashboard/meter-parts.tsx +349 -67
- package/src/dashboard/meter.module.css +76 -0
- package/src/dashboard/meter.module.css.d.ts +6 -0
- package/src/dashboard/meter.tsx +72 -18
- package/src/dashboard/page-summary.module.css +89 -0
- package/src/dashboard/page-summary.module.css.d.ts +15 -0
- package/src/dashboard/page-summary.tsx +95 -0
- package/src/dashboard/query-state.tsx +1 -1
- package/src/dashboard/section.module.css +23 -0
- package/src/dashboard/section.module.css.d.ts +1 -0
- package/src/dashboard/section.tsx +59 -11
- package/src/dashboard/stat-card-parts.tsx +5 -1
- package/src/dashboard/stat-card.module.css +36 -0
- package/src/dashboard/stat-card.tsx +12 -6
- package/src/dashboard/stat-group.module.css +7 -0
- package/src/dashboard/stat-strip.module.css +122 -53
- package/src/dashboard/stat-strip.module.css.d.ts +4 -0
- package/src/dashboard/stat-strip.tsx +176 -91
- package/src/dashboard/visual-slot.ts +12 -3
- package/src/guard/index.ts +0 -5
- package/src/guard/vx-names.ts +2 -0
- package/src/index.ts +2 -0
- package/src/styles.css +43 -4
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +200 -68
- package/src/theme/chrome-vars.ts +77 -8
- package/src/theme/controls.module.css +37 -0
- package/src/theme/controls.module.css.d.ts +2 -0
- package/src/theme/index.ts +22 -32
- package/src/theme/status-verdict.tsx +5 -1
- package/src/tokens/core.ts +4 -1
- package/src/tokens/derive.ts +32 -3
- package/src/tokens/palette.ts +11 -10
- package/src/tokens/status-text.ts +2 -0
package/dist/charts/labels.js
CHANGED
|
@@ -7,41 +7,74 @@ const END_LABEL_MIN_GAP = 13;
|
|
|
7
7
|
const END_LABEL_DX = 6;
|
|
8
8
|
const END_LABEL_GLYPH_EM = 0.85;
|
|
9
9
|
const END_LABEL_FLIP_DY = -9;
|
|
10
|
+
const END_LABEL_FLIP_DY_BELOW = 13;
|
|
11
|
+
const END_LABEL_EDGE = 7;
|
|
10
12
|
function endLabelAnchor(opts) {
|
|
11
13
|
const { fraction, plotWidth, label, fontSize } = opts;
|
|
12
14
|
const room = (1 - fraction) * plotWidth;
|
|
13
15
|
return room >= label.length * fontSize * END_LABEL_GLYPH_EM + END_LABEL_DX ? "start" : "end";
|
|
14
16
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
function spreadLabels(ys, plotHeight) {
|
|
18
|
+
const order = ys.map((y, i) => i).toSorted((a, b) => ys[a] - ys[b]);
|
|
19
|
+
const placed = /* @__PURE__ */ new Map();
|
|
20
|
+
let floor = END_LABEL_EDGE;
|
|
21
|
+
for (const i of order) {
|
|
22
|
+
const at = Math.max(ys[i], floor);
|
|
23
|
+
placed.set(i, at);
|
|
24
|
+
floor = at + END_LABEL_MIN_GAP;
|
|
25
|
+
}
|
|
26
|
+
const top = plotHeight - END_LABEL_EDGE;
|
|
27
|
+
let ceiling = Infinity;
|
|
28
|
+
for (const i of order.toReversed()) {
|
|
29
|
+
const at = Math.min(placed.get(i), ceiling, top);
|
|
30
|
+
placed.set(i, at);
|
|
31
|
+
ceiling = at - END_LABEL_MIN_GAP;
|
|
32
|
+
}
|
|
33
|
+
return ys.map((y, i) => placed.get(i) - y);
|
|
34
|
+
}
|
|
35
|
+
function endLabelPlan(plot, lines, naming = "auto") {
|
|
36
|
+
if (naming === "legend" || plot.y2 !== void 0 || lines.length === 0) return [];
|
|
37
|
+
if (naming === "auto" && (plot.containerClass !== "wide" || lines.length > MAX_END_LABELS))
|
|
38
|
+
return [];
|
|
18
39
|
const last = lines.flatMap((series) => {
|
|
19
|
-
const
|
|
40
|
+
const finite = plot.rows(series.key).filter((r) => r.y !== null);
|
|
41
|
+
const row = finite.at(-1);
|
|
20
42
|
if (row === void 0 || row.y === null) return [];
|
|
21
43
|
const fraction = plot.xFraction(row.x);
|
|
22
44
|
if (fraction === null || fraction < 0 || fraction > 1) return [];
|
|
23
|
-
return [{ series, row, y: row.y, fraction }];
|
|
45
|
+
return [{ series, row, y: row.y, fraction, prev: finite.at(-2)?.y ?? null }];
|
|
24
46
|
});
|
|
25
47
|
const [lo, hi] = plot.yDomain;
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
return last.map(({ series, row, fraction }) => ({
|
|
29
|
-
series,
|
|
30
|
-
row,
|
|
31
|
-
anchor: endLabelAnchor({
|
|
48
|
+
const placed = last.map(({ series, fraction, y, prev }) => {
|
|
49
|
+
const anchor = endLabelAnchor({
|
|
32
50
|
fraction,
|
|
33
51
|
plotWidth: plot.plotWidth,
|
|
34
52
|
label: series.label,
|
|
35
53
|
fontSize: VX.text.micro
|
|
36
|
-
})
|
|
54
|
+
});
|
|
55
|
+
const side = prev !== null && prev > y ? "below" : "above";
|
|
56
|
+
const centre = (y - lo) / (hi - lo || 1) * plot.plotHeight - endLabelOffset(anchor, side).dy;
|
|
57
|
+
return { anchor, side, centre };
|
|
58
|
+
});
|
|
59
|
+
const shifts = spreadLabels(
|
|
60
|
+
placed.map((p) => p.centre),
|
|
61
|
+
plot.plotHeight
|
|
62
|
+
);
|
|
63
|
+
return last.map(({ series, row }, i) => ({
|
|
64
|
+
series,
|
|
65
|
+
row,
|
|
66
|
+
anchor: placed[i].anchor,
|
|
67
|
+
side: placed[i].side,
|
|
68
|
+
nudge: 0 - shifts[i]
|
|
37
69
|
}));
|
|
38
70
|
}
|
|
39
|
-
function endLabelOffset(anchor) {
|
|
40
|
-
|
|
71
|
+
function endLabelOffset(anchor, side = "above") {
|
|
72
|
+
if (anchor === "start") return { dx: END_LABEL_DX, dy: 0 };
|
|
73
|
+
return { dx: -END_LABEL_DX, dy: side === "above" ? END_LABEL_FLIP_DY : END_LABEL_FLIP_DY_BELOW };
|
|
41
74
|
}
|
|
42
75
|
function endLabelMarks(plan) {
|
|
43
76
|
return plan.map(
|
|
44
|
-
({ series, row, anchor }) => decorative(
|
|
77
|
+
({ series, row, anchor, side, nudge }) => decorative(
|
|
45
78
|
text([row], {
|
|
46
79
|
id: `${series.key}-end-label`,
|
|
47
80
|
x: rowX,
|
|
@@ -50,7 +83,8 @@ function endLabelMarks(plan) {
|
|
|
50
83
|
fill: series.color,
|
|
51
84
|
fontSize: VX.text.micro,
|
|
52
85
|
anchor,
|
|
53
|
-
|
|
86
|
+
dx: endLabelOffset(anchor, side).dx,
|
|
87
|
+
dy: endLabelOffset(anchor, side).dy + nudge
|
|
54
88
|
})
|
|
55
89
|
)
|
|
56
90
|
);
|
|
@@ -59,5 +93,6 @@ export {
|
|
|
59
93
|
endLabelAnchor,
|
|
60
94
|
endLabelMarks,
|
|
61
95
|
endLabelOffset,
|
|
62
|
-
endLabelPlan
|
|
96
|
+
endLabelPlan,
|
|
97
|
+
spreadLabels
|
|
63
98
|
};
|
package/dist/charts/legend.d.ts
CHANGED
|
@@ -50,6 +50,8 @@ export type ChartLegendProps<T> = {
|
|
|
50
50
|
onHighlight: (key: string | null) => void;
|
|
51
51
|
/** Keeps the legend's box but shows and offers nothing: a chart with no marks names no series. */
|
|
52
52
|
concealed?: boolean;
|
|
53
|
+
/** `auto` mode only: gone from the wide class up, where end labels name the lines (CSS). */
|
|
54
|
+
hideAtWide?: boolean;
|
|
53
55
|
};
|
|
54
56
|
export declare function ChartLegend<T>(props: ChartLegendProps<T>): ReactElement | null;
|
|
55
57
|
//# sourceMappingURL=legend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legend.d.ts","sourceRoot":"","sources":["../../src/charts/legend.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAA;AAGxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C;;;;;;GAMG;AACH,MAAM,M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AAC,GAAG,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACzC,kGAAkG;IAClG,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,4FAA4F;IAC5F,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,YAAY,GAAG,IAAI,CA4D9E"}
|
package/dist/charts/legend.js
CHANGED
|
@@ -18,7 +18,8 @@ const rowBaseStyle = {
|
|
|
18
18
|
flexWrap: "wrap",
|
|
19
19
|
alignItems: "center",
|
|
20
20
|
rowGap: 4,
|
|
21
|
-
|
|
21
|
+
// The tick step: ticks, legend and tooltip are one size, so a chart card has at most three.
|
|
22
|
+
fontSize: VX.text.micro,
|
|
22
23
|
color: VX.ink2,
|
|
23
24
|
lineHeight: 1.35
|
|
24
25
|
};
|
|
@@ -94,31 +95,15 @@ function Swatch({ s, mode }) {
|
|
|
94
95
|
/* @__PURE__ */ jsx(Swatch, { s, mode: "chips" })
|
|
95
96
|
] });
|
|
96
97
|
if ((s.mark ?? "line") === "line") return /* @__PURE__ */ jsx(LineSwatch, { s, compact: mode === "dots" });
|
|
97
|
-
|
|
98
|
-
return /* @__PURE__ */ jsx(
|
|
99
|
-
"span",
|
|
100
|
-
{
|
|
101
|
-
"aria-hidden": true,
|
|
102
|
-
className: classes.dot,
|
|
103
|
-
style: {
|
|
104
|
-
width: 8,
|
|
105
|
-
height: 8,
|
|
106
|
-
// theme-allow raw-surface — a legend dot is a circle, not a surface corner
|
|
107
|
-
borderRadius: "50%",
|
|
108
|
-
background: swatchFill(s),
|
|
109
|
-
opacity: s.fillOpacity ?? 1,
|
|
110
|
-
flex: "none"
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
);
|
|
98
|
+
const size = mode === "dots" ? 8 : 10;
|
|
114
99
|
return /* @__PURE__ */ jsx(
|
|
115
100
|
"span",
|
|
116
101
|
{
|
|
117
102
|
"aria-hidden": true,
|
|
118
|
-
className: classes.chip,
|
|
103
|
+
className: mode === "dots" ? classes.dot : classes.chip,
|
|
119
104
|
style: {
|
|
120
|
-
width:
|
|
121
|
-
height:
|
|
105
|
+
width: size,
|
|
106
|
+
height: size,
|
|
122
107
|
// theme-allow raw-surface — swatch geometry, not a surface corner
|
|
123
108
|
borderRadius: 2,
|
|
124
109
|
background: swatchFill(s),
|
|
@@ -139,6 +124,7 @@ function ChartLegend(props) {
|
|
|
139
124
|
"data-basalt-chart-legend": props.mode,
|
|
140
125
|
...props.concealed && { "aria-hidden": true },
|
|
141
126
|
...auto && { className: classes.auto },
|
|
127
|
+
...auto && props.hideAtWide && { "data-hide-wide": "" },
|
|
142
128
|
style: rowLayout(props.mode, props.concealed === true),
|
|
143
129
|
children: groups.map((group, gi) => [
|
|
144
130
|
gi > 0 && /* @__PURE__ */ jsx("span", { "aria-hidden": true, style: dividerStyle }, `divider-${gi}`),
|
package/dist/charts/marks.js
CHANGED
|
@@ -26,7 +26,7 @@ function lineMark(plot, s) {
|
|
|
26
26
|
stroke: s.color,
|
|
27
27
|
strokeWidth: s.strokeWidth ?? LINE_STROKE_WIDTH,
|
|
28
28
|
strokeOpacity: (s.strokeOpacity ?? 1) * emphasis(plot.highlighted, s),
|
|
29
|
-
curve: chartCurve(s.curve ?? "
|
|
29
|
+
curve: chartCurve(s.curve ?? "linear"),
|
|
30
30
|
...s.dash === "dashed" && { strokeDasharray: DASH },
|
|
31
31
|
...yScale !== void 0 && { yScale }
|
|
32
32
|
});
|
package/dist/charts/panel.d.ts
CHANGED
|
@@ -48,8 +48,6 @@ export declare const paneY: (opts: {
|
|
|
48
48
|
format: (v: number) => string;
|
|
49
49
|
ticks: number;
|
|
50
50
|
cls: ContainerClass;
|
|
51
|
-
/** The whole chart's height ({@link chartHeightOf}). */
|
|
52
|
-
height: number;
|
|
53
51
|
}) => StoredChartSpec["scales"][string];
|
|
54
52
|
type ChartScale = NonNullable<StoredChartSpec['scales'][string]>['scale'];
|
|
55
53
|
/** The shared x axis (drawn on the bottom pane only): the rung's ticks and format. */
|
|
@@ -59,11 +57,7 @@ export declare const paneX: <X extends ChartX>(opts: {
|
|
|
59
57
|
/** A consumer's x format; absent, the span-aware default ({@link xTickFormat}). */
|
|
60
58
|
format?: ((v: ChartValue) => string) | undefined;
|
|
61
59
|
cls: ContainerClass;
|
|
62
|
-
/** The whole chart's height ({@link chartHeightOf}). */
|
|
63
|
-
height: number;
|
|
64
60
|
}) => StoredChartSpec["scales"][string];
|
|
65
|
-
/** The whole chart's height from one pane's: a pane gets `share` of the height less the gap. */
|
|
66
|
-
export declare const chartHeightOf: (paneHeight: number, share: number, gap: number) => number;
|
|
67
61
|
/** One row per datum for a series: a `null` or non-finite value is kept as a gap. */
|
|
68
62
|
export declare function rowsOf<T, X extends ChartX>(data: readonly T[], x: (d: T) => X, s: ChartSeries<T>): PlotRow<T, X>[];
|
|
69
63
|
export declare function PanelRung<T, X extends ChartX>(props: PanelRungProps<T, X>): ReactElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../../src/charts/panel.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,iBAAiB,EAEjB,eAAe,IAAI,gBAAgB,EACnC,UAAU,EACV,eAAe,EAChB,MAAM,6BAA6B,CAAA;AAIpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,kBAAkB,CAAA;AAKrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EACV,mBAAmB,EACnB,UAAU,EACV,WAAW,EAEX,MAAM,EACN,OAAO,EACR,MAAM,SAAS,C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e,CAAC,QAAQ,CAAC,CAAC,MAAM,CASlC,CAAA;AAEF,KAAK,UAAU,GAAG,WAAW,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;AAEzE,sFAAsF;AACtF,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,MAAM,EAAE,MAAM;IAC5C,KAAK,EAAE,UAAU,CAAA;IACjB,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,CAAA;IACrB,mFAAmF;IACnF,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,KAAK,MAAM,CAAC,GAAG,SAAS,CAAA;IAChD,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,eAAe,CAAC,QAAQ,CAAC,CAAC,MAAM,CAGlC,CAAA;AAEF,qFAAqF;AACrF,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EACxC,IAAI,EAAE,SAAS,CAAC,EAAE,EAClB,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EACd,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,GAChB,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAKjB;AAwGD,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY,CAaxF"}
|
package/dist/charts/panel.js
CHANGED
|
@@ -16,22 +16,14 @@ const paneY = (opts) => ({
|
|
|
16
16
|
cfg: { ticks: opts.ticks },
|
|
17
17
|
axis: { domain: opts.domain, format: opts.format },
|
|
18
18
|
cls: opts.cls,
|
|
19
|
-
height: opts.height,
|
|
20
19
|
side: "left",
|
|
21
20
|
grid: true
|
|
22
21
|
})
|
|
23
22
|
});
|
|
24
23
|
const paneX = (opts) => ({
|
|
25
24
|
scale: opts.scale,
|
|
26
|
-
...xGuide({
|
|
27
|
-
model: opts.model,
|
|
28
|
-
xTicks: void 0,
|
|
29
|
-
format: opts.format,
|
|
30
|
-
cls: opts.cls,
|
|
31
|
-
height: opts.height
|
|
32
|
-
})
|
|
25
|
+
...xGuide({ model: opts.model, xTicks: void 0, format: opts.format, cls: opts.cls })
|
|
33
26
|
});
|
|
34
|
-
const chartHeightOf = (paneHeight, share, gap) => paneHeight > 0 && share > 0 ? paneHeight / share + gap : 0;
|
|
35
27
|
function rowsOf(data, x, s) {
|
|
36
28
|
return data.map((d) => {
|
|
37
29
|
const v = s.getValue(d);
|
|
@@ -132,7 +124,6 @@ function PanelRung(props) {
|
|
|
132
124
|
}
|
|
133
125
|
export {
|
|
134
126
|
PanelRung,
|
|
135
|
-
chartHeightOf,
|
|
136
127
|
paneX,
|
|
137
128
|
paneY,
|
|
138
129
|
rowsOf
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a reference line's caption sits. Pure, so the rule is tested without an engine: a
|
|
3
|
+
* caption takes the first of four spots (end/start of the plot, above/below its line) that stays
|
|
4
|
+
* inside the plot and that no data line runs through; `RefLine.labelPosition` pins one.
|
|
5
|
+
*/
|
|
6
|
+
export type RefLabelPosition = 'end-above' | 'end-below' | 'start-above' | 'start-below';
|
|
7
|
+
/** A data point as a share of the plot width and a y value on the line's own axis. */
|
|
8
|
+
export type RefLabelPoint = {
|
|
9
|
+
fx: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
export declare function refLabelPosition(opts: {
|
|
13
|
+
/** `RefLine.labelPosition`: wins over everything. */
|
|
14
|
+
pinned: RefLabelPosition | undefined;
|
|
15
|
+
/** The default end when nothing constrains it: `true` for a right-axis line. */
|
|
16
|
+
startFirst: boolean;
|
|
17
|
+
value: number;
|
|
18
|
+
domain: readonly [number, number];
|
|
19
|
+
plotWidth: number;
|
|
20
|
+
plotHeight: number;
|
|
21
|
+
label: string;
|
|
22
|
+
fontSize: number;
|
|
23
|
+
/** One polyline per visible series on the line's axis. */
|
|
24
|
+
series: readonly (readonly RefLabelPoint[])[];
|
|
25
|
+
}): RefLabelPosition;
|
|
26
|
+
/**
|
|
27
|
+
* Which side of its line a sparkline's reference label sits on, and its `dy` (the engine centres
|
|
28
|
+
* the text on its y): above by default, below when the line is too near the plot top for the label
|
|
29
|
+
* box to fit above it. The box clears the line by {@link SPARK_LABEL_GAP}, so the dashed rule never
|
|
30
|
+
* strikes the text, and stays inside the plot (`height` less the line inset each side).
|
|
31
|
+
*/
|
|
32
|
+
export declare function referenceLabelPlacement(opts: {
|
|
33
|
+
value: number;
|
|
34
|
+
domain: readonly [number, number];
|
|
35
|
+
height: number;
|
|
36
|
+
/** The plot's margin inside the svg box, px. */
|
|
37
|
+
inset: number;
|
|
38
|
+
fontSize: number;
|
|
39
|
+
}): {
|
|
40
|
+
side: 'above' | 'below';
|
|
41
|
+
dy: number;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=ref-label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ref-label.d.ts","sourceRoot":"","sources":["../../src/charts/ref-label.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,WAAW,GAAG,aAAa,GAAG,aAAa,CAAA;AAExF,sFAAsF;AACtF,MAAM,MAAM,aAAa,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAkDrD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,qDAAqD;IACrD,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAAA;IACpC,gFAAgF;IAChF,UAAU,EAAE,OAAO,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,0DAA0D;IAC1D,MAAM,EAAE,SAAS,CAAC,SAAS,aAAa,EAAE,CAAC,EAAE,CAAA;CAC9C,GAAG,gBAAgB,CA+BnB;AAKD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE;IAC5C,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACjB,GAAG;IAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAS1C"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const GLYPH_EM = 0.62;
|
|
2
|
+
const EDGE_INSET = 6;
|
|
3
|
+
const LINE_GAP = 3;
|
|
4
|
+
const ORDER_END = [
|
|
5
|
+
"end-above",
|
|
6
|
+
"end-below",
|
|
7
|
+
"start-above",
|
|
8
|
+
"start-below"
|
|
9
|
+
];
|
|
10
|
+
const ORDER_START = [
|
|
11
|
+
"start-above",
|
|
12
|
+
"start-below",
|
|
13
|
+
"end-above",
|
|
14
|
+
"end-below"
|
|
15
|
+
];
|
|
16
|
+
function yRangeWithin(points, fx0, fx1) {
|
|
17
|
+
let lo = Infinity;
|
|
18
|
+
let hi = -Infinity;
|
|
19
|
+
const take = (y) => {
|
|
20
|
+
if (y < lo) lo = y;
|
|
21
|
+
if (y > hi) hi = y;
|
|
22
|
+
};
|
|
23
|
+
const at = (a, b, fx) => b.fx === a.fx ? a.y : a.y + (b.y - a.y) * (fx - a.fx) / (b.fx - a.fx);
|
|
24
|
+
for (let i = 0; i < points.length; i++) {
|
|
25
|
+
const p = points[i];
|
|
26
|
+
if (p.fx >= fx0 && p.fx <= fx1) take(p.y);
|
|
27
|
+
const next = points[i + 1];
|
|
28
|
+
if (next === void 0 || p.fx < fx0 && next.fx < fx0 || p.fx > fx1 && next.fx > fx1)
|
|
29
|
+
continue;
|
|
30
|
+
for (const edge of [fx0, fx1]) {
|
|
31
|
+
if (p.fx < edge && next.fx > edge || p.fx > edge && next.fx < edge)
|
|
32
|
+
take(at(p.fx < next.fx ? p : next, p.fx < next.fx ? next : p, edge));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return lo <= hi ? [lo, hi] : null;
|
|
36
|
+
}
|
|
37
|
+
function refLabelPosition(opts) {
|
|
38
|
+
const { pinned, startFirst, value, plotWidth, plotHeight, label, fontSize, series } = opts;
|
|
39
|
+
const order = startFirst ? ORDER_START : ORDER_END;
|
|
40
|
+
if (pinned !== void 0) return pinned;
|
|
41
|
+
const [lo, hi] = [Math.min(...opts.domain), Math.max(...opts.domain)];
|
|
42
|
+
if (hi === lo || plotWidth <= 0 || plotHeight <= 0) return order[0];
|
|
43
|
+
const perPx = (hi - lo) / plotHeight;
|
|
44
|
+
const widthFx = (label.length * fontSize * GLYPH_EM + EDGE_INSET) / plotWidth;
|
|
45
|
+
const heightPx = fontSize + 2;
|
|
46
|
+
const bandOf = (position) => position.endsWith("above") ? [value + LINE_GAP * perPx, value + (LINE_GAP + heightPx) * perPx] : [value - (LINE_GAP + heightPx) * perPx, value - LINE_GAP * perPx];
|
|
47
|
+
const inPlot = (position) => {
|
|
48
|
+
const [from, to] = bandOf(position);
|
|
49
|
+
return from >= lo && to <= hi;
|
|
50
|
+
};
|
|
51
|
+
const clear = (position) => {
|
|
52
|
+
const [from, to] = bandOf(position);
|
|
53
|
+
const [fx0, fx1] = position.startsWith("end") ? [1 - widthFx, 1 - EDGE_INSET / plotWidth] : [EDGE_INSET / plotWidth, widthFx];
|
|
54
|
+
return series.every((points) => {
|
|
55
|
+
const range = yRangeWithin(points, fx0, fx1);
|
|
56
|
+
return range === null || range[1] < from || range[0] > to;
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
return order.find((p) => inPlot(p) && clear(p)) ?? order.find(inPlot) ?? order[0];
|
|
60
|
+
}
|
|
61
|
+
const SPARK_LABEL_GAP = 2;
|
|
62
|
+
function referenceLabelPlacement(opts) {
|
|
63
|
+
const { value, domain, height, inset, fontSize } = opts;
|
|
64
|
+
const [lo, hi] = [Math.min(...domain), Math.max(...domain)];
|
|
65
|
+
const share = hi === lo ? 0 : (value - lo) / (hi - lo);
|
|
66
|
+
const line = inset + (height - 2 * inset) * (1 - share);
|
|
67
|
+
const reach = SPARK_LABEL_GAP + fontSize + 1;
|
|
68
|
+
const side = line - reach >= 0 || line + reach > height ? "above" : "below";
|
|
69
|
+
const dy = (SPARK_LABEL_GAP + (fontSize + 1) / 2) * (side === "above" ? -1 : 1);
|
|
70
|
+
return { side, dy };
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
refLabelPosition,
|
|
74
|
+
referenceLabelPlacement
|
|
75
|
+
};
|
package/dist/charts/scales.d.ts
CHANGED
|
@@ -11,7 +11,10 @@ export declare function padAutoUpper(candidate: number, pad: number): number;
|
|
|
11
11
|
* axis — a target past the data must stay inside the plot. Infinite bounds clamp to the domain by
|
|
12
12
|
* definition and are ignored. The 1.x law, unchanged (`resolveAxisDomain`).
|
|
13
13
|
*/
|
|
14
|
-
export declare function resolveYDomain<T>(cfg: AxisConfig<T> | undefined, data: readonly T[], series: readonly ChartSeries<T>[], extraBounds?: readonly number[]
|
|
14
|
+
export declare function resolveYDomain<T>(cfg: AxisConfig<T> | undefined, data: readonly T[], series: readonly ChartSeries<T>[], extraBounds?: readonly number[],
|
|
15
|
+
/** The number of ticks the axis will draw (0: none, or its own tick values): when set, an AUTO
|
|
16
|
+
* domain ends on a tick at or above the data's maximum. */
|
|
17
|
+
tickCount?: number): readonly [number, number];
|
|
15
18
|
/** A configured y scale instance for a resolved domain. */
|
|
16
19
|
export declare function yScaleFor<T>(cfg: AxisConfig<T> | undefined, domain: readonly [number, number]): ReturnType<typeof scaleLinear> | ReturnType<typeof scaleLog<number, number>>;
|
|
17
20
|
export type XKind = 'date' | 'number' | 'string';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scales.d.ts","sourceRoot":"","sources":["../../src/charts/scales.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAE5D,OAAO,
|
|
1
|
+
{"version":3,"file":"scales.d.ts","sourceRoot":"","sources":["../../src/charts/scales.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAE5D,OAAO,EAA2B,QAAQ,EAAY,MAAM,UAAU,CAAA;AACtE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAIzE,gGAAgG;AAChG,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAGnE;AAED,mGAAmG;AACnG,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAGnE;AAmBD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,EAC9B,IAAI,EAAE,SAAS,CAAC,EAAE,EAClB,MAAM,EAAE,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,EACjC,WAAW,GAAE,SAAS,MAAM,EAAO;AACnC;2DAC2D;AAC3D,SAAS,SAAI,GACZ,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAiC3B;AAED,2DAA2D;AAC3D,wBAAgB,SAAS,CAAC,CAAC,EACzB,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,EAC9B,MAAM,EAAE,SAAS,CAAC,MAA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AAS,CAAC,CAAC,CAAC,EAClB,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GACpB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAOlC"}
|
package/dist/charts/scales.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { scaleBand } from "@tanstack/charts/scales/band";
|
|
2
2
|
import { scaleLinear } from "@tanstack/charts/scales/linear";
|
|
3
3
|
import { scalePoint } from "@tanstack/charts/scales/point";
|
|
4
|
-
import { scaleLog, scaleUtc } from "d3-scale";
|
|
4
|
+
import { scaleLinear as d3Linear, scaleLog, scaleUtc } from "d3-scale";
|
|
5
5
|
const DEFAULT_AUTO_PAD = 1.1;
|
|
6
6
|
function padAutoLower(candidate, pad) {
|
|
7
7
|
if (candidate === 0) return 0;
|
|
@@ -11,7 +11,18 @@ function padAutoUpper(candidate, pad) {
|
|
|
11
11
|
if (candidate === 0) return 0;
|
|
12
12
|
return candidate > 0 ? candidate * pad : candidate / pad;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function coverTop(lower, upper, max, count) {
|
|
15
|
+
let top = upper;
|
|
16
|
+
for (let i = 0; i < 4; i++) {
|
|
17
|
+
const ticks = d3Linear().domain([lower, top]).ticks(count);
|
|
18
|
+
const last = ticks.at(-1);
|
|
19
|
+
const step = ticks.length > 1 ? ticks[1] - ticks[0] : 0;
|
|
20
|
+
if (last === void 0 || step <= 0 || last >= max) return top;
|
|
21
|
+
top = last + step;
|
|
22
|
+
}
|
|
23
|
+
return top;
|
|
24
|
+
}
|
|
25
|
+
function resolveYDomain(cfg, data, series, extraBounds = [], tickCount = 0) {
|
|
15
26
|
const domain = cfg?.domain ?? "auto";
|
|
16
27
|
if (Array.isArray(domain)) return domain;
|
|
17
28
|
if (typeof domain === "function") return domain(data, series);
|
|
@@ -36,7 +47,7 @@ function resolveYDomain(cfg, data, series, extraBounds = []) {
|
|
|
36
47
|
const upper = padAutoUpper(Math.max(max, cfg?.autoMaxFloor ?? -Infinity), pad);
|
|
37
48
|
const lower = padAutoLower(Math.min(min, cfg?.autoMinCeil ?? 0), pad);
|
|
38
49
|
if (lower === upper) return [Math.min(lower, 0), upper === 0 ? 1 : upper * pad];
|
|
39
|
-
return [lower, upper];
|
|
50
|
+
return [lower, tickCount > 0 && !cfg?.nice ? coverTop(lower, upper, max, tickCount) : upper];
|
|
40
51
|
}
|
|
41
52
|
function yScaleFor(cfg, domain) {
|
|
42
53
|
const extent = [domain[0], domain[1]];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* The sparkline's hover / focus readout: one quiet chip, never a floating tooltip, so a narrow cell
|
|
3
|
-
* cannot be escaped. It sits
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* cannot be escaped. It sits INSIDE the plot box, beside the hovered point (the roomier side, so it
|
|
4
|
+
* flips at the edges) and on the half of the box away from the point, so it covers neither the dot
|
|
5
|
+
* nor anything the host draws round the sparkline (a card's delta period, a strip's caption): a chip
|
|
6
|
+
* above the box landed on that text, and a host slot that clips took it off the page. Where it
|
|
7
|
+
* crosses the line it is opaque, so it reads over it. Placement is inline (`Sparkline.tsx`).
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
.root {
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
.readout {
|
|
15
15
|
position: absolute;
|
|
16
|
-
bottom: 100%;
|
|
17
16
|
z-index: 1;
|
|
17
|
+
max-height: 100%;
|
|
18
18
|
max-width: 100%;
|
|
19
19
|
box-sizing: border-box;
|
|
20
20
|
padding: 0 4px;
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
23
23
|
font-variant-numeric: lining-nums;
|
|
24
24
|
font-size: var(--vx-text-xs);
|
|
25
|
-
/* The
|
|
26
|
-
* value (`stat-card.module.css`, `stat-strip.module.css`)
|
|
25
|
+
/* The chip's height: hosts that reserve a line for it set `--basalt-spark-readout-h` to the same
|
|
26
|
+
* value (`stat-card.module.css`, `stat-strip.module.css`). */
|
|
27
27
|
block-size: var(--basalt-spark-readout-h, 1.125rem);
|
|
28
28
|
line-height: calc(var(--basalt-spark-readout-h, 1.125rem) - 2px);
|
|
29
29
|
color: var(--vx-tooltip-text);
|
|
@@ -35,19 +35,15 @@
|
|
|
35
35
|
border-radius: var(--vx-radius-ctrl);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
.start {
|
|
39
|
-
left: 0;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.end {
|
|
43
|
-
right: 0;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
38
|
.label {
|
|
47
|
-
font-family: var(--basalt-font-mono);
|
|
48
39
|
opacity: 0.7;
|
|
49
40
|
}
|
|
50
41
|
|
|
42
|
+
.layer {
|
|
43
|
+
position: absolute;
|
|
44
|
+
pointer-events: none;
|
|
45
|
+
}
|
|
46
|
+
|
|
51
47
|
.dot {
|
|
52
48
|
position: absolute;
|
|
53
49
|
width: 6px;
|
package/dist/charts/state.d.ts
CHANGED
|
@@ -21,5 +21,7 @@ export declare function ChartPlaceholder(props: {
|
|
|
21
21
|
/** For a box too small to hold a sentence (a sparkline): error and empty show a `—` and carry the
|
|
22
22
|
* label as the accessible name and the hover title. */
|
|
23
23
|
compact?: boolean;
|
|
24
|
+
/** Error only: what failed to load, "Could not load {noun}". Default: no noun. */
|
|
25
|
+
noun?: string;
|
|
24
26
|
}): ReactElement | null;
|
|
25
27
|
//# sourceMappingURL=state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/charts/state.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAiB,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAKnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,IAAI,CAAA;AAErE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,kBAAkB,CAMnF;
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/charts/state.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAiB,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAKnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,IAAI,CAAA;AAErE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,kBAAkB,CAMnF;AAsDD;8EAC8E;AAC9E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,KAAK,EAAE,UAAU,GAAG,SAAS,CAAA;IAC7B,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,8DAA8D;IAC9D,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB;2DACuD;IACvD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,kFAAkF;IAClF,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,GAAG,YAAY,GAAG,IAAI,CAuDtB"}
|
package/dist/charts/state.js
CHANGED
|
@@ -37,6 +37,8 @@ const dotStyle = {
|
|
|
37
37
|
const errorStyle = {
|
|
38
38
|
...boxStyle,
|
|
39
39
|
alignItems: "flex-start",
|
|
40
|
+
justifyContent: "flex-start",
|
|
41
|
+
paddingBottom: VX.space.controlGap,
|
|
40
42
|
textAlign: "start",
|
|
41
43
|
fontSize: VX.text.sm,
|
|
42
44
|
gap: VX.space.controlGap
|
|
@@ -49,7 +51,7 @@ const errorHeadStyle = {
|
|
|
49
51
|
fontWeight: 500
|
|
50
52
|
};
|
|
51
53
|
const errorMessageStyle = { color: VX.muted };
|
|
52
|
-
const emptyLabel = (state) => typeof state?.empty === "string" ? state.empty : "
|
|
54
|
+
const emptyLabel = (state) => typeof state?.empty === "string" ? state.empty : "Nothing recorded in this range.";
|
|
53
55
|
function ChartPlaceholder(props) {
|
|
54
56
|
const kind = resolveChartState(props.state);
|
|
55
57
|
if (kind === null) return null;
|
|
@@ -63,7 +65,8 @@ function ChartPlaceholder(props) {
|
|
|
63
65
|
const body = props.compact ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\u2014" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
64
66
|
kind === "error" && /* @__PURE__ */ jsxs("span", { style: errorHeadStyle, children: [
|
|
65
67
|
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", "data-basalt-status-dot": "", style: dotStyle }),
|
|
66
|
-
"Could not load
|
|
68
|
+
"Could not load",
|
|
69
|
+
props.noun === void 0 ? "" : ` ${props.noun}`
|
|
67
70
|
] }),
|
|
68
71
|
/* @__PURE__ */ jsx("span", { style: errorMessageStyle, children: label }),
|
|
69
72
|
kind === "error" && props.onRetry !== void 0 && /* @__PURE__ */ jsx(RetryButton, { onClick: props.onRetry, retrying: props.retrying ?? false }),
|
package/dist/charts/types.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { StoredChartSpec } from '@tanstack/charts/types/core';
|
|
|
6
6
|
import type { BasaltProps } from '../common/props.js';
|
|
7
7
|
import type { ContainerClass } from '../tokens/size-classes.js';
|
|
8
8
|
import type { CurveName } from './curves.js';
|
|
9
|
+
import type { RefLabelPosition } from './ref-label.js';
|
|
9
10
|
/** What `x` may return. The value type picks the x scale (§ 9.4): `Date` → time, `number` → linear,
|
|
10
11
|
* `string` → point (lines) or band (bars). */
|
|
11
12
|
export type ChartX = Date | number | string;
|
|
@@ -25,8 +26,10 @@ export type ChartSeries<T> = {
|
|
|
25
26
|
mark?: 'line' | 'bar' | 'area' | undefined;
|
|
26
27
|
/** Default `'solid'`; `'dashed'` is `VX.dashArray` on the line, the legend and the tooltip. */
|
|
27
28
|
dash?: 'solid' | 'dashed' | undefined;
|
|
28
|
-
/** Interpolation between points. Default `'
|
|
29
|
-
*
|
|
29
|
+
/** Interpolation between points. Default `'linear'`: discrete values (a daily total, a monthly
|
|
30
|
+
* rate) are joined by straight segments, never by a smoothed curve with crossings between points
|
|
31
|
+
* that never happened. `'monotone'` is an opt-in for a continuous measure; a piecewise-constant
|
|
32
|
+
* quantity (a price tier, a config value) is a step. */
|
|
30
33
|
curve?: CurveName | undefined;
|
|
31
34
|
strokeWidth?: number | undefined;
|
|
32
35
|
/**
|
|
@@ -142,11 +145,17 @@ export type RefLine = {
|
|
|
142
145
|
dashed?: boolean | undefined;
|
|
143
146
|
axis?: 'left' | 'right' | undefined;
|
|
144
147
|
/**
|
|
145
|
-
* Names the line on the plot: a small muted caption
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
+
* Names the line on the plot: a small muted caption on one of four spots (the plot's end or
|
|
149
|
+
* start, above or below the line). It follows the legend toggle. The ink is `--vx-ink2`, never
|
|
150
|
+
* the line colour.
|
|
148
151
|
*/
|
|
149
152
|
label?: string | undefined;
|
|
153
|
+
/**
|
|
154
|
+
* Pins the caption's spot. Default: the first spot (the plot's right end above the line; the left
|
|
155
|
+
* end for a right-axis line) that stays inside the plot and that no data line runs through, so a
|
|
156
|
+
* line in the top or bottom quarter, or one a series ends on, moves its caption.
|
|
157
|
+
*/
|
|
158
|
+
labelPosition?: RefLabelPosition | undefined;
|
|
150
159
|
/**
|
|
151
160
|
* Names the line in the legend (its color, dashed as `dashed`; a toggle hides the line), so a
|
|
152
161
|
* threshold needs no always-`null` series. `mark` is the swatch shape. Default `'line'`. The
|
|
@@ -176,8 +185,9 @@ export type ChartTooltipRow = {
|
|
|
176
185
|
swatch?: 'solid' | 'dashed' | undefined;
|
|
177
186
|
};
|
|
178
187
|
export type ChartTooltipConfig<T, X extends ChartX = ChartX> = {
|
|
179
|
-
/** The tooltip title. Default:
|
|
180
|
-
* `
|
|
188
|
+
/** The tooltip title. Default: a Date x reads weekday, day, month and year in the page locale
|
|
189
|
+
* (`Tue 1 Sep 2026`; a non-day instant adds its time) whatever `formatX` shortens the ticks to;
|
|
190
|
+
* any other x goes through `formatX`. */
|
|
181
191
|
formatHeader?: ((x: X, d: T) => string) | undefined;
|
|
182
192
|
/** Rows after the per-series rows (a total, a zone badge, a context line). `visible`/`hidden` are
|
|
183
193
|
* the legend's split, so a row never names a series the plot no longer draws. */
|
|
@@ -288,7 +298,7 @@ export type CartesianChartProps<T, X extends ChartX = ChartX> = BasaltProps & {
|
|
|
288
298
|
xDomain?: readonly [X, X] | undefined;
|
|
289
299
|
/**
|
|
290
300
|
* Tick label for an x value. Default: compact numbers, strings verbatim, and dates by tick step
|
|
291
|
-
* (`HH:MM` with the day on midnight, `
|
|
301
|
+
* (`HH:MM` with the day on midnight, the day (`4 Oct`, in the page locale), a month with the year on January; a label recurs
|
|
292
302
|
* only behind a day or year label).
|
|
293
303
|
*/
|
|
294
304
|
formatX?: ((x: X) => string) | undefined;
|