Execute each of these cells in order, such as with
First, load SankeyWidget
:
from ipysankeywidget import SankeyWidget
Then, create an instance of SankeyWidget
:
flows = [
{'source': 'start', 'target': 'A', 'value': 2},
{'source': 'A', 'target': 'B', 'value': 2},
{'source': 'B', 'target': 'start', 'value': 0.2},
{'source': 'C', 'target': 'A', 'value': 2},
{'source': 'A', 'target': 'C', 'value': 2},
]
nbsankeyExample = SankeyWidget(value={'flows': flows}, width=400, height=200,
margins=dict(top=0, bottom=0))
Display the widget:
nbsankeyExample
You should see a simple Sankey diagram with 4 nodes and 5 flows
Now, you can update the value
:
nbsankeyExample.value['flows'][0]['value'] = 1
nbsankeyExample.send_state()
You should see the diagram change.