@tangle-network/charts 0.9.0 → 0.9.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/dist/index.js +12 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2641,10 +2641,6 @@ function timeSeries(rows, o) {
|
|
|
2641
2641
|
const xLabel = (x) => o.formatX ? o.formatX(x) : category.get(x) ?? String(x);
|
|
2642
2642
|
const yLabel = (y) => scalarLabel(y, o.y.unit, o.formatY);
|
|
2643
2643
|
const grid = yGridlines(o.y, yLabel);
|
|
2644
|
-
if (axisGutter(grid) >= 270) return {
|
|
2645
|
-
id,
|
|
2646
|
-
refused: "Formatted y-axis labels leave no room for the phone chart. Use a shorter formatter or unit."
|
|
2647
|
-
};
|
|
2648
2644
|
const flat = rows.flatMap((row) => row.points.map((point) => ({
|
|
2649
2645
|
row,
|
|
2650
2646
|
point
|
|
@@ -2656,6 +2652,14 @@ function timeSeries(rows, o) {
|
|
|
2656
2652
|
const hasEvents = marks.length + bands.length > 0;
|
|
2657
2653
|
const groups = bands.some((band) => band.kind === "group");
|
|
2658
2654
|
const stripName = o.y.strip?.trim() || "no value";
|
|
2655
|
+
if (axisGutter(grid) >= 270) return {
|
|
2656
|
+
id,
|
|
2657
|
+
refused: "Formatted y-axis labels leave no room for the phone chart. Use a shorter formatter or unit."
|
|
2658
|
+
};
|
|
2659
|
+
if (stripped.length && axisGutter(grid, stripName) >= 270) return {
|
|
2660
|
+
id,
|
|
2661
|
+
refused: "The strip name leaves no room for the phone chart. Use a shorter y.strip."
|
|
2662
|
+
};
|
|
2659
2663
|
const valueText = (point) => point.y !== null ? yLabel(point.y) : point.verdict !== void 0 ? `${stripName} (${VERDICT_WORD[point.verdict]})` : "not measured";
|
|
2660
2664
|
const facts = (row, point) => [
|
|
2661
2665
|
row.label,
|
|
@@ -2710,14 +2714,14 @@ function timeSeries(rows, o) {
|
|
|
2710
2714
|
};
|
|
2711
2715
|
}
|
|
2712
2716
|
function plot(rows, o, width, xLabel, yLabel, grid, facts, stripName) {
|
|
2713
|
-
const
|
|
2717
|
+
const strip = rows.some((row) => row.points.some((point) => point.y === null && point.verdict !== void 0)) ? 24 : 0;
|
|
2718
|
+
const left = axisGutter(grid, strip ? stripName : void 0);
|
|
2714
2719
|
const right = width - 24;
|
|
2715
2720
|
const axis = xAxis(o.x.domain, o.x.categories, left, right);
|
|
2716
2721
|
const px = axis.px;
|
|
2717
2722
|
const labelRows = markLabelRows(o.marks ?? [], px, left, right);
|
|
2718
2723
|
const top = 36 + (labelRows ? labelRows * 14 + 2 : 0) + groupRowHeight(o.bands), bottom = top + 224;
|
|
2719
2724
|
const py = yScale(o.y.domain, o.y.scale, top, bottom);
|
|
2720
|
-
const strip = rows.some((row) => row.points.some((point) => point.y === null && point.verdict !== void 0)) ? 24 : 0;
|
|
2721
2725
|
let marks = text(left, 18, o.y.label, { cls: "tgc-ink-muted" });
|
|
2722
2726
|
for (const [i, tick] of grid.entries()) marks += line(left, py(tick.at), right, py(tick.at), i === 0 && !o.y.ticks?.length ? "tgc-axis" : "tgc-gridline") + text(left - 8, py(tick.at) + 4, tick.label, {
|
|
2723
2727
|
anchor: "end",
|
|
@@ -2844,8 +2848,8 @@ function plot(rows, o, width, xLabel, yLabel, grid, facts, stripName) {
|
|
|
2844
2848
|
const events = drawMarks(o.marks ?? [], px, top - groupRowHeight(o.bands), bottom, left, right, xLabel, 22);
|
|
2845
2849
|
return `<svg class="tgc-svg tgc-trajectories" xmlns="http://www.w3.org/2000/svg" width="${width}" height="${legendY + 12}" viewBox="0 0 ${width} ${legendY + 12}" role="group" aria-label="${esc(o.y.label)} by ${esc(o.x.label)}"><style>${rules}</style>${marks}${events}${points}${badges}${tips}</svg>`;
|
|
2846
2850
|
}
|
|
2847
|
-
function axisGutter(ticks) {
|
|
2848
|
-
return Math.max(64, ...ticks.map((tick) => Math.ceil(textWidth(tick.label, 12, "mono")) + 20));
|
|
2851
|
+
function axisGutter(ticks, stripName) {
|
|
2852
|
+
return Math.max(64, ...ticks.map((tick) => Math.ceil(textWidth(tick.label, 12, "mono")) + 20), stripName ? Math.ceil(textWidth(stripName, 11)) + 14 : 0);
|
|
2849
2853
|
}
|
|
2850
2854
|
//#endregion
|
|
2851
2855
|
//#region src/small-multiples.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/charts",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Static SVG and HTML figures for benchmarks and operational timing. Draws from producer data and refuses what it cannot draw honestly.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|