Skip to content

Draw Data: Binary Tree View canvas width doubles with every level #129

Open

Description

@martin-henz

Split out of #84 (case 1).

Problem

Binary Tree View reserves room for a full binary tree on both sides of the root, whatever the tree's actual shape. The canvas width is

(2^depth − 1) × 180 + 90   px   (BinaryTreeDrawer.draw: EY2 * NWidth * 2 + NWidth)
depth canvas width
4 2,790 px
6 11,430 px
7 22,950 px
8 45,990 px
9 92,070 px

Example (left-skewed, depth 4):

draw_data([1, [[2, [[3, [[4, [None, [None, None]]], [None, None]]], [None, None]]], [None, None]]])

Possible fix

A compact layout that sizes each subtree by its actual width, for example the classic Reingold–Tilford tidy-tree algorithm, instead of spacing children by 2^depth. The canvas would then be computed from the real extent of the drawn nodes.

Found while investigating #84; the clipping bugs from that issue are fixed separately.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions