robinhood / spark

A simple Android sparkline chart view.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

can i take double DataType in y axis

suveshagnihotri opened this issue · comments

Can i take double datatype in the Y axis . because my value in y axis is more than 8 digits .
My Value (12845678.46)
Right now i am getting (1.2645678E7) when i am scrubbing the SparkView.

When you scrub, you should get your original data type back. Just make sure your SparkAdapter's getItem() returns whatever data type you're interested in.

My Adapter code is :
public class MyAdapter extends SparkAdapter {
private Double[] yData;

    public MyAdapter(Double[] yData) {
        this.yData = yData;
    }

    @Override
    public int getCount() {
        return yData.length;
    }

    @Override
    public Object getItem(int index) {
        return yData[index];
    }

    @Override
    public float getY(int index) {
        return yData[index].floatValue();
    }
}

Your adapter looks fine to me. Are you certain your debugger/the method you're using to log isn't doing something funny? A small sample project that reproduces the problem would be helpful.

I tweaked Spark's sample app and was able to confirm onScrubbed() when used with an adapter backed by double values doesn't result in a loss of precision.

Hi @suveshagnihotri, did you get your issue figured out? I also tried out doubles in the sample app, and everything works fine for me.

If you're still having the issue, please reopen this and let us know where you're seeing the 1.2645678E7 value.