INNER CODE UNIT · JavaScript
niceTicks
oncologylab/fp-tools · src/fp_tools/resources/static_browser/app.js:87
function niceTicks(min, max, count = 5) {
if (!Number.isFinite(min) || !Number.isFinite(max) || min === max)
return [min || 0];
const step = niceStep(max - min, count - 1),
start = Math.ceil(min / step) * step,
end = Math.floor(max / step) * step,
out = [];
for (let value = start; value <= end + step * 0.25; value += step)
out.push(Math.abs(value) < step / 1e6 ? 0 : value);
return out.length ? out : [min, max];
}
function colorFor(motif) {
if (!motif.significant) return state.colors.neutral;
return motif.effect >= 0 ? state.colors.first : state.colors.second;
}
function groupFor(motif) {
if (!motif.significant) return "n.s.";
return motif.effect >= 0 ? `${state.first}_up` : `${state.second}_up`;