-
-
Notifications
You must be signed in to change notification settings - Fork 123
Add svg image generation #88
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
Conversation
@alexcjohnson can you resolve these two conflicts?
|
Hi Ivo! Could you rebase your branch on the current masters? if that doesn't resolve the conflicts, I can look into it. |
That option should be available on Github; if it's not, feel free to use |
Also once the conflicts are resolved, could you double check if the elements in my review from the previous PR were incorporated? Thanks! |
@xhlulu These are the ones you were mentioning, right?
|
Just for the records a small disclaimer: I have not managed to modify the react code in such a way that I was able to generate the string of the svg. Therefore, I added in usage-image-export and in Cytoscape.react.js the disclaimer that for the option 'store' only jpg and png are supported. Maybe someone else has an idea or want to add this in a follow up release. |
Thanks for adding to those suggestions! Would it be possible to share a GIF of the Also, just to make sure: Have you ran |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Ivo! Thank you for not only continuing this PR, but also adding substantial changes to support exporting in SVG. This is super appreciated.
I added a few comments specifically about the changes from the SVG module; whenever you have the time, could you take a look at them? Overall, I think we are close to merging the PR, as long as the comments are addressed and the tests all pass.
I saw that you added package-lock.json
; are you perhaps using npm? At the start of the project we settled on using yarn, so it would be great if we don't have multiple lock files. Let me know if you have any question about yarn
.
* React.js requirements: react-cytoscapejs | ||
*/ | ||
import cytoscape from 'cytoscape'; | ||
import svg from 'cytoscape-svg'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if it's a good idea to add svg
to the main module, since we want to minimize the file size when loading dash-cytoscape; also, adding one more package here means more dependencies to keep track. This is the reason why we have an extra_index.js
that loads all of the external dependencies.
Do you believe this should stay in the main file, or would it be better to have it in the extra_index.js
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a good idea, I was not aware of the exta_index.js before.
I just tried to add it to extra index.js and it works as expected :)
However, following that logic I guess it would be a good idea to put the plugins in an new file. On top it kinda feels wrong to enable the svg export feature with cyto.load_extra_layouts().
Since I do not 100% understand how to implement this I just added a plugins_index.js file as a reminder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ivo, please add a function directly to __init__
similar to this one, except here you would use _plugins
instead of _extra
. The function name could be load_plugins
, and an example on how to use it could be added to the readme
right below this section.
Feel free to also load it in your new usage app, if you have time. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are totally right on the confusion around extra_index.js. I think it's something I can add in a future release of Cytoscape, inside CONTRIBUTION.md, so people that want to add more plugin could easily do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think this might not be the best way. Maybe it's better to keep it inside extra_index.js
. More discussions below.
Thank you @xhlulu for the encouraging words 😃 These should be now all required changes meaning I am ready to merge 🚀 Update:
Should I just add a random |
Regarding:
You meant Regarding:
I removed it |
Thanks! Adding random prints is fine. |
@xhlulu just added the random print statement 🤞
When I installed it the first time I used npm and was tearing my hairs out |
CC: @alexcjohnson @Marc-Andre-Rivet So in this PR, we need to load an external package, which is usually done by calling // Imports
...
// Load
CytoscapeJS.use(coseBilkent);
CytoscapeJS.use(cola);
CytoscapeJS.use(dagre);
CytoscapeJS.use(euler);
CytoscapeJS.use(klay);
CytoscapeJS.use(spread);
export {
Cytoscape
}; The full Then, the file is loaded with a However, two options are possible:
In the case of the second option, we'd need to essentially:
For simplicity, I think it's better to go with the first option, and in a future release we could deprecate the function |
@xhlulu there seems to be some flakyness with ci 😬
|
@IvoLeist After discussing about this, I think we will move forward with option 1, so you won't need to make any change concerning |
Yes, I think this is fine. As discussed with @xhlulu on slack, long-term we can expect to turn each of the extra layouts and the SVG generation code into async chunks that would get loaded on demand, in which case we can get rid of |
This will be a 💃 for me. @IvoLeist Let me know if there's anything else you'd like to add, but otherwise I can merge this. |
@xhlulu Fine for me let's go 🚀 |
You all are awesome! Thanks for working on this! |
About
This PR is an extension of this PR which provides access to the existing Cytoscape.js image generation APIs, cy.png() and cy.jpg(), via Dash callbacks. It allows the current view of a Cytoscape graph to be saved as an image, stored as a base64 string or data URL, and/or downloaded as a file.
On top it enables the generation of an .svg file using that cytoscape plugin
Description of changes
This PR adds to the generateImage and imageData properties the possibility to generate an svg image.
Pre-Merge checklist
yarn run build:all
. !npm is buggyReference Issues
No current issues related to this PR.
Other comments
Please note that it is only building correctly if yarn is used.
If you use npm and need compound nodes to be fixed at one place
building dash-cytoscape with npm will result in unexpected behaviours
( = freely floating children nodes)