From 3d380e4dfa635fadb80e38ec1d8b94515fe7ce48 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Thu, 25 Nov 2021 00:42:34 +0000 Subject: [PATCH] Change slider to text field --- lib/findPaths.js | 7 +++-- lib/labeledgraph.js | 1 + lib/slider.js | 6 +++- lib/utils.js | 19 ++++++++++-- package-lock.json | 40 ++++++++++++++++++++++++++ pages/index.js | 70 ++++++++++++++++++++++++++++++++++----------- 6 files changed, 122 insertions(+), 21 deletions(-) diff --git a/lib/findPaths.js b/lib/findPaths.js index ee71fdd..5cabaa2 100644 --- a/lib/findPaths.js +++ b/lib/findPaths.js @@ -7,10 +7,13 @@ let avg = arr => arr.reduce((a,b) => (a+b)) / arr.length let formatLargeOrSmall = num => { if(num > 1){ return toLocale(truncateValueForDisplay(num)) - }else if(num != 0){ + }else if(num > 0){ return num.toFixed(-Math.floor(Math.log(num)/Math.log(10))); + }else if(num > -1){ + return num.toFixed(-Math.floor(Math.log(-num)/Math.log(10))); }else{ - return num//return "~0" + return toLocale(num)//return "~0" + } } diff --git a/lib/labeledgraph.js b/lib/labeledgraph.js index 3f18d29..210cc97 100644 --- a/lib/labeledgraph.js +++ b/lib/labeledgraph.js @@ -118,6 +118,7 @@ function drawGraphInner({nodes, links}){ return height-32-(Math.abs(start-end)/2)//height-30 }) .text(function(d){ + return Number(d.distance) return(truncateValueForDisplay(Number(d.distance))) //return(Number(d.distance).toPrecision(2).toString()) }) diff --git a/lib/slider.js b/lib/slider.js index bfae5f4..fe05cb4 100644 --- a/lib/slider.js +++ b/lib/slider.js @@ -133,7 +133,11 @@ export function SubmitSliderButton({posList, binaryComparisons, sliderValue, toC // console.log("input@SubmitSliderButton") console.log(obj) - nextStepSlider(obj) + if(sliderValue >= 0 ){ + nextStepSlider(obj) + }else if(sliderValue < 0){ + alert("Negative numbers not yet allowed") + } } return(