2017-04-25 119 views
0

我正在使用MPAndroidChartAndroid中的MPAndroidChart條形圖問題

  • 如何將BarEntryLabels更改爲Horizo​​ntalBarChart中的左側?v如何從底部刪除項目? enter image description here
  • 如何禁用縮放?
  • 雖然點擊特定的欄顏色正在改變如何禁用它?
  • IN BarChart在那裏我已經添加了6個月,但EntryLabels沒有正確對齊到相應的欄。 enter image description here

代碼:

BARENTRY = new ArrayList<>(); 
    BarEntryLabels = new ArrayList<String>(); 
    AddValuesToBARENTRY(); 
    AddValuesToBarEntryLabels(); 
    Bardataset = new BarDataSet(BARENTRY, "Projects"); 
    BARDATA = new BarData(BarEntryLabels, Bardataset); 
    Bardataset.setColors(new int[]{Color.parseColor("#701112")}); 
    horizontalBarChart.setData(BARDATA); 
    horizontalBarChart.setDrawBarShadow(false); 
    horizontalBarChart.setDrawValueAboveBar(true); 
    // if more than 60 entries are displayed in the chart, no values will be 
    // drawn 
    horizontalBarChart.setMaxVisibleValueCount(60); 
    // scaling can now only be done on x- and y-axis separately 
    horizontalBarChart.setPinchZoom(false); 
    // draw shadows for each bar that show the maximum value 
    // mChart.setDrawBarShadow(true); 
    horizontalBarChart.setDrawGridBackground(false); 
    horizontalBarChart.setDescription(""); 
    Bardataset.setBarSpacePercent(10f); 


    barChart.setData(BARDATA); 
    barChart.setDrawBarShadow(false); 
    barChart.setDrawValueAboveBar(true); 
    // if more than 60 entries are displayed in the chart, no values will be 
    // drawn 
    barChart.setMaxVisibleValueCount(60); 
    // scaling can now only be done on x- and y-axis separately 
    barChart.setPinchZoom(false); 
    // draw shadows for each bar that show the maximum value 
    // mChart.setDrawBarShadow(true); 
    barChart.setDrawGridBackground(false); 
    barChart.setDescription(""); 
+0

能否請您分享您的屬性代碼,您已設置爲顯示請看看這 –

+0

。 –

回答

1

對於「項目」傳說的一部分試試這個

Legend legend = mBarChart.getLegend(); 
    legend.setEnabled(false); 

能夠進行觸摸禁用集setTouchEnabled(布爾啓用)您條形圖對象像這樣

mBarChart.setTouchEnabled(false); 

,如果你想顯示所有的標籤,你應該嘗試

axis.setLabelCount(...) 
    mBarChart.getXAxis().setValueFormatter(new IndexAxisValueFormatter(labels)); 

,並嘗試official documents

+0

謝謝lot.It工作對我來說這個圖 –

+0

嗨Somesh。我還有一個疑問,當我調用API並設置它的值時,圖形x和y值是錯誤的。我該如何實現? –

+0

圖X和Y值?軸的價值觀是什麼意思? –

0
BARENTRY1 = new ArrayList<>(); 
    BarEntryLabels1 = new ArrayList<String>(); 
    AddValuesToHorizontalBARENTRY(); 
    AddValuesToHorizontalBarEntryLabels(); 
    Bardataset = new BarDataSet(BARENTRY1, "Projects"); 
    BARDATA = new BarData(BarEntryLabels1, Bardataset); 
    Bardataset.setColors(new int[]{Color.parseColor("#701112")}); 
    horizontalBarChart.setData(BARDATA); 
    horizontalBarChart.setDrawBarShadow(false); 
    horizontalBarChart.setDrawValueAboveBar(true); 
    horizontalBarChart.setPinchZoom(false); 
    horizontalBarChart.setDrawGridBackground(false); 
    horizontalBarChart.setDescription(""); 
    Bardataset.setBarSpacePercent(10f); 
    Legend legend = horizontalBarChart.getLegend(); 
    legend.setEnabled(false); 
    horizontalBarChart.setTouchEnabled(false); 
    XAxis xAxis1 = horizontalBarChart.getXAxis(); 
    xAxis1.setPosition(XAxis.XAxisPosition.BOTTOM); 
    xAxis1.setTextSize(8); 
    xAxis1.setSpaceBetweenLabels(8); 
    xAxis1.setTextColor(Color.parseColor("#701112")); 
    xAxis1.setTypeface(tf); 
    YAxis leftAxis = barChart.getAxisLeft(); 
    leftAxis.setEnabled(false); 

做這樣的一隻以下問題將是修復。