taxonium-component
Version:
React component for exploring large phylogenetic trees in the browser
37 lines (36 loc) • 1.78 kB
JavaScript
import { s, ad as S, O as T, u as j, ag as k } from "./JBrowsePanel-BNE3gNW1.js";
const x = 0.3, y = 2;
function H(t, E) {
const { stopToken: g, features: u, regions: I, bpPerPx: d, scaleOpts: c, height: i, config: n } = E, C = I[0], M = s.readConfObject(n, "bicolorPivot"), N = s.readConfObject(n, "bicolorPivotValue"), V = s.readConfObject(n, "negColor"), b = s.readConfObject(n, "posColor"), F = s.readConfObject(n, "color"), R = s.readConfObject(n, "clipColor"), h = M !== "none" && c.scaleType !== "log", _ = S({
...c,
pivotValue: h ? N : void 0,
range: h ? [V, "#eee", b] : ["#eee", b]
}), A = S({ ...c, range: [0, i] }), D = F === "#f0f" ? (o, e) => _(e) : (o, e) => s.readConfObject(n, "color", { feature: o, score: e }), m = A.domain(), P = m[0], v = m[1];
let O = Number.NEGATIVE_INFINITY, p = !1;
const w = [];
let a = performance.now();
for (const o of u.values()) {
performance.now() - a > 400 && (T.checkStopToken(g), a = performance.now());
const [e, f] = j.featureSpanPx(o, C, d);
(Math.floor(e) !== Math.floor(O) || f - e > 1) && (w.push(o), O = e);
const r = o.get("score");
p = p || r > v || r < P;
const l = f - e + x;
r >= c.domain[0] ? (t.fillStyle = D(o, r), t.fillRect(e, 0, l, i)) : (t.fillStyle = "#eee", t.fillRect(e, 0, l, i));
}
if (t.save(), p) {
t.fillStyle = R;
for (const o of u.values()) {
performance.now() - a > 400 && (T.checkStopToken(g), a = performance.now());
const [e, f] = j.featureSpanPx(o, C, d), r = f - e + x, l = o.get("score");
l > v ? k(e, 0, r, y, t) : l < P && c.scaleType !== "log" && k(e, 0, r, y, t);
}
}
return t.restore(), {
reducedFeatures: w
};
}
export {
H as drawDensity
};
//# sourceMappingURL=drawDensity-ApfWAEID.js.map