Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rework classes in from scratch examples match other examples #306

Merged
merged 1 commit into from
Feb 2, 2022

Conversation

jenshnielsen
Copy link
Contributor

The from scratch example uses classes embedded in the data dict rather that as a top level attribute. I found that a bit confusing since Node.classes ends up being empty (and the classes has to be found within the data dict) Here I suggest reworking this and the matching style to use classes as a top level key/value pair.

Chaning the classes value within the data dict does not seem to trigger an update to the graph but I guess that is a separate issue.

@github-actions
Copy link

Binder 👈 Launch a binder notebook on branch jenshnielsen/ipycytoscape/from_scratch_unify_classes

@ianhi
Copy link
Collaborator

ianhi commented Feb 2, 2022

thanks!

@ianhi ianhi merged commit 52d3072 into cytoscape:master Feb 2, 2022
@jenshnielsen jenshnielsen deleted the from_scratch_unify_classes branch February 2, 2022 15:02
@marimeireles
Copy link
Collaborator

Hi, sorry I missed this and the question out of context:
Is this attending to the issue that our docs are not up to date with the API?
Or not related at all?
Thank you for the contribution! :)

@jenshnielsen
Copy link
Contributor Author

I am honerstly not sure since I have not fully kept up to date with the changes in the API.
This change was motivated by me noticing that this notebook defined a node in json as

{"data": {"id": "BER", "label": "HBf BER", "classes": "east"}}

where as the other examples (both in ipycytoscape and in the cytoscape.js docs) defined it as

{"data": {"id": "BER", "label": "HBf BER"} "classes": "east"}

The first form puts the classes inside the data dict of the node where as the second example puts it in the classes attribute on the node it self. This then in turn has implications for how the css to style classes should be written. And for some reason I cannot get a change to the classes in the former example to trigger a change in style. E.g. if I did cytoscapeobj.graph.nodes[0].data['classes'] = "west" that would not change the color of a "east" class. But doing
but doing cytoscapeobj.graph.nodes[0].classes = "west" works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants