Skip to content

Commit

Permalink
num-dot-chart: create new dots when adjusting y, and also remove the …
Browse files Browse the repository at this point in the history
…old dots brownplt#469
  • Loading branch information
ds26gte committed Nov 13, 2024
1 parent bf03572 commit d54291f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/web/js/trove/chart-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -1631,14 +1631,22 @@
const circleX = Number(circle.getAttribute('cx'));
if (lastX &&
(lastX === circleX || (circleX - lastX) < offsetQuantum)) {
circle.setAttribute('cx', lastX);
// circle.setAttribute('cx', lastX); // if we don't want horiz stagger
currentNumOffsets++;
} else {
lastX = circleX; currentNumOffsets = 0;
}
let circleY = Number(circle.getAttribute('cy'));
circleY -= (currentNumOffsets + 0.5) * offsetQuantum;
circle.setAttribute('cy', circleY);

const circleElt = circle.cloneNode(false);
circleElt.classList.add('__img_labels'); // tag for later gc
circleElt.setAttribute('cy', circleY);
circleElt.setAttribute('r', circleR);
circleElt.setAttribute('fill-opacity', 1);
Object.assign(circleElt, circle); // we should probably not steal *everything*...
circle.remove();
svgRoot.appendChild(circleElt);
});
}
});
Expand Down

0 comments on commit d54291f

Please sign in to comment.