Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type Error in Nested Donut Example #517

Open
curran opened this issue Dec 30, 2024 · 3 comments
Open

Type Error in Nested Donut Example #517

curran opened this issue Dec 30, 2024 · 3 comments

Comments

@curran
Copy link

curran commented Dec 30, 2024

I notice that in

packages/dev/src/examples/misc/nested-donut/basic-nested-donut/index.tsx

there is a type error:

Type 'number' is not assignable to type 'string'.

at this line:

<VisNestedDonut
  data={data}
  centralLabel='Central Label'
  centralSubLabel='Sub-label'
  layers={[
    (d: NestedDatum) => d.group,
    (d: NestedDatum) => d.subgroup,
    (d: NestedDatum) => d.value, // <--- Type error on this line here
  ]}

I'm using this as a reference for implementing a Treemap, and I'm skeptical if I should copy this API over to the new component, or if there is something wrong with the example implementation.

@curran
Copy link
Author

curran commented Dec 30, 2024

Should it be like this maybe?

value={(d: NestedDatum) => d.value as number}
layers={[
  (d: NestedDatum) => d.group,
  (d: NestedDatum) => d.subgroup,
]}

@curran
Copy link
Author

curran commented Dec 30, 2024

Nope, that's not right. Perhaps this would be the best fix:

<VisNestedDonut
  data={data}
  centralLabel='Central Label'
  centralSubLabel='Sub-label'
  layers={[
    (d: NestedDatum) => d.group,
    (d: NestedDatum) => d.subgroup,
    (d: NestedDatum) => d.value as string,
  ]}

since a datum looks like this

{group: 'C', subgroup: 'C2', value: 'C2a'}

@rokotyan
Copy link
Contributor

rokotyan commented Jan 3, 2025

Good observation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants