Open hhenriques1999 opened 1 year ago
Hi, thank you for your good question!
The issue is a typings one. The data array requirement originates from chart.js and I'm not sure it can be changed externally.
The documentation is correct in the aspect that the data array will be populated and is not strictly required by the code, but typings just don't agree. You could use a @ts-ignore or @ts-expect-error comment to suppress the type error, but I'd recommend your already working approach of just providing the empty data array to satisfy the types too.
I was trying to implement a sample treemap graph to test and then fully implement it in an application.
My application is React based using:
Here's how I was trying to set it up:
However, unless I set data: []:
I get errors at the chart call (around line 64):
The error:
Property 'data' is missing in type '{ label: string; tree: number[]; borderColor: string; borderWidth: number; spacing: number; backgroundColor: string; }' but required in type 'ChartDatasetProperties<"treemap", TreemapDataPoint[]>'
This kind of "contradicts" the documentation which states that data would be automatically populated/built... It requires me to set it up as an empty array otherwise it will error out on me (it may be my linting settings?)
Once it's set up, the error goes away and everything works properly (ignore the bright red, it's my fault):
So, is this an implementation issue or documentation issue. Or worse, a user issue 😶.