diff --git a/packages/colors/src/inheritedColor.ts b/packages/colors/src/inheritedColor.ts index 162fd58eae..fbd73fdf81 100644 --- a/packages/colors/src/inheritedColor.ts +++ b/packages/colors/src/inheritedColor.ts @@ -15,7 +15,7 @@ export type ColorModifierFunction = (color: RGBColor) => RGBColor export type InheritedColorConfigStaticColor = string -export type InheritedColorConfigCustomFunction = (d: Datum) => string +export type InheritedColorConfigCustomFunction = (d: Datum, ...drest: Datum[]) => string export interface InheritedColorConfigFromTheme { theme: string @@ -61,7 +61,7 @@ export const getInheritedColorGenerator = ( ) => { // user provided function if (typeof config === 'function') { - return (datum: Datum) => config(datum) + return config } if (isPlainObject(config)) { diff --git a/packages/sunburst/src/hooks.ts b/packages/sunburst/src/hooks.ts index 293c001dcf..f0318c9dc4 100644 --- a/packages/sunburst/src/hooks.ts +++ b/packages/sunburst/src/hooks.ts @@ -108,7 +108,7 @@ export const useSunburst = ({ } if (inheritColorFromParent && parent && normalizedNode.depth > 1) { - normalizedNode.color = getChildColor(parent) + normalizedNode.color = getChildColor(parent, normalizedNode) } else { normalizedNode.color = getColor(normalizedNode) } diff --git a/packages/sunburst/stories/sunburst.stories.tsx b/packages/sunburst/stories/sunburst.stories.tsx index fdd8fdb40d..6f219cddef 100644 --- a/packages/sunburst/stories/sunburst.stories.tsx +++ b/packages/sunburst/stories/sunburst.stories.tsx @@ -46,6 +46,13 @@ stories.add('with custom colors', () => ( {...commonProperties} colors={customPalette} /> )) +stories.add('with custom child colors', () => ( + {...commonProperties} childColor={(parent, child) => { + // @ts-expect-error + return child.data.color; + }} /> +)) + stories.add('with formatted tooltip value', () => ( {...commonProperties} valueFormat=" >-$,.2f" /> ))