Skip to content
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
4 changes: 2 additions & 2 deletions packages/colors/src/inheritedColor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type ColorModifierFunction = (color: RGBColor) => RGBColor

export type InheritedColorConfigStaticColor = string

export type InheritedColorConfigCustomFunction<Datum> = (d: Datum) => string
export type InheritedColorConfigCustomFunction<Datum> = (d: Datum, ...drest: Datum[]) => string

export interface InheritedColorConfigFromTheme {
theme: string
Expand Down Expand Up @@ -61,7 +61,7 @@ export const getInheritedColorGenerator = <Datum = any>(
) => {
// user provided function
if (typeof config === 'function') {
return (datum: Datum) => config(datum)
return config
}

if (isPlainObject(config)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/sunburst/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const useSunburst = <RawDatum>({
}

if (inheritColorFromParent && parent && normalizedNode.depth > 1) {
normalizedNode.color = getChildColor(parent)
normalizedNode.color = getChildColor(parent, normalizedNode)
} else {
normalizedNode.color = getColor(normalizedNode)
}
Expand Down
7 changes: 7 additions & 0 deletions packages/sunburst/stories/sunburst.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ stories.add('with custom colors', () => (
<Sunburst<RawDatum> {...commonProperties} colors={customPalette} />
))

stories.add('with custom child colors', () => (
<Sunburst<RawDatum> {...commonProperties} childColor={(parent, child) => {
// @ts-expect-error
return child.data.color;
}} />
))

stories.add('with formatted tooltip value', () => (
<Sunburst<RawDatum> {...commonProperties} valueFormat=" >-$,.2f" />
))
Expand Down