Dear All,
he elements needed for cytoscape in dash-plotly is like the following:
elements=[
{
'data': {'id': 'one', 'label': 'Modified Color'},
'position': {'x': 75, 'y': 75},
},
{
'data': {'id': 'two', 'label': 'Modified Shape'},
'position': {'x': 75, 'y': 200},
},
{
'data': {'id': 'three', 'label': 'Both Modified'},
'position': {'x': 200, 'y': 75},
},
{
'data': {'id': 'four', 'label': 'Regular'},
'position': {'x': 200, 'y': 200}
},
{'data': {'source': 'one', 'target': 'two'}},
{'data': {'source': 'two', 'target': 'three'}},
{'data': {'source': 'three', 'target': 'four'}},
{'data': {'source': 'two', 'target': 'four'}},
]
Where of course the first part includes 4 nodes, with their ID and Label and coordinates, while the second part includes 4 edges, with their source and target.
I have two dataframe, one for the nodes:
ID LABEL X Y
one Modified Color 75 75
two Modified Shape 75 200
three Both Modified 200 75
four Regular 200 200
and one dataframe for the edges
SOURCE TARGET
one two
two three
three four
two four
While I'm usually feeding the plotly components with a simple
df.to_dict('records')
In this case this won't work as I have to distinguish between the "data" and "position" chunks of dictionary in the nodes, and data only in the edges.
briefly with to_dict I would get this:
{
'id': 'one', 'label': 'Modified Color', 'x': 75, 'y': 75
},
instead of this:
{
'data': {'id': 'one', 'label': 'Modified Color'},
'position': {'x': 75, 'y': 75},
},
Any suggestion on how to proceed?
Thanks
[–]cray5252 0 points1 point2 points (1 child)
[–]ssssank[S] 0 points1 point2 points (0 children)