@tangle-network/charts 0.1.7 → 0.1.9

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.
Files changed (2) hide show
  1. package/dist/index.js +12 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -776,12 +776,17 @@ function comparisonIntervals(rows, setups, o) {
776
776
  refused: rows.every((r) => r.interval === null) ? `${rows.length} ${plural(rows.length, "comparison")} listed; none carries an interval.` : `No comparison can be drawn. ${refused.join("; ")}.`
777
777
  };
778
778
  const clears = drawn.filter(({ row }) => row.interval.lower > row.minimumEffect && (intervalGap(row.exactInterval) !== null || row.exactInterval.lower > row.minimumEffect));
779
- const finding = clears.length === drawn.length ? drawn.length === 1 ? "The step clears its registered minimum effect." : `Each of the ${drawn.length} steps clears its registered minimum effect.` : clears.length === 0 ? `No step clears its registered minimum effect.` : `${clears.length} of ${drawn.length} steps clear their registered minimum effect.`;
779
+ const minimum = drawn[0].row.minimumEffect;
780
+ const sameMinimum = drawn.every(({ row }) => row.minimumEffect === minimum);
781
+ const pluralSubject = clears.length > 1 && clears.length < drawn.length;
782
+ const difference = drawn.every(({ row }) => row.minimumEffect >= 0) ? "improvement" : "difference";
783
+ const requirement = sameMinimum ? `the required ${difference} of more than ${new Intl.NumberFormat("en-US", { maximumFractionDigits: 12 }).format(minimum * 100)} percentage points in ${o.measure}` : `${pluralSubject ? "their" : "its"} required ${difference}${pluralSubject ? "s" : ""}`;
784
+ const finding = `${clears.length === drawn.length ? drawn.length === 1 ? "The comparison" : "Every comparison" : clears.length === 0 ? "No comparison" : `${clears.length} of ${drawn.length} comparisons`} ${pluralSubject ? "support" : "supports"} ${requirement}.`;
780
785
  const pairs = drawn.reduce((s, d) => s + d.row.pairs, 0);
781
786
  const lede = `${drawn.length} ${plural(drawn.length, "comparison")} over ${pairs} paired ${plural(pairs, "attempt")}${refused.length ? `; ${refused.length} not drawn` : ""}.`;
782
787
  const names = [...new Set(drawn.map((d) => intervalName(d.row.interval)))];
783
788
  const exactNames = [...new Set(drawn.filter((d) => intervalGap(d.row.exactInterval) === null).map((d) => intervalName(d.row.exactInterval)))];
784
- const read = `Each bar is the ${names.join(" or ")} interval on the difference in ${o.measure}` + (exactNames.length ? `; the thin bar under it is the ${exactNames.join(" or ")} interval` : "") + ". A step is backed when every bar lies wholly right of the dashed minimum effect.";
789
+ const read = `Each bar is the ${names.join(" or ")} interval on the difference in ${o.measure}` + (exactNames.length ? `; the thin bar under it is the ${exactNames.join(" or ")} interval` : "") + ". A comparison is supported when every bar lies wholly right of the dashed minimum effect.";
785
790
  const columns = [
786
791
  { label: "Comparison" },
787
792
  {
@@ -966,12 +971,14 @@ function costFrontier(rows, o) {
966
971
  const cheapest = [...costed].sort((a, b) => cost(a) - cost(b))[0];
967
972
  finding = `${cheapest.label} has the lowest cost per pass, ${usd(cost(cheapest))}${est(cheapest)}.`;
968
973
  }
969
- const lede = `${costed.length} of ${rows.length} setups are plotted; ` + (drawLine ? `${front.length} sit on the producer's frontier.` : front.length === 1 ? "1 sits on the producer's frontier." : "the producer computed no frontier.");
974
+ const lowest = Math.min(...costed.map(cost));
975
+ const highest = Math.max(...costed.map(cost));
976
+ const lede = (lowest === highest ? `Cost per pass is ${usd(lowest)}.` : `Cost per pass ranges from ${usd(lowest)} to ${usd(highest)}.`) + (costed.some((row) => row.cost.basis === "estimated") ? " Costs include estimates." : "");
970
977
  const read = `Higher ${o.measure} and lower cost per pass are better; on the wide plot, better is up and right.` + (drawLine ? " Filled points sit on the frontier; the line joins them." : "") + (costed.some((r) => r.onFront && r.cost.basis !== "receipts") ? " A hollow accent ring is a frontier point with an estimated cost." : "");
971
978
  const intervals = [...new Set(costed.filter((r) => rateIntervalGap(r) === null).map((r) => intervalName(r.interval)))];
972
979
  const method = [
973
980
  `Cost per pass is model spend over passed attempts, ${[...new Set(costed.map((r) => r.cost.basis))].map((b) => b === "receipts" ? "from router receipts" : b === "estimated" ? "estimated, not billed" : "from an unrecorded source").join(" or ")}.`,
974
- front.length ? "The frontier is the producer's: no setup off it is both cheaper and higher." : "The producer did not compute a frontier.",
981
+ front.length ? `A frontier setup has no alternative with both lower cost and higher ${o.measure}.` : "",
975
982
  intervals.length ? `Vertical lines: ${intervals.join(", ")} on the ${o.measure}.` : ""
976
983
  ].filter(Boolean).join(" ");
977
984
  const columns = [
@@ -1744,7 +1751,7 @@ function taskMatrix(tasks, setupsIn, cells, o = {}) {
1744
1751
  const most = Math.max(...perSetup.map((x) => x.k));
1745
1752
  const leaders = perSetup.filter((x) => x.k === most).map((x) => x.s.label);
1746
1753
  const rest = perSetup.filter((x) => x.k !== most);
1747
- if (setups.length > 1 && everywhere > 0) finding = `${everywhere} of ${tasksN} passed at least once for every ${noun.setup}.`;
1754
+ if (setups.length > 1 && everywhere > 0) finding = `Every ${noun.setup} passed at least once on ${everywhere} shared ${plural(everywhere, noun.task)} out of ${tasks.length}.`;
1748
1755
  else if (most === 0) finding = `No ${noun.task} passed for any ${noun.setup}.`;
1749
1756
  else {
1750
1757
  const tail = rest.length && rest.every((x) => x.k === 0) ? `; ${rest.length === 1 ? rest[0].s.label : `every other ${noun.setup}`} on none` : "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/charts",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Benchmark figures as static SVG and HTML tables: ranked rates, cost frontier, comparison intervals, task matrix and breakdown. Draws from producer data and refuses what it cannot draw honestly.",
5
5
  "type": "module",
6
6
  "license": "MIT",