Skip to content

Commit 7a77cc0

Browse files
committed
Make update elements store callback clientside
1 parent 7e75900 commit 7a77cc0

14 files changed

+36
-47
lines changed

dash_cytoscape/CyLeaflet.py

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -220,41 +220,12 @@ def get_cytoscape_max_zoom(self, leaflet_max_zoom):
220220
Input({"id": MATCH, "component": "cyleaflet", "sub": "elements"}, "data"),
221221
prevent_initial_call="initial_duplicate",
222222
)
223-
224-
225-
@callback(
226-
Output({"id": MATCH, "component": "cyleaflet", "sub": "elements"}, "data"),
227-
Input({"id": MATCH, "component": "cyleaflet", "sub": "cy"}, "elements"),
228-
prevent_initial_call=True,
229-
)
230-
def update_elements_store(elements):
231-
def xy_to_lon_lat(x, y):
232-
conversion_factor = 20037508.34
233-
double_lon = 360
234-
max_lon = 180
235-
max_lat = 90
236-
lon = (x * max_lon) / conversion_factor
237-
lat = (
238-
math.atan(math.exp((-y * math.pi) / conversion_factor)) * double_lon
239-
) / math.pi - max_lat
240-
return [lon, lat]
241-
242-
new_elements = []
243-
if elements:
244-
for e in elements:
245-
new_element = e
246-
if (
247-
"position" in e.keys()
248-
and "x" in e["position"].keys()
249-
and e["position"]["x"]
250-
and e["position"]["y"]
251-
):
252-
lon_lat = xy_to_lon_lat(e["position"]["x"], e["position"]["y"])
253-
new_element["data"]["lon"] = lon_lat[0]
254-
new_element["data"]["lat"] = lon_lat[1]
255-
new_elements.append(new_element)
256-
return new_elements
257-
return no_update
223+
clientside_callback(
224+
ClientsideFunction(namespace="cyleaflet", function_name="updateLonLat"),
225+
Output({"id": MATCH, "component": "cyleaflet", "sub": "elements"}, "data"),
226+
Input({"id": MATCH, "component": "cyleaflet", "sub": "cy"}, "elements"),
227+
prevent_initial_call=True,
228+
)
258229

259230

260231
@callback(

dash_cytoscape/dash_cytoscape.dev.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dash_cytoscape/dash_cytoscape.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dash_cytoscape/dash_cytoscape_extra.dev.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dash_cytoscape/dash_cytoscape_extra.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deps/dash_cytoscape.dev.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deps/dash_cytoscape.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deps/dash_cytoscape_extra.dev.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deps/dash_cytoscape_extra.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/deps/dash_cytoscape.dev.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)