我试图在每个栏上方显示标签,而不是在每个栏的顶部。假设我有五个小条,那么我想在每个小节的顶部放置标签。我试过这段代码
YAxis leftAxis = barChart.getAxisLeft();
leftAxis.setSpaceTop(15f); //Prevent 100% from overlapping
YAxis rightAxis = barChart.getAxisRight();
XAxis xAxis = barChart.getXAxis();
xAxis.setTextSize(15);
rightAxis.setEnabled(false);
leftAxis.setEnabled(false);
BarData data = new BarData(labels, dataset);
data.setValueTextSize(10);
data.setValueFormatter(new MyValueFormatter());
barChart.setBackgroundColor(Color.TRANSPARENT); //set whatever color you prefer
barChart.setDrawGridBackground(false);// this is a must
barChart.setData(data); // set the data and list of lables into chart
barChart.setDescription(""); // set the description
barChart.animateY(2500);
// barChart.setDrawValueAboveBar(false);
Legend l = barChart.getLegend();
l.setEnabled(false);