2017-11-14 1 views
0

mpandroid 차트 라이브러리를 사용하고 있습니다. 플로트 값을 선 그래프로 표시하고 싶지만 정상 값을 보여줍니다.Mpchart float 값이 배열리스트에 표시되지 않습니다

Screenshot.

내 코드 :

if (cursor != null) { 

      for (int h = 0; h < cursor.getCount(); h++) { 

       cursor.moveToNext(); 

       ans = cursor.getString(cursor.getColumnIndex("pnt_triiodothyronine")); 

       entry1.add(new Entry(cursor.getFloat(cursor.getColumnIndex("pnt_triiodothyronine")),h)); 
       entry2.add(new Entry(cursor.getFloat(cursor.getColumnIndex("pnt_thyroxine")),h)); 
       entry3.add(new Entry(cursor.getFloat(cursor.getColumnIndex("pnt_tsh")),h)); 
       entry4.add(new Entry(cursor.getFloat(cursor.getColumnIndex("pnt_weight")),h)); 
       entry5.add((cursor.getString(cursor.getColumnIndex("date")))); 

       ansText.setText(ans); 
      } 

      cursor.close(); 

     } 

lDataSet1 = new LineDataSet(entry1, "T3"); 
     //lDataSet1.setDrawFilled(true); 
     lDataSet1.setColors(new int[]{getResources().getColor(R.color.purple)}); //resolved color 
     lDataSet1.setCircleColor(Color.parseColor("#ffffff")); 
     lDataSet1.setLineWidth(1.5f); 
     lDataSet1.setCircleColorHole(Color.parseColor("#9c27b0")); 
     lDataSet1.setHighLightColor(Color.rgb(190, 190, 190)); 
     lDataSet1.setDrawCubic(true); 
     //lDataSet1.setDrawFilled(true); 
     lines.add(lDataSet1); 

답변

1

보기 위키에서이 같이

ValueFormatter에, 당신의 자신의 ValueFormatter를 작성하고 원하는 형식을 설정합니다.

// usage on whole data object 
lineData.setValueFormatter(new MyValueFormatter()); 

// usage on individual dataset object 
lineDataSet.setValueFormatter(new MyValueFormatter()); 
:

public class MyValueFormatter implements IValueFormatter { 

    private DecimalFormat mFormat; 

    public MyValueFormatter() { 
     mFormat = new DecimalFormat("###,###,##0.0"); // use one decimal 
    } 

    @Override 
    public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) { 
     // write your logic here 
     return mFormat.format(value) + " $"; // e.g. append a dollar-sign 
    } 
} 

그런 다음 ChartData 또는 데이터 집합 객체에 포맷터 적용

관련 문제