-
Notifications
You must be signed in to change notification settings - Fork 231
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Customize color for a link #79
Customize color for a link #79
Conversation
When adding links to a dataset now, we can add optionally include a 'color' property. If it's set, said color will override the default color defined in the configuration object. In order for this to work, the 'buildLinkProps' is now receiving a 'link' object, which could contain any additional data aside from the source and target nodes. In this case, we'll be only considering a 'color' property that will be taken into account when setting the stroke color of the line to draw. The former 'source' and 'target' parameters that used to be stand-alone parameters in the function, are now data contained inside of the new 'link' object.
Added some new tests in the 'graph.helper.test' suite to check whether the customization of the color for a certain link is working correctly. We will be checking whether the stroke color matches the expected one in both scenarios: when a custom color is set and when no color has been passed along the link data.
Hi there! Thanks for the feedback, @danielcaldas! It doesn't seem to work just by doing what you say, though. It didn't for me when I run the sandbox example, at least. 馃槥 Both
Is there any case in which you'll actually be receiving a string with the id instead of an object? You had this on the code implying it is a possibility, but it doesn't seem like it can actually happen now.
Also, you had this comment on line 30:
Could this have something to do with the change you are proposing? 馃 At any rate, if we want to pass
This one would work as long as Does any of these choices look right to you? |
Hey thanks for providing the options but I prefer the one you have currently where |
* Customizable color for individual links When adding links to a dataset now, we can add optionally include a 'color' property. If it's set, said color will override the default color defined in the configuration object. In order for this to work, the 'buildLinkProps' is now receiving a 'link' object, which could contain any additional data aside from the source and target nodes. In this case, we'll be only considering a 'color' property that will be taken into account when setting the stroke color of the line to draw. The former 'source' and 'target' parameters that used to be stand-alone parameters in the function, are now data contained inside of the new 'link' object. * Add tests for custom link feature Added some new tests in the 'graph.helper.test' suite to check whether the customization of the color for a certain link is working correctly. We will be checking whether the stroke color matches the expected one in both scenarios: when a custom color is set and when no color has been passed along the link data.
This is a great feature. Thank you for adding it. It works great the first time we setup the graph but when we add new nodes and link the link go back to being the default color and not using the setting set in the edge's configuration. Is there something extra I need to do to have it use the link's color? |
Hi, @wendymungovan thanks for the feedback please submit an issue with your request and try to explain the problem with a little more detail. |
FYI @wendymungovan @LonelyPrincess the issue that @wendymungovan is referring to in the comment above (Jan 30), was fixed in this PR #220. This was released with react-d3-graph v2.2.0 |
I was planning on using your library for a project I'm currently working on, but I needed to be able to customize the color for each link separately. I saw a recently closed issue requesting this feature (#71) and that there was no one who had offered to implement it yet, so I decided to give it a go.
This set of changes is the result, and it makes it possible to set a custom color for single link when defining its data:
{ source: 'A', target: 'B', color: 'orange' }
A couple of tests were also included to ensure the behaviour is as expected:
PS: Very beautifully written and documented code, it was a real joy to work with. Congratulations and thanks for your hard work! 馃槈