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

[Bug]: GaugeChart — "numberFormatter" typing is wrong #1951

Open
2 of 6 tasks
janhassel opened this issue Jan 29, 2025 · 0 comments
Open
2 of 6 tasks

[Bug]: GaugeChart — "numberFormatter" typing is wrong #1951

janhassel opened this issue Jan 29, 2025 · 0 comments

Comments

@janhassel
Copy link
Member

Relevant package(s)

  • @carbon/charts
  • @carbon/charts-svelte
  • @carbon/charts-react
  • @carbon/charts-angular
  • @carbon/charts-vue
  • Documentation website

Carbon Charts Version

1.22.15

Which bundler are you using?

Vite

What happened and what did you expect to happen?

The type definition for options.gauge.numberFormatter for the GaugeChart is ((value: number) => string) | undefined. Despite announcing that the incoming value will be of type number, it is actually a string. This means strict equality comparisons with numbers will fail and developers either have to use loose comparisons or compare against a string which will throw a TypeScript warning.

Image Image Image

Chart data and options (automatically formatted so no need for backticks)

{
  data: [
    {
      group: 'value',
      value: 66.67,
    },
  ],
  options: {
    gauge: {
      numberFormatter: (val) => {
        console.log(val, typeof val);

        return val.toString();
      },
    },
  },
}

JavaScript console or build output (if relevant)

66.67  "string"

StackBlitz repro

No response

IBM Application/Team (if relevant)

No response

What priority level would this be in your opinion?

P3 (Low)

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

1 participant