2017-04-25 117 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); 

做这样的一只以下问题将是修复。