Charts icon indicating copy to clipboard operation
Charts copied to clipboard

Candle stick chart not displaying when timestamp used for XAxis.

Open artuan opened this issue 5 years ago • 7 comments

Hi,

I want to draw a Candle Stick Chart.

The candles are NOT displaying correctly if I use timestamp data for XAxis. The candles are displaying correctly if I use iteration index for XAxis.

  • I have a line chart that is displaying like it should for the same kind of data(timestamp, X value). But when I use those data on candles chart it is not working.

CandleStickChartNotWorking.txt displaying error

Charts (3.2.2) Swift 4.0 Xcode 10.2.1

Thank you

artuan avatar May 13 '19 15:05 artuan

Same problem also for CombinedChartView with BarChartData

MarcoImoo avatar Jul 16 '19 11:07 MarcoImoo

Has anyone been able to solve this yet? I've just run into it 6 months later..

mikecsh avatar Jan 25 '20 16:01 mikecsh

I had recently the same issue. Turns out that candle bars are simply just too narrow to be visible when time interval is used for X values. As a workaround I have time stamps stored in an array and I did assign index values from that array as X values instead. Other option may be some kind of multiplier but that may not work if time interval diff is small.

J-Fiser avatar Jan 20 '21 07:01 J-Fiser

same problem here.. does anybody has any workaround instead of giving indexes of values ?

miletliyusuf avatar Jul 12 '21 20:07 miletliyusuf

The issue is still present, any workaround?

SaladDays831 avatar Jan 06 '23 14:01 SaladDays831

for me too. candlestick chart not displaying when timestamp with timezone used for x axis.

Gayathrigopi98 avatar Nov 07 '23 05:11 Gayathrigopi98

I had come up with same issue and found workaround. In my case I was converting Instant to Epochseconds so the converted float value is in scientific notation. I assume which is causing the problem for you guys as well. here is my workaround

  // divide by big number which will not return in scientific notation
  new CandleEntry((float) candleStick.getTimeStamp().getEpochSecond() /100000
  
 And add value formatter for Xaxis 
 candleStickChart.getXAxis().setValueFormatter(new DateValueFormatter());
 
 In DateValueFormatter multiply with value with the above big number in my case  100000 , this will ensure not showing wrong dates in UI 
    
    
    @Override
    public String getFormattedValue(float value) {
       Date date = getDateValue(value * 100000);

venky-yv avatar Dec 20 '23 14:12 venky-yv