我正在使用MPAndroidChart。
代码:
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 :(得分:1)
对于&#34;项目&#34; 图例部分,请尝试此
Legend legend = mBarChart.getLegend();
legend.setEnabled(false);
要在条形图对象上进行触摸禁用设置 setTouchEnabled(布尔启用) ,就像这样
mBarChart.setTouchEnabled(false);
如果您想显示所有标签,请尝试
axis.setLabelCount(...)
mBarChart.getXAxis().setValueFormatter(new IndexAxisValueFormatter(labels));
答案 1 :(得分: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);
这样做。以下问题将得到解决。