Skip to content

Commit 87d24a7

Browse files
committed
added logistic function
1 parent e6054ad commit 87d24a7

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

src/app/components/StateRoute/ComponentMap/ComponentMap.tsx

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -248,23 +248,16 @@ export default function ComponentMap({
248248
childPropsLength = Object.keys(childPropsObj).length;
249249
console.log('>> child_props_length: ', childPropsLength);
250250
}
251-
// function Sigmoid (x) {
252-
// // alter the shape by changing x0, L and k (see wikipedia)
253-
// const x0 = 5;
254-
// const L = 25;
255-
// const k = .4;
256-
// // some costumization for case x <= 0
257-
// if (x <= 0) result = 1
258-
// else {
259-
// let result = -3 + L / (1 + Math.exp(-k * (x - x0)));
260-
// }
261-
// return result;
262-
// }
263-
// const strokeWidthIndex = Sigmoid(childPropsLength);
264-
const strokeWidthIndex = childPropsLength * 2.5 + 1;
251+
// go to https://en.wikipedia.org/wiki/Logistic_function
252+
// for an explanation of Logistic functions and parameters used
253+
const yshift = -3;
254+
const x0 = 5;
255+
const L = 25;
256+
const k = .4;
257+
const strokeWidthIndex = yshift + L / (1 + Math.exp(-k * (childPropsLength - x0)));
258+
// const strokeWidthIndex = childPropsLength * 2.5 + 1;
265259
console.log('strokeWidthIndex: ', strokeWidthIndex);
266260

267-
268261
if (strokeWidthIndex <= 1) {
269262
// strokeWidthIndex = 1;
270263
stroke = '#000000';

0 commit comments

Comments
 (0)