2016-07-15 1 views
0

HorizontalBarChart를 사용하고 있습니다. 바의 내부 또는 중간에 Label (공급 업체의 이름)을 그립니다. BarDaset에는 setLabel이라는 것이 있지만 작동하지 않습니다.MPAndroidChart 바 안의 레이블

private BarDataSet createLineChart(String storeName, List<String> listofcompanies){ 

    ArrayList<BarEntry> entries= new ArrayList<BarEntry>(); 
    for (int j = 0; j < listofcompanies.size(); j++) { 
     entries.add(new BarEntry(Float.parseFloat(listofcompanies.get(j)),j)); 

    } 
    Random rd = new Random(); 
    setComp1 = new BarDataSet(entries,storeName); 
    setComp1.setColor(Color.argb(255,rd.nextInt(256),rd.nextInt(256),rd.nextInt(256))); 
      setComp1.setDrawValues(true); 
    setComp1.setLabel(storeName); 
    setComp1.setHighlightEnabled(true); 
    setComp1.setDrawValues(true); 
    // LineData data =new LineData(labels,dataset); 
    return setComp1; 
} 

답변

2

시도가 사용하기 :

chart.getXAxis().setPosition(XAxisPosition.BOTTOM_INSIDE); 

또는

chart.getXAxis().setPosition(XAxisPosition.TOP_INSIDE); 

이 문서가 문제를 해결하는 것입니다 다음은 내 코드입니다.

관련 문제