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

how to add text to nodes and edges? #12

Open
zhiyiZeng opened this issue Jun 5, 2017 · 5 comments
Open

how to add text to nodes and edges? #12

zhiyiZeng opened this issue Jun 5, 2017 · 5 comments

Comments

@zhiyiZeng
Copy link

I'm working on a project about social network, so I'm wondering is there any way to add text to the nodes and edges?

@patrickfuller
Copy link
Owner

There's an example here (and code) that shows how to add text on hover. It uses jQuery to overlay a div with a label. If you want to have all text boxes showing all the time, you can extend the example to recalculate div positions when the mouse is dragged.

Hope this helps!

@ju40268
Copy link

ju40268 commented Dec 4, 2017

Hi!!! I would like to ask for the same feature as well. I am really a newbie to js and have been trying for days.. I would like to display the node name by default if its value is over some threshold, and meanwhile keep the hovering function.

Originally I want to change the onNodeHover function in js, but it did not work out :-(
And I give it another try on the following but still not showing up.

screenshot

Could u please explain more explicitly on how to achieve the feature?
Thanks a lot in advance!!! I love your version of implementing 3d force-directed graph.

@patrickfuller
Copy link
Owner

Thanks!

I'm not planning on adding built-in node labels in the near future, because there are multiple ways to do so and the "right" way depends on use case. This documentation is a good overview.

You've been following the jgraph example that edits the DOM, which only has one label (shown on hover). If you want multiple labels, you'll need to create a div for each label you want to show and then position the div over the node or edge.

Hope this helps!

@diarmaidfinnerty
Copy link

Hi,

How would you add names to nodes using the python jgraph package?

@patrickfuller
Copy link
Owner

Unfortunately, there's no clean API for that right now, and I haven't been maintaining this project.

If you're feeling ambitious, however, it's probably not hard to implement. I'd look at this code to see the node drawing part, then reference three.js' text manual to either add webGL text or make HTML overlays.

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

4 participants