react-google-charts icon indicating copy to clipboard operation
react-google-charts copied to clipboard

Gantt backgroundColor type definition is set to string instead of object

Open Cry0nicS opened this issue 4 years ago • 1 comments

From the original documentation, setting the backgroundColor should be something like backgroundColor: {fill: "#ccc"} image

However, inside the ChartWrapperOptions, the backgroundColor is defined as a string, not as object. Hence, setting the property as described in the documentation yelds

TS2769: No overload matches this call.   Overload 1 of 2, '(props: Readonly<ReactGoogleChartProps>): Chart', gave the following error.     Type '{ fill: string; }' is not assignable to type 'string'.   Overload 2 of 2, '(props: ReactGoogleChartProps, context?: any): Chart', gave the following error.     Type '{ fill: string; }' is not assignable to type 'string'.

For what is worth, ignoring any errors, setting backgroundColor: "#ccc won't work. However, backgroundColor: {fill: "#ccc"} does work.

My temporary workaround: backgroundColor: ({fill: "#ccc"} as unknown) as string

Cry0nicS avatar Jun 16 '20 14:06 Cry0nicS

Is this still the only viable workaround? This is the only syntax I have found that seems to work.

Moxie1776 avatar Jun 30 '23 01:06 Moxie1776