From 2525ad11fa6bbec6d03e2b814df4e526c5a8ea67 Mon Sep 17 00:00:00 2001 From: Eric Lin Date: Thu, 21 Feb 2019 08:30:42 -0800 Subject: [PATCH] feat(sunburst): allow independent child colors (#463) --- packages/sunburst/src/Sunburst.js | 4 ++-- packages/sunburst/stories/sunburst.stories.js | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/sunburst/src/Sunburst.js b/packages/sunburst/src/Sunburst.js index 89c23b8c1..fa721ca51 100644 --- a/packages/sunburst/src/Sunburst.js +++ b/packages/sunburst/src/Sunburst.js @@ -157,7 +157,7 @@ const enhance = compose( })), withPropsOnChange( ['data', 'partition', 'getIdentity', 'getChildColor'], - ({ data, partition, getIdentity, getColor, getChildColor }) => { + ({ data, partition, getIdentity, getColor, childColor, getChildColor }) => { const total = data.value const nodes = sortBy(partition(cloneDeep(data)).descendants(), 'depth') @@ -175,7 +175,7 @@ const enhance = compose( ancestor, }) - if (node.depth === 1) { + if (node.depth === 1 || childColor === 'noinherit') { node.data.color = getColor(node.data) } else if (node.depth > 1) { node.data.color = getChildColor(node.parent.data) diff --git a/packages/sunburst/stories/sunburst.stories.js b/packages/sunburst/stories/sunburst.stories.js index 6cec51184..eea51d45a 100644 --- a/packages/sunburst/stories/sunburst.stories.js +++ b/packages/sunburst/stories/sunburst.stories.js @@ -24,3 +24,8 @@ stories.add( 'with child color modifier', withInfo()(() => ) ) + +stories.add( + 'with child colors independent of parent', + withInfo()(() => ) +)