question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add granular change to style so user doesn't have to repeat the content of style every time they want to update it

See original GitHub issue

The issue: every time style is updated the user needs to copy the old style and add the new parts to it if they want to include something new. E.g: if you have a style set on your graph and now you want to add new commands to this style, instead of simply calling the set_style method with your new commands, you need to copy all the style content of your graph + the new commands.

See 1, https://github.com/cytoscape/ipycytoscape/issues/270, https://github.com/cytoscape/ipycytoscape/issues/197.

Explanation: This happens because cytoscape.js, the library which ipycytoscape draws from, need to have the following style configuration to show up arrows:

            {
                "selector": "edge.directed",
                "style": {
                    "curve-style": "bezier",
                    "target-arrow-shape": "triangle",
                    "target-arrow-color": "#9dbaea",
                },
            },

(Of course you can change the shape and color of the arrow, but it’s necessary to specify these three attrs in order to see them).

The problem here is that because of traitlets implementation (the library in which Jupyter lab depends on to sync the backend with the frontend attrs) doesn’t offer support to deep objects like lists or dictionaries. In other words, it’s only syncing simple objects like ints and strings automatically. Fortunately, I was able to overcome this issue in ipycytoscape using a library called spectate. However, spectate doesn’t seem to be able to sync nested deep objects, aka, a dict inside a dict as we have when creating styles.

One way to fix it: creating an API like this. Positive: seems like it will work Negative: too much code to write, very different from current API, users will have to change their code

Another way to fix it: make the MutableDict work with this. Positive: less code, more elegant solution, minimal changes to current API. users will also have to change their code, but just by adding one word. Negative: I spent some time looking into it and couldn’t make it work. Not sure why.

Thinking it further, ideally I think we would have both solutions as we strive to keep cytoscape.js and ipycy as close as possible API wise.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
marimeirelescommented, Jul 27, 2021

Okay! Earlier today I got the answer! It’s pretty simple: We just have to adapt the deepcopy code from set_layout. Just have to take care to not overwrite keys and to keep the cytoscape.style object as a MutableDict. I’m not sure when I’ll be able to implement it cause I want to work on other things now, so if anyone feels like it, please feel free. I’ll try to do it some time this week!

1reaction
marimeirelescommented, Sep 30, 2020

This can be done in many parts. One attribute you add will already help! 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Granular control over site styles with css - Stack Overflow
This is controlled by PHP and mysql. When a user logs in, and slects a non-default style, it is added against their user...
Read more >
aggregated suggestions · Issue #46 · cytoscape/ipycytoscape · GitHub
4. create an add_to_style method. If I do want to make a directed graph and want to style the edges to be directed...
Read more >
list-style-type - CSS: Cascading Style Sheets - MDN Web Docs
The list-style-type CSS property sets the marker (such as a disc, character, or custom counter style) of a list item element.
Read more >
Word: Add more levels to a TOC - CyberText Newsletter
Click the Modify button. Select the TOC level style you want to modify, then click the Modify button on the Style window. On...
Read more >
Custom CSS - FormAssembly Resource Center
Please note: This guide is meant to help you get started with adding custom CSS to your form. You can use the examples...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found