Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add textual mouseover descriptions of collapsed nodes #3051

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions python/tests/data/svg/tree_poly_tracked.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 20 additions & 5 deletions python/tests/data/svg/tree_poly_tracked_collapse.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions python/tests/data/svg/tree_simple_collapsed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion python/tests/data/svg/tree_subtrees_with_collapsed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 23 additions & 14 deletions python/tskit/drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1990,15 +1990,20 @@ def draw_tree(self):
end=(x2, 0),
)
)
poly.add(
dwg.text(
f"+{info.num_samples}/{bold_integer(info.num_branches)}",
font_style="italic",
x=[rnd(x2)],
dy=[rnd(-self.text_height / 10)], # make the plus sign line up
text_anchor="end",
label = dwg.text(
f"+{info.num_samples}/{bold_integer(info.num_branches)}",
font_style="italic",
x=[rnd(x2)],
dy=[rnd(-self.text_height / 10)], # make the plus sign line up
text_anchor="end",
)
label.set_desc(
title=(
f"This polytomy has {info.num_branches} additional branches, "
f"leading to a total of {info.num_samples} descendant samples"
)
)
poly.add(label)
curr_svg_group.add(poly)

# Add edge above node first => on layer underneath anything else
Expand Down Expand Up @@ -2092,14 +2097,18 @@ def draw_tree(self):
node_lab_attr["transform"] = self.text_transform("above")
else:
if multi_samples is not None:
curr_svg_group.add(
dwg.text(
text=f"+{multi_samples}",
transform=self.text_transform("below", dy=1),
font_style="italic",
class_="lab summary",
)
label = dwg.text(
text=f"+{multi_samples}",
transform=self.text_transform("below", dy=1),
font_style="italic",
class_="lab summary",
)
title = (
f"A collapsed {'sample' if tree.is_sample(u) else 'non-sample'} "
f"node with {multi_samples} descendant samples in this tree"
)
label.set_desc(title=title)
curr_svg_group.add(label)
if u == left_child[tree.parent(u)]:
add_class(node_lab_attr, "lft")
node_lab_attr["transform"] = self.text_transform("above_left")
Expand Down
Loading