Skip to content

Commit 6b4eb25

Browse files
committed
expose CyLeaflet subcomponent IDs and demonstrate usage in demo
1 parent 231eaab commit 6b4eb25

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

dash_cytoscape/CyLeaflet.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ def __init__(
6464
s: {"id": id, "component": "cyleaflet", "sub": s}
6565
for s in ["cy", "leaf", "elements"]
6666
}
67-
self.ids["component"] = "leaflet"
67+
68+
self.CYTOSCAPE_ID = self.ids["cy"]
69+
self.LEAFLET_ID = self.ids["leaf"]
70+
self.ELEMENTS_ID = self.ids["elements"]
71+
6872
cytoscape_props = cytoscape_props or {}
6973
leaflet_props = leaflet_props or {}
7074
elements = cytoscape_props.get("elements", [])

demos/usage-cy-leaflet-aio.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,23 @@
5050
"Gold Coast": (-28.026901440211205, 153.4208293956674),
5151
}
5252

53+
# Create an instance of CyLeaflet
54+
cyleaflet_instance = cyto.CyLeaflet(
55+
id="my-cy-leaflet",
56+
cytoscape_props={
57+
"elements": [],
58+
"stylesheet": cy_stylesheet,
59+
},
60+
width=int(default_div_style["width"][:-2]),
61+
height=int(default_div_style["height"][:-2]),
62+
)
63+
64+
5365
# App
5466
app.layout = html.Div(
5567
[
5668
html.Div(
57-
cyto.CyLeaflet(
58-
id="my-cy-leaflet",
59-
cytoscape_props={
60-
"elements": [],
61-
"stylesheet": cy_stylesheet,
62-
},
63-
width=int(default_div_style["width"][:-2]),
64-
height=int(default_div_style["height"][:-2]),
65-
),
69+
cyleaflet_instance,
6670
id="cy-leaflet-div",
6771
style=default_div_style,
6872
),
@@ -97,9 +101,7 @@
97101
@callback(
98102
Output("cy-leaflet-div", "children"),
99103
Output("cy-leaflet-div", "style"),
100-
Output(
101-
{"id": "my-cy-leaflet", "sub": "leaf", "component": "cyleaflet"}, "children"
102-
),
104+
Output(cyleaflet_instance.LEAFLET_ID, "children"),
103105
Input("location-dropdown", "value"),
104106
Input("width-input", "value"),
105107
Input("height-input", "value"),

0 commit comments

Comments
 (0)