2016-10-18 2 views
1

BarChart 및 레이블에 문제가 있습니다. 레이블 개수가 올바르지 않습니다. 직접 값을 입력하더라도 :MPAndroid BarChart 레이블 개수 및 ValueFormatter가 제대로 작동하지 않습니다.

xAxis.setLabelCount(5,true); 

하지만 내가 얻는 것은 4 개의 라벨입니다. 6을 넣으면 5가됩니다. 버그가있는 것 같습니다.

또한 레이블의 마지막 항목 (단순한 ValueFormatter를 사용하고 있습니다)이 표시되지 않습니다. 라벨의 수는 바의 수와 동일하면 내가 각 막대의

xAxis.setGranularity(1f); 
xAxis.setGranularityEnabled(true); 

과 X 값이 0, 1, 2, 3, 4이다 사용하더라도 두 번 첫 번째를 반복합니다.

아무도 도와 줄 수 있습니까?

업데이트 이미지


여기 HERE

내가 항목의 목록을 이용하고 있고 레이블이 항목의 데이터입니다을 봐.

항목 목록의 크기가 4이고 첫 번째 항목이 두 번 반복되는 동안 레이블은 3 개뿐입니다.

내가 항목에 대한 있는지 확인하고이 값 :

 Log.d(TAG, "Size of categories : " + categoriesEntries.size()); 

     for (BarEntry e : 
       categoriesEntries) { 
      Log.d(TAG, e.getX() + " " + e.getData().toString()); 
     } 

로그 캣 출력 :

10-21 15:16:49.569 31194-31194/com.shamdroid.myfinancialassistant D/Statistics Activity: Size of categories : 4 
10-21 15:16:49.569 31194-31194/com.shamdroid.myfinancialassistant D/Statistics Activity: 0.0 Study 
10-21 15:16:49.569 31194-31194/com.shamdroid.myfinancialassistant D/Statistics Activity: 1.0 Home 
10-21 15:16:49.569 31194-31194/com.shamdroid.myfinancialassistant D/Statistics Activity: 2.0 Car 
10-21 15:16:49.569 31194-31194/com.shamdroid.myfinancialassistant D/Statistics Activity: 3.0 Schools 

ValueFormatter :

같은 문제가 다른 사람에 대한
xAxis.setValueFormatter(new AxisValueFormatter() { 
      @Override 
      public String getFormattedValue(float value, AxisBase axis) { 

       int i = (int) value; 
       Log.d(TAG, value + " " + i); 

       return String.valueOf(categoriesEntries.get(i).getData()); 

      } 

      @Override 
      public int getDecimalDigits() { 
       return 0; 
      } 
     }); 
+0

정확하게 문제가 될 수있는 사례를 보여 줄 수 있습니까? –

+0

@ error404 답장을 보내 주셔서 감사합니다. 더 자세한 내용으로 질문을 업데이트했습니다. –

답변

0

, setLabelCount()를 제거하여 문제를 해결했습니다.

관련 문제