尝试在条形图的x轴上渲染String标签。只是没有出现。以下是代码段。除了没有出现的标签外,一切都很好。我试过设置下面但仍然没有。
xAxis.setDrawLabels(true);
...
entries.add(new BarEntry((float) e.getX(), ((float) e.getY()),labels));
}
BarDataSet set1;
if (mChart.getData() != null && mChart.getData().getDataSetCount() > 0) {
set1 = (BarDataSet) mChart.getData().getDataSetByIndex(0);
set1.setValues(entries);
mChart.getData().notifyDataChanged();
mChart.notifyDataSetChanged();
} else {
set1 = new BarDataSet(entries, "Engine Output");
ArrayList<Integer> colors = new ArrayList<Integer>();
for (int c : ColorTemplate.VORDIPLOM_COLORS)
colors.add(c);
for (int c : ColorTemplate.JOYFUL_COLORS)
colors.add(c);
for (int c : ColorTemplate.COLORFUL_COLORS)
colors.add(c);
for (int c : ColorTemplate.LIBERTY_COLORS)
colors.add(c);
for (int c : ColorTemplate.PASTEL_COLORS)
colors.add(c);
colors.add(ColorTemplate.getHoloBlue());
set1.setColors(colors);
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(dataSets);
data.setValueTextSize(50f);
data.setValueTextColor(Color.WHITE);
data.setValueTypeface(mTfLight);
data.setBarWidth(0.9f);
mChart.setData(data);
答案 0 :(得分:0)
所以,我最后回答了自己的问题。使用下面我能够获取要渲染的值。定位仍有一些问题,但至少它们正在出现。
mChart.getXAxis().setValueFormatter(new IndexAxisValueFormatter(labels));