Skip to content

Commit

Permalink
Merge pull request #217 from plotly/cyleaflet-performance
Browse files Browse the repository at this point in the history
Cyleaflet performance and mouse position mismatch
  • Loading branch information
Farkites authored May 23, 2024
2 parents 67fa01f + cbc6769 commit 083dc1b
Show file tree
Hide file tree
Showing 21 changed files with 53 additions and 37 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.0.1] - 2024-05-23

### Fixed
* [#205](https://github.com/plotly/dash-cytoscape/pull/205) Fixed updating maxZoom via callback in CyLeaflet AIO component.
* [#207](https://github.com/plotly/dash-cytoscape/pull/207) Allow access to updated lat/lon when Cytoscape nodes in CyLeaflet AIO component are modified via UI.
* [#208](https://github.com/plotly/dash-cytoscape/pull/208) Allow updating Cytoscape elements in CyLeaflet AIO component via callback.
* [#210](https://github.com/plotly/dash-cytoscape/pull/210) Performace improvement: added debounce to update elements event.
* [#212](https://github.com/plotly/dash-cytoscape/pull/212) Added call to `cy.resize` to fix mouse position mismatch on `tapstart` event.

## [1.0.0] - 2024-01-26

Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dashCytoscape
Title: A Component Library for 'Dash' aimed at facilitating network visualization in R, wrapped around Cytoscape.js.
Version: 1.0.0
Version: 1.0.1
Description: A Component Library for 'Dash' aimed at facilitating network visualization in R, wrapped around Cytoscape.js.
Depends: R (>= 3.0.2)
Imports:
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "DashCytoscape"
uuid = "1b08a953-4be3-4667-9a23-85cc21bfd5e9"
authors = ["The Plotly Team <[email protected]>"]
version = "1.0.0"
version = "1.0.1"

[deps]
Dash = "1b08a953-4be3-4667-9a23-3db579824955"
Expand Down
2 changes: 1 addition & 1 deletion R/internal.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.dashCytoscape_js_metadata <- function() {
deps_metadata <- list(`dash_cytoscape` = structure(list(name = "dash_cytoscape",
version = "1.0.0", src = list(href = NULL,
version = "1.0.1", src = list(href = NULL,
file = "deps"), meta = NULL,
script = 'dash_cytoscape.min.js',
stylesheet = NULL, head = NULL, attachment = NULL, package = "dashCytoscape",
Expand Down
2 changes: 1 addition & 1 deletion dash_cytoscape/dash_cytoscape.dev.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash_cytoscape/dash_cytoscape.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash_cytoscape/dash_cytoscape_extra.dev.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash_cytoscape/dash_cytoscape_extra.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash_cytoscape/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-cytoscape",
"version": "1.0.0",
"version": "1.0.1",
"description": "A Component Library for Dash aimed at facilitating network visualization in Python, wrapped around Cytoscape.js",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion deps/dash_cytoscape.dev.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion deps/dash_cytoscape.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion deps/dash_cytoscape_extra.dev.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion deps/dash_cytoscape_extra.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/deps/dash_cytoscape.dev.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/deps/dash_cytoscape.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/deps/dash_cytoscape_extra.dev.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/deps/dash_cytoscape_extra.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-cytoscape",
"version": "1.0.0",
"version": "1.0.1",
"description": "A Component Library for Dash aimed at facilitating network visualization in Python, wrapped around Cytoscape.js",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions src/DashCytoscape.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module DashCytoscape
using Dash

const resources_path = realpath(joinpath( @__DIR__, "..", "deps"))
const version = "1.0.0"
const version = "1.0.1"

include("jl/cyto_cytoscape.jl")

Expand All @@ -16,7 +16,7 @@ function __init__()
[
DashBase.Resource(
relative_package_path = "dash_cytoscape.min.js",
external_url = "https://unpkg.com/[email protected].0/dash_cytoscape/dash_cytoscape.min.js",
external_url = "https://unpkg.com/[email protected].1/dash_cytoscape/dash_cytoscape.min.js",
dynamic = nothing,
async = nothing,
type = :js
Expand Down
44 changes: 29 additions & 15 deletions src/lib/components/Cytoscape.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ class Cytoscape extends Component {
// ///////////////////////////////////// CONSTANTS /////////////////////////////////////////
const SELECT_THRESHOLD = 100;
const EXTENT_THRESHOLD = 5;
const UPDATE_ELEMENTS_THRESHOLD = 100;
const RESIZE_THRESHOLD = 50;

const selectedNodes = cy.collection();
const selectedEdges = cy.collection();
Expand Down Expand Up @@ -214,6 +216,27 @@ class Cytoscape extends Component {
});
}, EXTENT_THRESHOLD);

const updateElements = _.debounce(() => {
this.props.setProps({
elements: cy.elements('').map((item) => {
if (item.json().group === 'nodes') {
return {
data: item.json().data,
position: item.json().position,
};
}
return {
data: item.json().data,
position: void 0,
};
}),
});
}, UPDATE_ELEMENTS_THRESHOLD);

const resize = _.debounce(() => {
cy.resize();
}, RESIZE_THRESHOLD);

// Store the original maxZoom and minZoom functions
const originalMaxZoomFn = cy.maxZoom;
const originalMinZoomFn = cy.minZoom;
Expand Down Expand Up @@ -331,26 +354,17 @@ class Cytoscape extends Component {
});

cy.on('dragfree add remove', (_) => {
this.props.setProps({
elements: cy.elements('').map((item) => {
if (item.json().group === 'nodes') {
return {
data: item.json().data,
position: item.json().position,
};
}
return {
data: item.json().data,
position: void 0,
};
}),
});
updateElements();
});

cy.on('viewport resize', () => {
cy.on('resize viewport', () => {
setExtent(cy.extent());
});

cy.on('tapstart', () => {
resize();
});

// Refresh layout if current zoom is out of boundaries
cy.on('minMaxZoomChange', function () {
const zoom = cy.zoom();
Expand Down

0 comments on commit 083dc1b

Please sign in to comment.