radix-vue / shadcn-vue

Vue port of shadcn-ui
https://www.shadcn-vue.com/
MIT License
4.33k stars 251 forks source link

[Bug]: Donut chart index prop does not render if value is different than "name" #663

Open decito opened 1 month ago

decito commented 1 month ago

Reproduction

https://codesandbox.io/p/devbox/shadcn-vue-donutchartdemo-forked-8z4mt4

Describe the bug

Basically, unless the index property is equal to "name", it does not render the text passed in the property.

Inspecting the code closely, the bug is due to the fact that the const omittedData of the ChartSingleTooltip component is assigning the name value to data.name and not for the value passed in the index prop of the DonutChart component.

I managed to fix the bug in my project by changing the expected to Object.values(data)[0]. I don't have enough knowledge to understand whether this would be the best course of action, nor have I checked whether the ChartSingleTooltip component is being used by another and whether this change breaks the behavior in other imports. Nonetheless, I'll submit a PR.

In the Reproduction, I described two objects, one with the name property and the other with any other. Hovering the chart, one of the names are rendered while the other one isn't.

This is my first bug report here on GitHub :)

System Info

System:
    OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (2) x64 AMD EPYC
    Memory: 1.78 GB / 4.01 GB
    Container: Yes
    Shell: Unknown
Binaries:
    Node: 18.20.4 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.7.0 - /usr/local/bin/npm
npmPackages:
    @vueuse/core: ^10.11.0 => 10.11.0 
    radix-vue: ^1.9.0 => 1.9.1 
    shadcn-vue: latest => 0.10.5 
    vue: latest => 3.4.32

Contributes

entl commented 1 month ago

Hey, could you please double-check access rights to the codesandbox, thanks.

Devbox not found
It's likely that the Devbox you're trying to access doesn't exist or you don't have the required permissions to access it.
If the issue persists, please contact our support team at [support@codesandbox.io](mailto:support@codesandbox.io) for further assistance, making sure to copy the error details below.