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

Edge labels #50

Open
psychemedia opened this issue Dec 13, 2013 · 5 comments
Open

Edge labels #50

psychemedia opened this issue Dec 13, 2013 · 5 comments

Comments

@psychemedia
Copy link

Is is possible to easily display edge labels either:

  1. attached to each edge, or
  2. in the info box (so for example a list of edge attribute info associated with each node listed in the info box).

What I'd like to do is pass in a graph where the edge labels are descriptive text, and when I search for a node to see the other nodes it's connected to, get a list of those nodes along with the appropriate edge description.

(I guess the general case would be multi-edges with different labels, in which case it would be nice to list each label edge associated with a particular node).

@computermacgyver
Copy link
Member

Thanks for writing and suggesting this. I am working on edge labels directly for edges, but it is part of a large overhaul of the underlying sigmajs code to replace the drawing functions with a full canvas library (using kineticjs right now). Links with this issue

The idea of adding labels to the info box is much easier and probably something that could be added fairly quickly. If you have a bit of JavaScript experience, the basic change needs to happen are:

  • At line 463 of main.js store whatever attribute is desired temporarily into the data structure 'n' (e.g., attribute: b.myattribute)
  • At line 501 to transfer this attribute over to the new per node structure (e.g., attribute: c[g].attribute
  • Finally at line 521 adjust the html to actually print out the attribute (e.g., '('+c.attribute+')')

The only issue I can see arising is how to handle parallel edges in multigraphs (e.g., what should happen if edge a-->b has attribute x, but another parallel edge also connecting a-->b has attribute y). As long as this doesn't occur in your graphs the above changes should work fine.

If you can make the changes and contribute back the code that would be great. If you'd prefer, I'm happy to make the changes as well; I just need to find time to do the testing, etc. Cheers.

@vulpessepluv
Copy link

vulpessepluv commented Nov 27, 2016

Follow up question :
I seem to be stuck with the same question as psychemedia - was the adapted code ever contributed back, or else are the changes that need to be done somehow available?

Greets, v

@computermacgyver
Copy link
Member

Hi vulpessepluv, the changes are described above, but this is one variation that I didn't actually code up myself. The version of sigmajs we use in the plugin at the moment makes it very hard to detect edge hover events, but the newest version of sigmajs makes this easier. We are working on a new version of the plugin, but it is not yet ready for release. Until then, the changes above would work if you only have one edge attribute to display. If you have more than one edge attribute, I would recommend a custom interface using the newest version of sigma for now.

@vulpessepluv
Copy link

vulpessepluv commented Dec 1, 2016

Hi Scott, thanks a lot for the fast answere!
It seems the exact line numbers have changed a bit due to changes over time.

The only problem I experience is to include '('+c.attribute+')' the right way at the right position, I'd be eternally grateful for a hint, since it's really the last thing I need for my project!

f.push('<li class="membership"><a href="#' + c.name + '" onmouseover="sigInst._core.plotter.drawHoverNode(sigInst._core.graph.nodesIndex[\'' + c.id + '\'])\" onclick=\"nodeActive(\'' + c.id + '\')" onmouseout="sigInst.refresh()">' + c.name + "</a></li>");

Greets, v

@TianzhuQin
Copy link

I guess the code has been changed for long years. But this issue also make me crazy one time. Here is my code for the last step.@vulpessepluv

f.push('<li class="membership"><a href="#' + c.name + '" onmouseover="sigInst._core.plotter.drawHoverNode(sigInst._core.graph.nodesIndex[\'' + c.id + '\'])\" onclick=\"nodeActive(\'' + c.id + '\')" onmouseout="sigInst.refresh()">' + c.name + "</a> (" + c.group + ")</li>");

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

No branches or pull requests

4 participants