Skip to content

Commit ebbb246

Browse files
authored
Merge pull request #195 from Farkites/add-timestamp-to-events
Add timestamp to events, update positions on drag, and add `clearOnUnhover` prop.
2 parents 13cb7ff + 1ae6e2a commit ebbb246

24 files changed

+468
-136
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [0.3.1] - 2023-09-27
7+
## [UNRELEASED]
88

99
### Added
1010
* `prettier` and `black` lint/format scripts have been added.
1111
* React 18 job has been added to circleCI workflow.
12+
* [#195](https://github.com/plotly/dash-cytoscape/pull/195)
13+
- Add `clearOnUnhover` property.
14+
- Add timestamp to `tapNodeData`, `tapEdgeData`, `mouseoverNodeData`, and `mouseoverEdgeData` properties.
1215

1316
### Changed
1417
* Dash has been upgraded to 2.* in requirements.txt and tests/requirements.txt.
1518
* Dependencies have been upgraded to lastest versions.
1619
* CircleCI workflow has been updated to version 2.1.
1720
* Python version in CircleCI workflow has been updated to 3.11.
1821
* Node version in CircleCI workflow has been updated to 20.5.1.
22+
* [#195](https://github.com/plotly/dash-cytoscape/pull/195) Update `elements` positions when nodes are dragged.
1923

2024
### Fixed
2125
* CircleCI workflow has been fixed.

CONTRIBUTING.md

Lines changed: 71 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ Thank you for your interesting in contributing to this open-source project! Make
77
Please follow the following steps for local testing:
88

99
1. Clone the repo
10+
1011
```commandline
1112
git clone https://github.com/plotly/dash-cytoscape.git
1213
```
13-
2. In order to run the Python builds (`npm run build:backends`) you need to create a
14-
venv for this project. Make sure you have `virtualenv` correctly installed and run this:
14+
15+
2. In order to run the Python builds (`npm run build:all`) you need to create a
16+
venv for this project. Make sure you have `virtualenv` correctly installed and run this:
17+
1518
```commandline
1619
mkdir dash_cytoscape_dev
1720
cd dash_cytoscape_dev
@@ -21,14 +24,16 @@ pip install -r requirements.txt # Install the requirements
2124
```
2225

2326
To activate in windows, replace the 4th line with this:
27+
2428
```commandline
25-
venv\Scripts\activate
29+
venv\Scripts\activate
2630
```
2731

2832
3. Install the JavaScript dependencies and build the code:
33+
2934
```commandline
3035
npm install
31-
npm run build:backends
36+
npm run build:all
3237
```
3338

3439
#### Package manager
@@ -37,12 +42,10 @@ Before v0.2.0, our preferred package manager for this project is Yarn. Starting
3742

3843
## Coding Style
3944

40-
Please lint any additions to Python code with `pylint` and `flake8`:
45+
Please lint any additions to Python and JS code with `pylint`, `flake8`, `black`, `eslint`, and `prettier`:
46+
4147
```commandline
42-
flake8 --max-line-length=100 usage.py usage-advanced.py usage-elements.py usage-events.py usage-stylesheet.py
43-
flake8 --max-line-length=100 demos tests
44-
pylint usage.py usage-advanced.py usage-elements.py usage-events.py usage-stylesheet.py
45-
pylint demos tests
48+
npm run lint:all
4649
```
4750

4851
## Code quality & design
@@ -63,37 +66,41 @@ pylint demos tests
6366
* Scan your code for expensive operations (large computations, DOM queries, React re-renders). Have you done your possible to limit their impact? If not, it is going to slow your app down.
6467
* Can you think of cases where your current code will break? How are you handling errors? Should the user see them as notifications? Should your app try to auto-correct them for them?
6568

66-
6769
## Tests
6870

6971
### Running the tests
7072

7173
Activate your virtualenv:
74+
7275
```commandline
7376
source venv/bin/activate
7477
```
7578

7679
If needed, install the requirements:
80+
7781
```commandline
7882
pip install -r tests/requirements.txt
7983
```
8084

81-
Run the following tests:
85+
Install ChromeDriver following the instructions [here (Mac)](https://www.kenst.com/2015/03/installing-chromedriver-on-mac-osx/) or [here (Windows)](http://jonathansoma.com/lede/foundations-2018/classes/selenium/selenium-windows-install/). You must install the version of ChromeDriver that matches your Chrome version.
86+
87+
Run the tests using the following command:
88+
8289
```commandline
83-
python -m unittest tests.test_callbacks
84-
python -m unittest tests.test_interactions
85-
python -m unittest tests.test_usage
90+
pytest --headless
8691
```
8792

8893
Look inside the `tests/screenshots` directory to find the images created by the tests. If you have
8994
Percy configured, run the following test:
95+
9096
```commandline
9197
python -m unittest tests.test_percy_snapshot
92-
```
98+
```
9399

94100
### Percy
95101

96102
Make sure to configure your Percy environment variables correctly:
103+
97104
```commandline
98105
PERCY_BRANCH=local
99106
PERCY_ENABLED=1
@@ -103,10 +110,12 @@ PERCY_TOKEN=***************
103110
You can find the token in the [project settings of the Percy project](https://percy.io/plotly/dash-cytoscape/settings). Only members of the Plotly organizations have access to this token.
104111

105112
### About the tests
113+
106114
The tests are broken down in 3 categories:
107-
* Callbacks: Tests if the `elements`, `stylesheet` and `layout` properties can be updated correctly by other Dash components using callbacks.
108-
* Interactions: Tests user interactions such as dragging, clicking, and hovering over nodes, as well as the associated event callbacks.
109-
* Usage: Tests if all of the usage apps render correctly on start. This does not test callbacks.
115+
116+
- Callbacks: Tests if the `elements`, `stylesheet` and `layout` properties can be updated correctly by other Dash components using callbacks.
117+
- Interactions: Tests user interactions such as dragging, clicking, and hovering over nodes, as well as the associated event callbacks.
118+
- Usage: Tests if all of the usage apps render correctly on start. This does not test callbacks.
110119

111120
Those tests are rendered into images located inside `tests/screenshots`, which are then sent to a Percy build using `tests.test_percy_snapshot`, which creates a Dash app that only serves the content of `tests/screenshots` at different routes, which are then captured by the Percy runner.
112121

@@ -122,14 +131,19 @@ To publish or create a prerelease:
122131
2. Bump version numbers in `package.json`, update the [CHANGELOG](CHANGELOG.md), and make a pull request
123132
3. Once the pull request is merged into master:
124133
4. Build
134+
125135
```
126-
npm run build:backends
136+
npm run build:all
127137
```
138+
128139
5. Create distribution tarball
140+
129141
```
130142
python setup.py sdist
131143
```
144+
132145
6. Copy the tarball into a separate folder and try to install it and run the examples:
146+
133147
```
134148
cp dist/dash_cytoscape-x.x.x.tar.gz ../temp
135149
cp usage.py ../temp
@@ -138,64 +152,77 @@ source venv/bin/activate
138152
pip install dash_cytoscape-x.x.x.tar.gz
139153
python usage.py
140154
```
155+
141156
7. If the examples work, then publish:
157+
142158
```
143159
npm publish
144160
twine upload dist/dash_cytoscape-x.x.x.tar.gz
145161
```
162+
146163
8. Tag your release with git:
164+
147165
```
148166
git tag -a 'vx.x.x' -m 'vx.x.x'
149167
git push origin master --follow-tags
150168
```
169+
151170
9. Verify that the publish worked by installing it:
171+
152172
```
153173
cd ../temp
154174
pip install dash-cytoscape==x.x.x
155175
python usage.py
156176
```
157177

158-
159178
Make a post in the [Dash Community Forum](https://community.plotly.com/c/dash)
160-
* Title it `":mega: Announcement! New <Your Feature> - Feedback Welcome"`
161-
* In the description, link to the PR and any relevant issue(s)
162-
* Pin the topic so that it appears at the top of the forum for two weeks
179+
180+
- Title it `":mega: Announcement! New <Your Feature> - Feedback Welcome"`
181+
- In the description, link to the PR and any relevant issue(s)
182+
- Pin the topic so that it appears at the top of the forum for two weeks
163183

164184
## [Checklists](http://rs.io/unreasonable-effectiveness-of-checklists/)
185+
165186
**Beginner tip:** _Copy and paste this section as a comment in your PR, then check off the boxes as you go!_
187+
166188
### Pre-Merge checklist
167-
- [ ] The project was correctly built with `npm run build:backends`.
168-
- [ ] If there was any conflict, it was solved correctly
169-
- [ ] All changes were documented in CHANGELOG.md.
170-
- [ ] All tests on CircleCI have passed.
171-
- [ ] All Percy visual changes have been approved.
172-
- [ ] Two people have :dancer:'d the pull request. You can be one of these people if you are a Dash Cytoscape core contributor.
189+
190+
- [ ] The project was correctly built with `npm run build:all`.
191+
- [ ] If there was any conflict, it was solved correctly
192+
- [ ] All changes were documented in CHANGELOG.md.
193+
- [ ] All tests on CircleCI have passed.
194+
- [ ] All Percy visual changes have been approved.
195+
- [ ] Two people have :dancer:'d the pull request. You can be one of these people if you are a Dash Cytoscape core contributor.
173196

174197
### Merge step
175-
1. Make sure to *Squash and Merge* your contribution if you have created multiple commits to change a specific feature.
176-
2. Make sure to *Rebase and Merge* if you added many different features, and need to contribute multiple different commits.
198+
199+
1. Make sure to _Squash and Merge_ your contribution if you have created multiple commits to change a specific feature.
200+
2. Make sure to _Rebase and Merge_ if you added many different features, and need to contribute multiple different commits.
177201

178202
### Post-Merge checklist
179-
- [ ] You have tagged the release using `git tag v<version_number>` _(for the contributor merging the PR)_.
180-
- [ ] You have pushed this tag using `git push <tag_name>` _(for the contributor merging the PR)_.
181-
- [ ] You have deleted the branch.
203+
204+
- [ ] You have tagged the release using `git tag v<version_number>` _(for the contributor merging the PR)_.
205+
- [ ] You have pushed this tag using `git push <tag_name>` _(for the contributor merging the PR)_.
206+
- [ ] You have deleted the branch.
182207

183208
### Pre-Release checklist
184-
- [ ] Everything in the Pre-Merge checklist is completed.
185-
- [ ] `git remote show origin` shows you are in the correct repository.
186-
- [ ] `git branch` shows that you are on the expected branch.
187-
- [ ] `git status` shows that there are no unexpected changes.
188-
- [ ] Both `package.json` and `dash_cytoscape/package.json` versions have been correctly updated.
209+
210+
- [ ] Everything in the Pre-Merge checklist is completed.
211+
- [ ] `git remote show origin` shows you are in the correct repository.
212+
- [ ] `git branch` shows that you are on the expected branch.
213+
- [ ] `git status` shows that there are no unexpected changes.
214+
- [ ] Both `package.json` and `dash_cytoscape/package.json` versions have been correctly updated.
189215

190216
### Release Step
217+
191218
Complete the "Publishing" section.
192219

193220
### Post-Release checklist
194-
- [ ] Step 1 and 2 of Post-merge checklist are completed.
195-
- [ ] You have closed all issues that this pull request solves, and commented the new version number users should install.
196-
- [ ] If significant enough, you have created an issue about documenting the new feature or change and you have added it to the [Documentation] project.
197-
- [ ] You have created a pull request in [Dash Docs] with the new release of your feature by editing that project's [`requirements.txt` file](https://github.com/plotly/dash-docs/blob/master/requirements.txt).
198221

222+
- [ ] Step 1 and 2 of Post-merge checklist are completed.
223+
- [ ] You have closed all issues that this pull request solves, and commented the new version number users should install.
224+
- [ ] If significant enough, you have created an issue about documenting the new feature or change and you have added it to the [Documentation] project.
225+
- [ ] You have created a pull request in [Dash Docs] with the new release of your feature by editing that project's [`requirements.txt` file](https://github.com/plotly/dash-docs/blob/master/requirements.txt).
199226

200227
## Financial Contributions
201228

@@ -205,7 +232,7 @@ Dash, and many of Plotly's open source products, have been funded through direct
205232
[Dash HTML Components]: https://github.com/plotly/dash-html-components
206233
[write your own components]: https://dash.plotly.com/plugins
207234
[Dash Component Biolerplate]: https://github.com/plotly/dash-component-boilerplate
208-
[issues]: https://github.com/plotly/dash-core-components/issues
235+
[issues]: https://github.com/plotly/dash-core-components/issues
209236
[GitHub flow]: https://guides.github.com/introduction/flow/
210237
[eslintrc-react.json]: https://github.com/plotly/dash-components-archetype/blob/master/config/eslint/eslintrc-react.json
211238
[contributors]: https://github.com/plotly/dash-core-components/graphs/contributors

R/cytoCytoscape.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# AUTO GENERATED FILE - DO NOT EDIT
22

33
#' @export
4-
cytoCytoscape <- function(id=NULL, autoRefreshLayout=NULL, autolock=NULL, autoungrabify=NULL, autounselectify=NULL, boxSelectionEnabled=NULL, className=NULL, elements=NULL, generateImage=NULL, imageData=NULL, layout=NULL, maxZoom=NULL, minZoom=NULL, mouseoverEdgeData=NULL, mouseoverNodeData=NULL, pan=NULL, panningEnabled=NULL, responsive=NULL, selectedEdgeData=NULL, selectedNodeData=NULL, style=NULL, stylesheet=NULL, tapEdge=NULL, tapEdgeData=NULL, tapNode=NULL, tapNodeData=NULL, userPanningEnabled=NULL, userZoomingEnabled=NULL, zoom=NULL, zoomingEnabled=NULL) {
4+
cytoCytoscape <- function(id=NULL, autoRefreshLayout=NULL, autolock=NULL, autoungrabify=NULL, autounselectify=NULL, boxSelectionEnabled=NULL, className=NULL, clearOnUnhover=NULL, elements=NULL, generateImage=NULL, imageData=NULL, layout=NULL, maxZoom=NULL, minZoom=NULL, mouseoverEdgeData=NULL, mouseoverNodeData=NULL, pan=NULL, panningEnabled=NULL, responsive=NULL, selectedEdgeData=NULL, selectedNodeData=NULL, style=NULL, stylesheet=NULL, tapEdge=NULL, tapEdgeData=NULL, tapNode=NULL, tapNodeData=NULL, userPanningEnabled=NULL, userZoomingEnabled=NULL, zoom=NULL, zoomingEnabled=NULL) {
55

6-
props <- list(id=id, autoRefreshLayout=autoRefreshLayout, autolock=autolock, autoungrabify=autoungrabify, autounselectify=autounselectify, boxSelectionEnabled=boxSelectionEnabled, className=className, elements=elements, generateImage=generateImage, imageData=imageData, layout=layout, maxZoom=maxZoom, minZoom=minZoom, mouseoverEdgeData=mouseoverEdgeData, mouseoverNodeData=mouseoverNodeData, pan=pan, panningEnabled=panningEnabled, responsive=responsive, selectedEdgeData=selectedEdgeData, selectedNodeData=selectedNodeData, style=style, stylesheet=stylesheet, tapEdge=tapEdge, tapEdgeData=tapEdgeData, tapNode=tapNode, tapNodeData=tapNodeData, userPanningEnabled=userPanningEnabled, userZoomingEnabled=userZoomingEnabled, zoom=zoom, zoomingEnabled=zoomingEnabled)
6+
props <- list(id=id, autoRefreshLayout=autoRefreshLayout, autolock=autolock, autoungrabify=autoungrabify, autounselectify=autounselectify, boxSelectionEnabled=boxSelectionEnabled, className=className, clearOnUnhover=clearOnUnhover, elements=elements, generateImage=generateImage, imageData=imageData, layout=layout, maxZoom=maxZoom, minZoom=minZoom, mouseoverEdgeData=mouseoverEdgeData, mouseoverNodeData=mouseoverNodeData, pan=pan, panningEnabled=panningEnabled, responsive=responsive, selectedEdgeData=selectedEdgeData, selectedNodeData=selectedNodeData, style=style, stylesheet=stylesheet, tapEdge=tapEdge, tapEdgeData=tapEdgeData, tapNode=tapNode, tapNodeData=tapNodeData, userPanningEnabled=userPanningEnabled, userZoomingEnabled=userZoomingEnabled, zoom=zoom, zoomingEnabled=zoomingEnabled)
77
if (length(props) > 0) {
88
props <- props[!vapply(props, is.null, logical(1))]
99
}
1010
component <- list(
1111
props = props,
1212
type = 'Cytoscape',
1313
namespace = 'dash_cytoscape',
14-
propNames = c('id', 'autoRefreshLayout', 'autolock', 'autoungrabify', 'autounselectify', 'boxSelectionEnabled', 'className', 'elements', 'generateImage', 'imageData', 'layout', 'maxZoom', 'minZoom', 'mouseoverEdgeData', 'mouseoverNodeData', 'pan', 'panningEnabled', 'responsive', 'selectedEdgeData', 'selectedNodeData', 'style', 'stylesheet', 'tapEdge', 'tapEdgeData', 'tapNode', 'tapNodeData', 'userPanningEnabled', 'userZoomingEnabled', 'zoom', 'zoomingEnabled'),
14+
propNames = c('id', 'autoRefreshLayout', 'autolock', 'autoungrabify', 'autounselectify', 'boxSelectionEnabled', 'className', 'clearOnUnhover', 'elements', 'generateImage', 'imageData', 'layout', 'maxZoom', 'minZoom', 'mouseoverEdgeData', 'mouseoverNodeData', 'pan', 'panningEnabled', 'responsive', 'selectedEdgeData', 'selectedNodeData', 'style', 'stylesheet', 'tapEdge', 'tapEdgeData', 'tapNode', 'tapNodeData', 'userPanningEnabled', 'userZoomingEnabled', 'zoom', 'zoomingEnabled'),
1515
package = 'dashCytoscape'
1616
)
1717

dash_cytoscape/Cytoscape.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ class Cytoscape(Component):
3838
Sets the class name of the element (the value of an element's html
3939
class attribute).
4040
41+
- clearOnUnhover (boolean; default False):
42+
If set to True, mouseoverNodeData and mouseoverEdgeData will be
43+
cleared on unhover. If set to False, the value of
44+
mouseoverNodeData and mouseoverEdgeData will be the last Node or
45+
Edge hovered over.
46+
4147
- elements (list of dicts; optional):
4248
A list of dictionaries representing the elements of the networks.
4349
Each dictionary describes an element, and specifies its purpose.
@@ -467,6 +473,7 @@ def __init__(
467473
generateImage=Component.UNDEFINED,
468474
imageData=Component.UNDEFINED,
469475
responsive=Component.UNDEFINED,
476+
clearOnUnhover=Component.UNDEFINED,
470477
**kwargs
471478
):
472479
self._prop_names = [
@@ -477,6 +484,7 @@ def __init__(
477484
"autounselectify",
478485
"boxSelectionEnabled",
479486
"className",
487+
"clearOnUnhover",
480488
"elements",
481489
"generateImage",
482490
"imageData",
@@ -510,6 +518,7 @@ def __init__(
510518
"autounselectify",
511519
"boxSelectionEnabled",
512520
"className",
521+
"clearOnUnhover",
513522
"elements",
514523
"generateImage",
515524
"imageData",

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.

dash_cytoscape/metadata.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,17 @@
880880
"value": "false",
881881
"computed": false
882882
}
883+
},
884+
"clearOnUnhover": {
885+
"type": {
886+
"name": "bool"
887+
},
888+
"required": false,
889+
"description": "If set to True, mouseoverNodeData and mouseoverEdgeData will be cleared on unhover.\nIf set to False, the value of mouseoverNodeData and mouseoverEdgeData will be the last\nNode or Edge hovered over",
890+
"defaultValue": {
891+
"value": "false",
892+
"computed": false
893+
}
883894
}
884895
}
885896
}

0 commit comments

Comments
 (0)