我是Mp Android Chart和android的新手。我想绘制水平BarChart标签,但我无法做到。我想写出我在数据中输入的标签。我想在链接(Jun,May,Apr)中的图表中写下像标签一样的标签
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
System.out.println("Message");
// Inflate the layout for this fragment
myFragmentView = inflater.inflate(R.layout.fragment_stats, container, false);
mChart = (HorizontalBarChart) myFragmentView.findViewById(R.id.chart);
// mChart.setHighlightEnabled(false);
drawUI();
XAxis xl = mChart.getXAxis();
xl.setPosition(XAxis.XAxisPosition.BOTTOM);
xl.setDrawAxisLine(false);
xl.setDrawGridLines(false);
xl.setDrawLabels(true);
YAxis yl = mChart.getAxisLeft();
yl.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
yl.setDrawAxisLine(false);
yl.setDrawGridLines(false);
yl.setDrawLabels(True);
YAxis yr = mChart.getAxisRight();
yr.setDrawAxisLine(false);
yr.setDrawGridLines(false);
yr.setDrawLabels(false);
// yr.setInverted(true);
mChart.setFitBars(false);
mChart.animateY(2500);
return myFragmentView;
}
public void drawUI()
{
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
MainActivity activity = (MainActivity) getActivity();
Team LocalTeam = activity.GetTeam(1);
yVals1.add(new BarEntry(1 *2f, LocalTeam.getRedCard(),"Rojas"));
yVals1.add(new BarEntry(2 *2f, LocalTeam.getYellowCard(),"Amarillas"));
yVals1.add(new BarEntry(3 *2f, LocalTeam.getOffSide(),"Off Side"));
Incorrecto“)); yVals1.add(new BarEntry(10 * 2f,LocalTeam.getPass(),“pases”));
BarDataSet set1 ;
set1= new BarDataSet(yVals1,"Local");
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(dataSets);
mChart.setData(data);
mChart.getXAxis().setCenterAxisLabels(false);
mChart.invalidate();
}
}`
答案 0 :(得分:0)
opTimestamp