Cytoscape - user_data as part of the elements dictionary


#1

Hi,
I just came up with an idea to append a custom user_data to the elements of Cytoscape.

basic_elements = [
{
    "data": {"id": "FAN", "label": "Fan \n Sound Power Level"},
    "classes": "FAN",
    "user_data": {"id": "fan", "units": "metric", "IL": [2, 3, 4, 5, 6, 7, 8]},
},
{"data": {"source": "FAN", "target": "Duct", "label": "Edge from Node1 to Node2"}},
{"data": {"id": "Duct", "label": "Duct"}, "classes": "DUCT"},
{"data": {"id": "Branch", "label": "Branch"}, "classes": "BRANCH"},
}]

and

 cyto.Cytoscape(
                    id="cytoscape",
                    elements=basic_elements,
                    stylesheet=cytoscape_stylesheet,
                    style={
                        "height": "95vh",
                        "width": "100%",
                        "background-color": "#f5f5fa",
                    },
                    userZoomingEnabled=False,
                    autoRefreshLayout=True,
                )

I use the user_data in the callbacks to store the struct containing analysis data associated with each node. It works well now. I was wondering if this would break in the future - i.e. elements NOT accepting unregistered fields.

Thanks,
Vivek


#2

@xhlu : Do you have any insight on this? :slight_smile: Thaks so much for your elaborate responses to all my questions on the Cytoscape package.


#3

Hey! I think it won’t break in the future. However, I would recommend you to take a look at the Changelog for dash-cytoscape AND Cytoscape.js if you would like to upgrade, if this application is critical :slight_smile:


#4

Thank you! I just wanted to check if you had any ideas to break support in the near future. This is great! :slight_smile: :slight_smile:


#5

Not for now! If we plan to break support, we will certainly change version (i.e. 0.x.x -> 1.0.0)