Skip to content

Commit

Permalink
feat(sunburst): allow independent child colors (#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
retypepassword authored and Raphaël Benitte committed Feb 21, 2019
1 parent d2ed5a3 commit 2525ad1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/sunburst/src/Sunburst.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions packages/sunburst/stories/sunburst.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ stories.add(
'with child color modifier',
withInfo()(() => <Sunburst {...commonProperties} childColor="inherit:brighter(0.13)" />)
)

stories.add(
'with child colors independent of parent',
withInfo()(() => <Sunburst {...commonProperties} childColor="noinherit" />)
)

0 comments on commit 2525ad1

Please sign in to comment.