coinjar/react-native-wagmi-charts

Ability to control precision of textlabels

ArkyBald opened this issue · 6 comments

Would be nice to have the ability to control the precision of textlabels, similar to how the price display works. Thanks

Hi @ArkyBald by text labels do you mean for example LineChart.Tooltip or LineChart.PriceText? If so, the formatting of those can be controlled using the format worklet function.

Would like to piggy bag on this. In my use case I only work with whole numbers.
Would be nice to be able to set formatting on the tooltip directly, or also have the prop 'variant' to display the value as is, and not having the double float digit.

@arancauchi resurfacing this issue.
There is no apparent way to format a tooltips text. The format worklet only works with PirceText, not with the tooltip.
Any ideas?

The format function actually does work with the tooltip:

Screenshot 2024-01-12 at 16 28 22

@JuanRdBO thanks for the tip, but unfortunately getting the following error when trying to do it with

textProps={{
  format: ({ formatted }) => {
    return Number(formatted).toFixed(0);
   },
}}

Simulator Screenshot - iPhone 15 Pro - 2024-01-13 at 00 57 07

@JuanRdBO actually you're right, adding the worklet directive solves it

textProps={{
  format: ({ value }) => {
   'worklet';
   return Number(value).toFixed(0);
  },
}}