cytoscape / cytoscape-explore

Network visualization webapp.
MIT License
13 stars 4 forks source link

Feature/node aspect ratio #90

Closed mikekucera closed 2 years ago

mikekucera commented 2 years ago

General information

Associated issues: #89

Checklist

Author:

Reviewers:

Notes

mikekucera commented 2 years ago

Sorry, didn't check the mocha tests. I'll commit a fix shortly.

d2fong commented 2 years ago

Sorry, didn't check the mocha tests. I'll commit a fix shortly. @mikekucera This is related to some CX conversion tests I made. Do you mind me committing a fix since I am familiar with the tests/code?

mikekucera commented 2 years ago

Yes please, thanks!

mikekucera commented 2 years ago

Thanks Dylan.

maxkfranz commented 2 years ago

Looks good

A few discussion points:

d2fong commented 2 years ago

Yeah I am considering commenting out the tests I made because they are probably going to break every time someone adds something new. They help me develop CX export functionality but they probably slow everyone else down. Maybe I can just run those locally.

mikekucera commented 2 years ago

Transparency should be multiplicative with the selection state so that they can coexist. E.g., an edge with opacity 0.5 set in the style should be 0.5 * ordinaryDeselectedOpacity when a selection is made that excludes the edge. You probably already accounted for this.

No, I did not consider this. Now my attempts to get it working are not successful.

I'm not sure how/when cytoscape.js applies the transparency to the non-selected elements, but its not working when I apply the ordinaryDeselectedOpacity multiplier (which is 0.33 btw) in the vizmapper.calculate() method. Also, I need to know when some other element in the graph is selected, which I'm doing like this: !ele.cy().$('*:selected).empty() and that seems like it would be very bad for performance to do that for every edge. I also tried adding a listener to the vizmapper for selection events but that seems to get fired after calculate() is called. I need help with this, I'm not familiar enough with cytoscape.js and I'm not sure how to implement this.

mikekucera commented 2 years ago

Also there's a bug with the transparency slider which I'll fix now.

maxkfranz commented 2 years ago

I'm pretty sure it would just be something like this:

'opacity': ele => 0.333 * vizmapper.calculate(ele, 'opacity')

Here:

https://github.com/cytoscape/cytoscape-explore/blob/master/src/client/components/network-editor/index.js#L72

The unselected block overrides the prior, matching blocks, like CSS. If you do styling through the stylesheet, then everything 'just works'. Cytoscape knows when to recalculate style as long as you specify it declaratively in the stylesheet, so you shouldn't need any listeners etc. It's meant to be simple and automatic, as long as you follow CSS conventions.

You can see in the top blocks that all the vizmapper rules work in the same way. They're just being transformed from the vizmapper model to the declarative stylesheet spec.

On Wed, Oct 27, 2021 at 4:09 PM Mike Kucera @.***> wrote:

Transparency should be multiplicative with the selection state so that they can coexist. E.g., an edge with opacity 0.5 set in the style should be 0.5 * ordinaryDeselectedOpacity when a selection is made that excludes the edge. You probably already accounted for this.

No, I did not consider this. Now my attempts to get it working are not successful.

I'm not sure how/when cytoscape.js applies the transparency to the non-selected elements, but its not working when I apply the ordinaryDeselectedOpacity multiplier (which is 0.33 btw) in the vizmapper.calculate() method. Also, I need to know when some other element in the graph is selected, which I'm doing like this: !ele.cy ().$('*:selected).empty() and that seems like it would be very bad for performance to do that for every edge. I also tried adding a listener to the vizmapper for selection events but that seems to get fired after calculate() is called. I need help with this, I'm not familiar enough with cytoscape.js and I'm not sure how to implement this.

— You are receiving this because your review was requested. Reply to this email directly, view it on GitHub https://github.com/cytoscape/cytoscape-explore/pull/90#issuecomment-953270716, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHRO44QJAKS5RJPUQU73CTUJBL6VANCNFSM5GYWQJ2A .

maxkfranz commented 2 years ago

Yeah I am considering commenting out the tests I made because they are probably going to break every time someone adds something new. They help me develop CX export functionality but they probably slow everyone else down. Maybe I can just run those locally.

If you want to do that, you can just put them in a different dir, e.g. tests-cx. Then a different script in package.json can still run your tests, e.g. npm run test:cx