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

updating graph style by adding element to the set_style list not working. #197

Closed
joseberlines opened this issue Dec 9, 2020 · 4 comments

Comments

@joseberlines
Copy link
Contributor

joseberlines commented Dec 9, 2020

I have a graph called ipycytoscape_obj9 with a particular my_style.

assume I add a node and two edges to that node.
And then I want to update also the style of the edges.
as in:

my_style.append({'selector': 'edge[id = "line6"]',
                 'style': {
                     'font-family': 'arial',
                     'font-size': '10px',
                     'label': 'data(label)'}})
my_style.append({'selector': 'edge[id = "line7"]',
                 'style': {
                     'font-family': 'arial',
                     'font-size': '10px',
                     'label': 'data(label)'}})
ipycytoscape_obj9.set_style(my_style)

If I print out in the next cell the graph I would expect that the new appended styles are taking into account for edges 6 and 7. that is not the case.

Only starting from scratch with a new graph the new styles would be matched by printing/displaying/rendering the graph:

ipycytoscape_obj10 = ipycytoscape.CytoscapeWidget()
ipycytoscape_obj10.graph.add_graph_from_json(railnetJSON)
ipycytoscape_obj10.graph.add_node(station_NUR)
ipycytoscape_obj10.graph.add_edges([new_edge1,new_edge2])
ipycytoscape_obj10.set_style(my_style)
ipycytoscape_obj10

looking at the source code there is no method to "add_style" so I assumed that changing the json style and pass it again to the graph will do it. but it does not.

POST EDIT: I have the impression that the graph including styles has to be re-created from scratch. adding nodes and edges is ok, but adding styles isnt.

@ianhi
Copy link
Collaborator

ianhi commented Dec 16, 2020

What version of ipycytoscape are you seeing this on?

@joseberlines
Copy link
Contributor Author

print(ipycytoscape.version)
1.0.4

@marimeireles
Copy link
Collaborator

Thanks for the issue @joseberlines will investigate now =)

@marimeireles
Copy link
Collaborator

This happens because of #56. I'm closing this and moving the discussion to there.
Thanks for the issue!

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

No branches or pull requests

3 participants