PhilJay / MPAndroidChart

A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.
Other
37.56k stars 9.01k forks source link

CombinedChart CandleStick real body not showing #4282

Open rayarteagas opened 5 years ago

rayarteagas commented 5 years ago

Summary With a CombinedChart, The CandleSticks real bodies are not displaying. Only the shadows are rendered.

Expected Behavior I expect the real bodies to be rendered with the declared decreasing/neutral/increasing color.

**Device

Additional Context the data is coming from: https://min-api.cryptocompare.com/data/histoday?fsym=BTC&tsym=USD&aggregate=1&G&limit=10&e=CCCAGG https://gist.github.com/rayarteagas/fa9242ac9a31db20782b2802d8e5010e

almic commented 5 years ago

I'm not sure how that's happened, and I would test it myself, but right now I can't exactly do that. I'm adding to the support list and hopefully you get an answer.

rayarteagas commented 5 years ago

Wen the X values are very long (like in a timestamp for example), the real body shrinks horizontally and, at some point, hides no matter how much you zoom. The solution I'm using right now is to scale the X values (for example dividing by 10000 or so), and then reverting the scaled values to the original ones in the value formatters and marker views. This does not happens with the shadows, so I think is a math problem.

almic commented 5 years ago

I don't believe that having long labels should be causing the boxes to shrink at all, so that is definitely a problem with the library! I wonder if this happens to bar charts or is a unique problem to the candlestick chart.

rayarteagas commented 5 years ago

I'm using a CombinedChart with lines and candlesticks, but the problem is also on CandleScrickChart. I'll take some time to simplify the code posted, so the issue may be more clear.

ArcherEmiya05 commented 5 months ago

I know this is old but @rayarteagas is correct, if your Entry.x value which is the timestamp for this library's chart is too long or too large e.g. 1705795200000 this can shrink the body specially if there is a huge data entries. The temporary fix is to reduce that value by dividing it with e.g. 86400000f which is equivalent to one day milliseconds. Just make sure to multiply it back with same value 86400000f when showing it with MarkerView.refreshContent. I suspect this is related to precision issue of using float which the library seems used in Entry. There are also a lot of file bug in this repo relating to that issue, it should use Double or BigDecimal instead since charts are usually used in financial.