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

Allow nodes to override strokeColor #123

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/graph/graph.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
* @param {boolean} [node.renderLabel=true] - when set to false no labels will appear along side nodes in the
* graph.
* @param {number} [node.size=200] - 🔍🔍🔍 defines the size of all nodes.
* @param {string} [node.strokeColor='none'] - color for the stroke of each node.
* @param {string} [node.strokeColor='none'] - 🔍🔍🔍 this is the stroke color that will be applied to the node if no **strokeColor property** is found inside the node itself (yes **you can pass a property 'strokeColor' inside the node and that stroke color will override this default one** ).
* @param {number} [node.strokeWidth=1.5] - the width of the all node strokes.
* @param {string} [node.svg=''] - 🔍🔍🔍 render custom svg for nodes in alternative to **node.symbolType**. This svg can
* be provided as a string to either a remote svg resource or for a local one.
Expand Down
2 changes: 1 addition & 1 deletion src/components/graph/graph.helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ function buildNodeProps(node, config, nodeCallbacks = {}, highlightedNode, highl
fill = config.node.highlightColor;
}

let stroke = config.node.strokeColor;
let stroke = node.strokeColor || config.node.strokeColor;

if (highlight && config.node.highlightStrokeColor !== CONST.KEYWORDS.SAME) {
stroke = config.node.highlightStrokeColor;
Expand Down
21 changes: 21 additions & 0 deletions test/component/graph/graph.helper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,27 @@ describe('Graph Helper', () => {
});
});
});
describe('and no custom strokeColor is set', () => {
test('should return the default strokeColor in the props', () => {
const props = graphHelper.buildNodeProps(that.node, that.config, undefined, undefined, undefined, 1);

expect(props.stroke).toEqual('none');
});
});
describe('and custom strokeColor is set to yellow', () => {
test('should return yellow strokeColor in the props', () => {
const props = graphHelper.buildNodeProps(
{ ...that.node, strokeColor: 'yellow' },
that.config,
undefined,
undefined,
undefined,
1
);

expect(props.stroke).toEqual('yellow');
});
});
});

describe('#initializeGraphState', () => {
Expand Down