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

[Metric] It's not possible to format non-numeric value #2206

Open
mbondyra opened this issue Oct 18, 2023 · 2 comments
Open

[Metric] It's not possible to format non-numeric value #2206

mbondyra opened this issue Oct 18, 2023 · 2 comments
Labels
bug Something isn't working :metric Related to Metric chart

Comments

@mbondyra
Copy link
Contributor

mbondyra commented Oct 18, 2023

Describe the issue

  1. Go here: https://codesandbox.io/s/long-legend-sizing-forked-h83q6s?file=/src/App.tsx:127-134 and analyze the code, specifically the passed valueFormatter.
  2. It will never run if the value is not a number
  3. If you change it to number, the valueFormatter runs

Specifically, here's my usecase: I am working on adding other types of data to be supported by visualization ('string', 'boolean', 'number', 'ip', 'date') to match the legacy metric.

Screenshot 2023-10-18 at 14 00 14

While strings, booleans and ip don't need extra format to be passed, we need it for dates as we get them as strings. Not sure if there's another way to handle that. Let me know if that's not a bug and there is another way!

@mbondyra mbondyra added bug Something isn't working :metric Related to Metric chart labels Oct 18, 2023
@mbondyra
Copy link
Contributor Author

mbondyra commented Oct 18, 2023

Just an update from my side: I found a way of passing already a formatted value. That's probably not ideal, but works! So instead of

{
    value,
    valueFormatter: formatPrimaryMetric,
}

I pass

{
    value: formatPrimaryMetric(value),
}

@nickofthyme
Copy link
Collaborator

Good point @mbondyra I think in #1817 we just assumed it would be redundant to format a string but I think there is definitely a use for this. In any case I think it's strange the valueFormatter has no affect with string values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working :metric Related to Metric chart
Projects
None yet
Development

No branches or pull requests

2 participants