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

Add Support to pass a function to node.labelProperty #135

Merged
merged 9 commits into from Oct 17, 2018

Conversation

dgautsch
Copy link
Contributor

@dgautsch dgautsch commented Oct 16, 2018

Changes

  • If config.node.labelProperty is a string follow the current approach
  • If config.node.labelProperty is a function then call that function and pass in the node as parameter
  • Implement a sample config.node.labelProperty in the marvel dataset where the output of labelProperty is the concatenation of the characterid+ the charactername`

Fixes #133

@dgautsch dgautsch changed the title Adds Support to pass a function to node.labelProperty Add Support to pass a function to node.labelProperty Oct 16, 2018
@@ -30,7 +30,7 @@ module.exports = {
highlightFontWeight: 'bold',
highlightStrokeColor: 'red',
highlightStrokeWidth: 1.5,
labelProperty: 'id',
labelProperty: n => n.id + n.name,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
labelProperty: n => n.id + n.name,
labelProperty: n => `${n.id} - ${n.name}`,

package.json Outdated
@@ -7,7 +7,7 @@
"scripts": {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase with master and also drop the changes on sandbox/rd3g.sandbox.**

@@ -331,6 +331,7 @@ function buildNodeProps(node, config, nodeCallbacks = {}, highlightedNode, highl
node.id === (highlightedLink && highlightedLink.target));
const opacity = _getNodeOpacity(node, highlightedNode, highlightedLink, config);
let fill = node.color || config.node.color;
let labelProperty = node[config.node.labelProperty] || node.id;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename labelProperty to label and move this assignment next to the new logic that you added

Copy link
Owner

@danielcaldas danielcaldas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some minor comments.

@dgautsch
Copy link
Contributor Author

@danielcaldas Thanks for the feedback! I made the changes you suggested.

@danielcaldas
Copy link
Owner

Sweet!

@danielcaldas danielcaldas merged commit 390e5d5 into danielcaldas:master Oct 17, 2018
@dgautsch dgautsch deleted the fix/133 branch October 17, 2018 20:21
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

Successfully merging this pull request may close these issues.

None yet

2 participants