yWorks / yfiles-jupyter-graphs

The home of the Jupyter notebook graph visualization widget powered by yFiles for HTML
https://www.yworks.com/products/yfiles-graphs-for-jupyter
Other
173 stars 18 forks source link

Default node / edge label mapping always creates labels in the diagram #4

Closed fskpf closed 2 years ago

fskpf commented 2 years ago

Describe the bug The default mappings for nodes and edges always fall back to the item's index if no label property is given. Therefore, graph items always have at least the index as label.

To Reproduce Delete the label property in the data of the introduction graph and show the diagram.

Expected behavior No label should be displayed if the data doesn't contain a label property.

Additional context This behavior can be adjusted by setting another label mapping function:

def custom_label_mapping(index: int, node: Dict):
    """don't show any label"""
    return ''

w.set_node_label_mapping(custom_label_mapping)
w.set_edge_label_mapping(custom_label_mapping)

I think the better default may be to remove the index label fallback and let users explicitly add the index label by overwriting the label mapping.

yGuy commented 2 years ago

The workaround is simple and can be written in a more compact way using lambdas:

w.node_label_mapping = lambda _,__ : ''
w.edge_label_mapping = lambda _,__ : ''