danielcaldas / react-d3-graph

Interactive and configurable graphs with react and d3 effortlessly
https://danielcaldas.github.io/react-d3-graph/sandbox/
MIT License
818 stars 233 forks source link

Add legend to graph support? #359

Open michaelbdavid opened 4 years ago

michaelbdavid commented 4 years ago

Hey @danielcaldas , I was wondering if there is a way to add a legend to describe nodes added to graph? Looking through documentation I did not see anything like this but was hoping either this could be a new feature or you could give me some pointers how this could be done?

Right now I'm looking into just displaying a div overtop or near the graph to display this data but it would be awesome if there was someway to integrate legend directly within the graph.

btw loving rd3g keep up the good work!

Thanks for your time in advance, Michael

danielcaldas commented 4 years ago

Hey there @michaelbdavid this is certainly a feature request, there's nothing similar today in react-d3-graph to what you've described.

Usually, I try to look at feature requests as the following:

Anyways I would like to keep this as a feature request and let's see if any other developers have a particular interest or different views on this.

michaelbdavid commented 4 years ago

Hey @danielcaldas,
Thanks for looking into this for me. I was thinking about this more and was wondering if this could actually be added pretty easily by adding in another custom node configuration? This would be similar to what you currently do with viewGenerator except maybe it has away to give it placement within the graph. What do you think just a thought I had? I also wanted to ask is there a way to have several different types of cusomNodes in a graph? If this is possible in theory a user could create a separate node that could represent the legend.

Thanks again, Michael

michaelbdavid commented 4 years ago

Cool it looks like this will work. Basically create a custom node specific to legend data and display it without any links. Its kind of a hack but I think this will look pretty sweet if I could tell the node where I always want it to display.

michaelbdavid commented 4 years ago

So just to follow up. I was able to create a legend using custom node component and setting x,y. For others interested, take a look at the custom node example. I basically have several different types of nodes with different viewGenerators. One of the nodes that I create has no relationships and has a viewGenerator that creates my legend.

danielcaldas commented 4 years ago

Hey there @michaelbdavid thanks for the update, glad you could make it work. Any screenshots you may be willing to share so that developers looking into this thread might get an idea of how this looks like? Thanks!

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.