react-google-charts
react-google-charts copied to clipboard
Gantt backgroundColor type definition is set to string instead of object
From the original documentation, setting the backgroundColor should be something like backgroundColor: {fill: "#ccc"}
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
Is this still the only viable workaround? This is the only syntax I have found that seems to work.