Tree

Tree charts or maps are primarily used to display data that is grouped and nested in a hierarchical (or tree-based) structure.

The Method To Use

The method is s.plt.tree()

It must contain the following input variables:

order: int
data: Union[str, Dict, List[Dict]]

And accepts the following input variable as optional:

radial: bool 
vertical: bool
title: Optional[str]
padding: Optional[List[int]]
rows_size: Optional[int] 
cols_size: Optional[int]
option_modifications: Optional[Dict]

Video demonstration of the tree chart

Examples

1. Default Configuration

data = [{
    'name': 'root',
    'value': 35,
    'children': [
        {
            'name': 'Child A',
            'value': 9,
            'children': [
                {'name': 'Child A1', 'value': 23},
                {'name': 'Child A2', 'value': 72},
                {'name': 'Child A3', 'value': 93},
            ],
        },
        {
            'name': 'Child B',
            'value': 56,
            'children': [
                {'name': 'Child B1', 'value': 39},
                {'name': 'Child B2', 'value': 61},
                {'name': 'Child B3', 'value': 71},
            ],
        },
        {
            'name': 'Child C',
            'value': 100,
            'children': [
                {'name': 'Child C1', 'value': 19},
                {'name': 'Child C2', 'value': 66},
                {'name': 'Child C3', 'value': 47},
            ],
        },
    ],
}]

s.plt.tree(
    data=data, order=0
)

2. Customization And Context

data = [{
    'name': 'Central Plant',
    'value': 300,
    'children': [
         {
            'name': 'Mach A',
            'value': 100,
            'children': [
                 {'name': 'Working', 'value': 95},
                 {'name': 'Maintenance', 'value': 5},
            ],
        },
        {
            'name': 'Mach B',
            'value': 150,
            'children': [
                 {'name': 'Working', 'value': 135},
                 {'name': 'Maintenance', 'value': 15},
            ],
        },
        {
            'name': 'Mach C',
            'value': 50,
            'children': [
                {'name': 'Working', 'value': 40},
                {'name': 'Maintenance', 'value': 10},
            ],
        },
    ],
}]

s.plt.tree(
    data=data, order=0,
    title='Status of Machines at Central Plant',
    rows_size=2, cols_size=10, padding='0,0,0,2',
)

Changing the Menu Path The menu_path can be modified.

Using the Grid

It is possible to use any number of rows.

Last updated