@tangle-network/charts 0.18.1 → 0.20.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/README.md +1 -1
- package/dist/figure.css +8 -8
- package/dist/{flow-trace-BYKE-PMb.d.ts → flow-trace-Sr8GtLm0.d.ts} +34 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +49 -39
- package/dist/react/flow-waterfall.css +76 -25
- package/dist/react/index.d.ts +13 -3
- package/dist/react/index.js +423 -209
- package/dist/{timeline-CVXBpZzt.js → timeline-B7c-cede.js} +13 -13
- package/package.json +1 -1
|
@@ -626,10 +626,10 @@ function drawGroups(bands, extent, top, bottom, left, right, format, clip) {
|
|
|
626
626
|
const from = clip ? Math.max(band.from, clip[0]) : band.from, to = clip ? Math.min(band.to, clip[1]) : band.to;
|
|
627
627
|
if (to < from) return "";
|
|
628
628
|
const [x0, x1] = extent(from, to), w = x1 - x0;
|
|
629
|
-
const label = w >= 24 ? wrap(band.label, w - 10,
|
|
629
|
+
const label = w >= 24 ? wrap(band.label, w - 10, 12, "sans", 1).lines[0] : "";
|
|
630
630
|
const edges = [x0, x1].filter((x) => x > left + .5 && x < right - .5).map((x) => line(x, top - 16, x, bottom, "tgc-group-edge")).join("");
|
|
631
631
|
const bracket = line(x0 + 2, top - 3, x1 - 2, top - 3, "tgc-group-rule") + (label ? text(x0 + 3, top - 7, label, {
|
|
632
|
-
size:
|
|
632
|
+
size: 12,
|
|
633
633
|
cls: "tgc-group-label"
|
|
634
634
|
}) : "");
|
|
635
635
|
return titled(`${band.label}: ${format(band.from)} to ${format(band.to)}`, `<g data-band="group">${edges}${bracket}</g>`);
|
|
@@ -661,7 +661,7 @@ function layoutLabels(groups, left, right, o) {
|
|
|
661
661
|
const taken = Array.from({ length: rows }, () => []);
|
|
662
662
|
const fits = (row, a, b) => taken[row].every(([p, q]) => b + gap <= p || a >= q + gap);
|
|
663
663
|
const place = (value, start, end, prefer, flexible) => {
|
|
664
|
-
const label = wrap(value, maxW,
|
|
664
|
+
const label = wrap(value, maxW, 12, "sans", 1).lines[0], w = textWidth(label, 12);
|
|
665
665
|
for (const anchor of flexible ? [prefer, prefer === "start" ? "end" : "start"] : [prefer]) {
|
|
666
666
|
const [a, b] = anchor === "start" ? [start, start + w] : [end - w, end];
|
|
667
667
|
if (a < left - 4 || b > right + 4) continue;
|
|
@@ -721,13 +721,13 @@ function drawMarks(marks, px, top, bottom, left, right, format, labelTop = top,
|
|
|
721
721
|
for (const group of groups) {
|
|
722
722
|
const spot = placed.get(group);
|
|
723
723
|
if (spot) out += text(spot.x, rowY(spot.row), spot.text, {
|
|
724
|
-
size:
|
|
724
|
+
size: 12,
|
|
725
725
|
anchor: spot.anchor,
|
|
726
726
|
cls: "tgc-mark-label"
|
|
727
727
|
});
|
|
728
728
|
}
|
|
729
729
|
for (const edge of edges) out += `<g data-edge="${edge.anchor === "end" ? "after" : "before"}">${text(edge.x, rowY(edge.row), edge.text, {
|
|
730
|
-
size:
|
|
730
|
+
size: 12,
|
|
731
731
|
anchor: edge.anchor,
|
|
732
732
|
cls: "tgc-mark-label tgc-mark-edge"
|
|
733
733
|
})}</g>`;
|
|
@@ -1012,7 +1012,7 @@ function timeline(lanes, o) {
|
|
|
1012
1012
|
const detail = (lane) => (lane.detail ?? []).filter((fact) => typeof fact === "string" && fact.trim());
|
|
1013
1013
|
const spanLabel = (lane, span) => [`${lane.label}: ${span.state} ${fmt(span.start)} to ${span.end === null ? `now (${fmt(o.now)}, open)` : fmt(span.end)}, ${duration(ends(span) - span.start)}${span.note ? ` · ${span.note}` : ""}`, ...detail(lane)].join("\n");
|
|
1014
1014
|
const hasTicks = rows.some((row) => row.ticks !== void 0);
|
|
1015
|
-
const countWidth = hasTicks ? Math.max(...rows.filter((row) => row.ticks).map((row) => textWidth(counts(row.ticks).text,
|
|
1015
|
+
const countWidth = hasTicks ? Math.max(...rows.filter((row) => row.ticks).map((row) => textWidth(counts(row.ticks).text, 12, "mono"))) : 0;
|
|
1016
1016
|
const draw = (width) => {
|
|
1017
1017
|
const phone = width === 358, indent = phone ? 10 : 12;
|
|
1018
1018
|
const caretX = (depth) => 4 + depth * indent;
|
|
@@ -1031,7 +1031,7 @@ function timeline(lanes, o) {
|
|
|
1031
1031
|
const barTop = (y) => y + (phone ? 19 : 5), barH = 14;
|
|
1032
1032
|
let body = drawBands(bands, px, top, bottom, fmt, [t0, t1]) + drawGroups(bands, (from, to) => [px(from), px(to)], top, bottom, left, right, fmt, [t0, t1]);
|
|
1033
1033
|
for (const t of axisTicks(t0, t1, px, left, right, axisLabel)) body += line(px(t), top, px(t), bottom, "tgc-gridline") + text(px(t), bottom + 16, axisLabel(t), {
|
|
1034
|
-
size:
|
|
1034
|
+
size: 12,
|
|
1035
1035
|
cls: "tgc-ink-muted tgc-num",
|
|
1036
1036
|
anchor: "middle"
|
|
1037
1037
|
});
|
|
@@ -1048,9 +1048,9 @@ function timeline(lanes, o) {
|
|
|
1048
1048
|
body += `<path class="tgc-tree" d="M${x} ${from}V${mid}H${labelX(row.depth) - (row.children ? 13 : 3)}"/>`;
|
|
1049
1049
|
}
|
|
1050
1050
|
const countText = row.ticks ? counts(row.ticks) : void 0;
|
|
1051
|
-
const room = (phone ? width - 12 - (countText ? textWidth(countText.text,
|
|
1052
|
-
const label = wrap(lane.label, Math.max(24, room),
|
|
1053
|
-
const name = `<text class="tgc-ink tgc-lane-label" x="${labelX(row.depth)}" y="${baseline}" font-size="
|
|
1051
|
+
const room = (phone ? width - 12 - (countText ? textWidth(countText.text, 12, "mono") + 8 : 0) : left - 8) - labelX(row.depth) - textWidth(tail(row), 12);
|
|
1052
|
+
const label = wrap(lane.label, Math.max(24, room), 12, "sans", 1).lines[0];
|
|
1053
|
+
const name = `<text class="tgc-ink tgc-lane-label" x="${labelX(row.depth)}" y="${baseline}" font-size="12">${esc(label)}${row.hidden ? `<tspan class="tgc-ink-muted">${esc(tail(row))}</tspan>` : ""}</text>`;
|
|
1054
1054
|
const caret = row.children ? `<path class="tgc-caret" d="${row.folded ? `M${caretX(row.depth)} ${mid - 4}l6 4l-6 4z` : `M${caretX(row.depth) - 1} ${mid - 3}h8l-4 6z`}"/>` : "";
|
|
1055
1055
|
const facts = [
|
|
1056
1056
|
lane.label,
|
|
@@ -1068,7 +1068,7 @@ function timeline(lanes, o) {
|
|
|
1068
1068
|
if (row.ticks?.length) body += drawTicks(row.ticks, lane.label, px, barTop(y), barH, fmt);
|
|
1069
1069
|
if (countText) {
|
|
1070
1070
|
const x = phone ? width - 12 : width - 16;
|
|
1071
|
-
body += titled(`${lane.label}: ${countText.sentence}${row.hidden ? ` across ${row.hidden + 1} lanes` : ""}`, `<text class="tgc-num tgc-count" x="${x}" y="${baseline}" font-size="
|
|
1071
|
+
body += titled(`${lane.label}: ${countText.sentence}${row.hidden ? ` across ${row.hidden + 1} lanes` : ""}`, `<text class="tgc-num tgc-count" x="${x}" y="${baseline}" font-size="12" text-anchor="end">${countText.ok}<tspan class="tgc-count-ok">✓</tspan> ${countText.failed}<tspan class="tgc-count-failed">✗</tspan></text>`);
|
|
1072
1072
|
}
|
|
1073
1073
|
body += "</g>";
|
|
1074
1074
|
});
|
|
@@ -1079,7 +1079,7 @@ function timeline(lanes, o) {
|
|
|
1079
1079
|
body += titled(`${markName(mark)}: ${fmt(mark.at)}${mark.verdict ? ` · ${mark.verdict}` : ""}`, `<g data-mark="${mark.kind}" data-lane-mark="${esc(mark.lane)}"${verdict}>${glyph}</g>`);
|
|
1080
1080
|
}
|
|
1081
1081
|
if (o.now !== void 0) body += line(px(o.now), top, px(o.now), bottom, "tgc-now") + text(px(o.now), bottom + 30, `now ${fmt(o.now)}`, {
|
|
1082
|
-
size:
|
|
1082
|
+
size: 12,
|
|
1083
1083
|
cls: "tgc-ink tgc-num",
|
|
1084
1084
|
anchor: px(o.now) > (left + right) / 2 ? "end" : "start"
|
|
1085
1085
|
});
|
|
@@ -1184,7 +1184,7 @@ function axisTicks(t0, t1, px, left, right, label) {
|
|
|
1184
1184
|
const fit = (list) => {
|
|
1185
1185
|
let end = -Infinity;
|
|
1186
1186
|
for (const t of list) {
|
|
1187
|
-
const w = textWidth(label(t),
|
|
1187
|
+
const w = textWidth(label(t), 12, "mono"), a = px(t) - w / 2, b = px(t) + w / 2;
|
|
1188
1188
|
if (a < left - 14 || b > right + 14 || a < end + 10) return false;
|
|
1189
1189
|
end = b;
|
|
1190
1190
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/charts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
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",
|