feat: Propagate squiggleString

This commit is contained in:
NunoSempere 2022-02-08 16:26:15 -05:00
parent f8fafb837f
commit b52ddbcfdf
2 changed files with 13 additions and 4 deletions

View File

@ -178,7 +178,7 @@ export default function ComparisonView({ listOfElementsForView }) {
let binaryComparisons2 = []; let binaryComparisons2 = [];
links.shift(); links.shift();
for (let link of links) { 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 searchByName = (name, candidate) => candidate.name == name;
let testForSource = (candidate) => searchByName(source, candidate); let testForSource = (candidate) => searchByName(source, candidate);
let testForTarget = (candidate) => searchByName(target, candidate); let testForTarget = (candidate) => searchByName(target, candidate);
@ -190,7 +190,13 @@ export default function ComparisonView({ listOfElementsForView }) {
console.log(target); console.log(target);
throw new Error("Comparisons include unknown elements, please retry"); 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]); binaryComparisons2.push([element1, element2]);
} }
// return ({quantitativeComparisons: quantitativeComparisons2, binaryComparisons: binaryComparisons2}) // return ({quantitativeComparisons: quantitativeComparisons2, binaryComparisons: binaryComparisons2})
@ -315,6 +321,7 @@ export default function ComparisonView({ listOfElementsForView }) {
if (inputValue < 1 && inputValue > 0) { if (inputValue < 1 && inputValue > 0) {
inputValue = 1 / inputValue; inputValue = 1 / inputValue;
[element1, element2] = [element2, element1]; [element1, element2] = [element2, element1];
squiggleString = `(${squiggleString})^(-1)`;
} }
console.log(`posList@nextStepInput:`); console.log(`posList@nextStepInput:`);
console.log(posList); console.log(posList);

View File

@ -122,9 +122,10 @@ function drawGraphInner({ nodes, links }) {
); );
}) })
.style("fill", "none") .style("fill", "none")
.attr("stroke", "black"); .attr("stroke", "green"); // black
// labels for links // labels for links
// smaller font.
svg svg
.selectAll("mylinks") .selectAll("mylinks")
.data(links) .data(links)
@ -149,7 +150,8 @@ function drawGraphInner({ nodes, links }) {
if (d.distance == d.squiggleString || !d.squiggleString) { if (d.distance == d.squiggleString || !d.squiggleString) {
return distanceFormatted; return distanceFormatted;
} else { } else {
return `${d.squiggleString}${distanceFormatted}`; // return `${d.squiggleString} → ${distanceFormatted}`;
return `(${d.squiggleString})`;
} }
// return (truncateValueForDisplay(Number(d.distance))) // return (truncateValueForDisplay(Number(d.distance)))