Search code examples
anychart

How to control truncation of branches in AnyChart's Word Tree?


Our Word Tree data frequently contains too many nodes for AnyChart's Word Tree to render properly within its container: results not visible

The data is formatted as follows:

[
  {
    "data": {
      "value": "i think",
      "children": [
        {
          "value": "i",
          "children": [
            {
              "value": "am",
              "children": [
                ...
              ],
              "value": "am",
            }
          ]
        }
      ]
    }
  }
]

In order to create at least some benefit for our users, we want to always display only the direct children of the root node:desired Word Tree

Unfortunately, we are unaware of how to configure the Word Tree to truncate all nodes that are not direct children of the root node. We tinkered around with the height of the Word Tree's container but the best we could come up with looks like this:

best achieved result

Please note the large gaps between branches which render the Word Tree unusable to our users. In addition, some children of the root node are expanded, for example "it" as seen in the picture.

How can we use AnyChart's Word Tree to create chart that looks like the hand-drawn one?


Solution

  • The current version of the library 8.9.0 doesn't provide settings to implement the desired layout. Yes, applying custom height does the trick, but it seems that you have applied too high height. Try to adjust the container height to fit only the 1st level of the words.