gamcil / clustermap.js

MIT License
30 stars 5 forks source link

Cluster labels are clipped at initializtion of plot #6

Open chasemc opened 3 years ago

chasemc commented 3 years ago

Cluster labels are clipped off left side of plot area: image

It seems to be caused by the static-setting of the translation below, but I'm not yet well-versed in D3 so I'm not going to suggest a fix: https://github.com/gamcil/clustermap.js/blob/84586f6e8406df47276dff160c9b5947b6aa78b2/dist/clustermap.js#L1650

gamcil commented 3 years ago

Yeah, you're correct - currently it's just the arbitrary translation with the expectation that the user will click/drag the figure into view. It's a little tricky since I use x=0 as the base point for gene clusters to get drawn, with labels being right aligned from that point (therefore going negative to varying degrees for each label). The easiest way around this is probably to implement some bounding box check after the figure is generated for the first time, then setting the zoom translation on the base element (perhaps similar to https://observablehq.com/@d3/zoom-to-bounding-box). Either that or just a more generous initial translation to account for longer labels. I don't have a lot of time right now to implement something, so please feel free to have a stab at it :)