MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

Float to Double on entry

Open luizarantes opened this issue 8 years ago • 9 comments

Why you are using float on entry? Maybe you can use Double instead of float.

luizarantes avatar Feb 11 '17 03:02 luizarantes

I am stuck now, i need to display big number in Pie Chart. Because of float entry I can't.. Any solutions?

Specko93 avatar Feb 13 '17 18:02 Specko93

+1

mohitagrawal avatar Mar 01 '17 22:03 mohitagrawal

+2

fukemy avatar Mar 03 '17 01:03 fukemy

+1

ratikanta131 avatar Mar 07 '17 12:03 ratikanta131

Just use BigDecimal, then use .floatValue() on that and you will be able to use entry.

Specko93 avatar Mar 07 '17 17:03 Specko93

Still didn't work @Specko93

double d = detail.getValue();//162444145 BigDecimal bigDecimal = new BigDecimal(d); Log.i("hello", bigDecimal + "");//162444145 Log.i("hello", bigDecimal.floatValue() + "");//1.6244414E8 entry = new Entry(bigDecimal.floatValue(), i);//162444144 //showing on the line chart value

ratikanta131 avatar Mar 08 '17 07:03 ratikanta131

@ratikanta-sdrc Strange.. It worked for me. Let me try it when I get home. I will post you my code.

Specko93 avatar Mar 08 '17 11:03 Specko93

i send a list(Double) and new barEntry(float x, float y, data) ,i order data is 0,1,2,3...then getformatter() reture list.get(entry.getdata),i solved by this way for (int i = 0, n = yAxisValue.size(); i < n; ++i) { entries.add(new BarEntry(i, yAxisValue.get(i),i)); }

data.setValueFormatter(new IValueFormatter() { @Override public String getFormattedValue(float value, Entry entry, int i, ViewPortHandler viewPortHandler) { return String.valueOf(list.get(entry.getData())); } });

sun1594732 avatar Nov 06 '17 08:11 sun1594732

This is indeed an issue as Float tends to lose precision. Anyone who successfully forked this library and improve the Entry?

ArcherEmiya05 avatar Apr 23 '24 19:04 ArcherEmiya05