diff --git a/src/components/graph/graph.config.js b/src/components/graph/graph.config.js index 6be42acf9..62ac487aa 100644 --- a/src/components/graph/graph.config.js +++ b/src/components/graph/graph.config.js @@ -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. diff --git a/src/components/graph/graph.helper.js b/src/components/graph/graph.helper.js index 057cdcc06..2212a4567 100644 --- a/src/components/graph/graph.helper.js +++ b/src/components/graph/graph.helper.js @@ -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; diff --git a/test/component/graph/graph.helper.test.js b/test/component/graph/graph.helper.test.js index ffa77cf3a..d6960453d 100644 --- a/test/component/graph/graph.helper.test.js +++ b/test/component/graph/graph.helper.test.js @@ -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', () => {