coinjar / react-native-wagmi-charts

A sweet & simple chart library for React Native that will make us feel like We're All Gonna Make It.
MIT License
588 stars 116 forks source link

Ability to control precision of textlabels #127

Closed ArkyBald closed 7 months ago

ArkyBald commented 1 year ago

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

arancauchi commented 1 year ago

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.

michaelpomogajko commented 1 year ago

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.

michaelpomogajko commented 11 months ago

@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?

JuanRdBO commented 10 months ago

The format function actually does work with the tooltip:

Screenshot 2024-01-12 at 16 28 22

michaelpomogajko commented 10 months ago

@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

michaelpomogajko commented 10 months ago

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

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