MCPcopy
hub / github.com/plotly/dash / calcStep

Function calcStep

components/dash-core-components/src/utils/computeSliderMarkers.ts:121–139  ·  view source on GitHub ↗
(min?: number, max?: number, step?: number | null)

Source from the content-addressed store, hash-verified

119 * Calculate default step if not defined
120 */
121export const calcStep = (min?: number, max?: number, step?: number | null) => {
122 if (step) {
123 return step;
124 }
125
126 if (isNil(min) || isNil(max)) {
127 return 1;
128 }
129
130 const diff = max > min ? max - min : min - max;
131
132 const v = (Math.abs(diff) + Number.EPSILON) / 100;
133 const N = Math.floor(Math.log10(v));
134 return [
135 Number(Math.pow(10, N)),
136 2 * Math.pow(10, N),
137 5 * Math.pow(10, N),
138 ].sort((a, b) => Math.abs(a - v) - Math.abs(b - v))[0];
139};
140
141/**
142 * Set min and max if they are undefined and marks are defined

Callers 1

RangeSliderFunction · 0.90

Calls 1

sortMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…