plot icon indicating copy to clipboard operation
plot copied to clipboard

flamegraph transform?

Open Fil opened this issue 1 year ago • 0 comments

flamegraph

Here's a starting point; I'll make a notebook later. We have to change this from an ad hoc function to a proper transform (facet-aware etc).

{
  const positions = new Map();

  return (d) => {
    const p = (!positions.has(d.YEAR) && positions.set(d.YEAR, []), positions.get(d.YEAR));
    const start = days(d["AFSDATE"]);
    const end = days(d["AFEDATE"]);
    let height = 0;
    while (
      p.some(
        (p) =>
          p.height === height &&
          ((p.start <= start && start <= p.end) ||
            (p.start <= end && end <= p.end) ||
            (start <= p.start && p.start <= end) ||
            (start <= p.end && p.end <= end))
      )
    )
      height++;

    p.push({ start, end, height });
    return height;
  };
}

Fil avatar Mar 04 '24 14:03 Fil