#!/usr/bin/env python
# coding: utf-8
# # Simple example
#
# > Simple example
# >
# > [Advanced examples](./More%20examples.ipynb)
# >
# > [Linking and Layout](./Linking%20and%20Layout.ipynb)
# >
# > [Exporting Images](./Exporting%20Images.ipynb)
# > Execute each of these cells in order, such as with
# First, load `SankeyWidget`:
# In[1]:
from ipysankeywidget import SankeyWidget
# Then, create an instance of `SankeyWidget`:
# In[2]:
links = [
{'source': 'start', 'target': 'A', 'value': 2},
{'source': 'A', 'target': 'B', 'value': 2},
{'source': 'C', 'target': 'A', 'value': 2},
{'source': 'A', 'target': 'C', 'value': 2},
]
# In[3]:
w = SankeyWidget(links=links, margins=dict(top=0, bottom=0, left=50, right=100))
# Display the widget:
# In[4]:
w
# > You should see a simple Sankey diagram with 4 nodes and 4 flows
# Now, you can update the value of a link:
# In[5]:
w.links[0]['value'] = 1
w.send_state()
# > You should see the diagram change.
#
# See the other notebooks linked above for more examples.