plain-dev / MPAndroidChartDemo

MPAndroidChart library content demonstration and implementation of big decimal charts, rounded charts and range charts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MPAndroidChart Demo

MPAndroidChart Demo

MPAndroidChart library content demonstration and implementation of big decimal charts, rounded charts and range charts

> Browse MPAndroidChart Library

Use Big Decimal Data πŸ’­

> Browse Issue

IDEA πŸ’‘

Unfortunately, floats aren't good for handling large numbers. Once they get too far up there they'll start losing precision. Tragically, floats are all MPAndroidChart knows.

Assuming your big numbers are all in the same ballpark as each other (it looks like you're using dates so I would assume so), you can work around this. When you get your first value, store it somewhere, and subtract it from every entry value as you add them. So numbers like 16314195, 16315200, 16316191 are stored as 0, 1005, 1996, and then convert them to a float. Then in a ValueFormatter for your axis, take that stored value, convert it back to the proper type, and add the stored value back in to get the original value, without loss of precision.

Preview 🎞

β˜€ πŸŒ™
Light Dark

Simple Data, take timestamp as an example

Data Limit

  • The data is too large, remove the end 000
  • Change the timestamp to the first day (e.g. 06-12)
X: 06-12 Y: 1623521449000
X: 06-13 Y: 1623520427000
X: 06-14 Y: 1623510435000
X: 06-15 Y: 1623510725000
X: 06-16 Y: 1623509282000
X: 06-17 Y: 1623513979000
X: 06-18 Y: 1623519397000
X: 06-19 Y: 1623500522000

> Browse Code

Implement Rounded Chart & Range Chart βš—

Preview 🎞

β˜€ BarChart (Rounded) πŸŒ™ BarChart (Rounded)
Light Dark
β˜€ BarChart (Range) πŸŒ™ BarChart (Range)
Light Dark

> Browse Code

About

MPAndroidChart library content demonstration and implementation of big decimal charts, rounded charts and range charts

License:MIT License


Languages

Language:Kotlin 100.0%