From b52ddbcfdfea142088d6c68b8d491173d87630ec Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Tue, 8 Feb 2022 16:26:15 -0500 Subject: [PATCH] feat: Propagate squiggleString --- lib/comparisonView.js | 11 +++++++++-- lib/labeledGraph.js | 6 ++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/comparisonView.js b/lib/comparisonView.js index 59867e4..d0fda06 100644 --- a/lib/comparisonView.js +++ b/lib/comparisonView.js @@ -178,7 +178,7 @@ export default function ComparisonView({ listOfElementsForView }) { let binaryComparisons2 = []; links.shift(); for (let link of links) { - let { source, target, distance, reasoning } = link; + let { source, target, distance, reasoning, squiggleString } = link; let searchByName = (name, candidate) => candidate.name == name; let testForSource = (candidate) => searchByName(source, candidate); let testForTarget = (candidate) => searchByName(target, candidate); @@ -190,7 +190,13 @@ export default function ComparisonView({ listOfElementsForView }) { console.log(target); throw new Error("Comparisons include unknown elements, please retry"); } - quantitativeComparisons2.push([element1, element2, distance, reasoning]); + quantitativeComparisons2.push([ + element1, + element2, + distance, + reasoning, + squiggleString || distance, + ]); binaryComparisons2.push([element1, element2]); } // return ({quantitativeComparisons: quantitativeComparisons2, binaryComparisons: binaryComparisons2}) @@ -315,6 +321,7 @@ export default function ComparisonView({ listOfElementsForView }) { if (inputValue < 1 && inputValue > 0) { inputValue = 1 / inputValue; [element1, element2] = [element2, element1]; + squiggleString = `(${squiggleString})^(-1)`; } console.log(`posList@nextStepInput:`); console.log(posList); diff --git a/lib/labeledGraph.js b/lib/labeledGraph.js index 1026735..7cff14e 100644 --- a/lib/labeledGraph.js +++ b/lib/labeledGraph.js @@ -122,9 +122,10 @@ function drawGraphInner({ nodes, links }) { ); }) .style("fill", "none") - .attr("stroke", "black"); + .attr("stroke", "green"); // black // labels for links + // smaller font. svg .selectAll("mylinks") .data(links) @@ -149,7 +150,8 @@ function drawGraphInner({ nodes, links }) { if (d.distance == d.squiggleString || !d.squiggleString) { return distanceFormatted; } else { - return `${d.squiggleString} → ${distanceFormatted}`; + // return `${d.squiggleString} → ${distanceFormatted}`; + return `(${d.squiggleString})`; } // return (truncateValueForDisplay(Number(d.distance)))