MPAndroidChart
MPAndroidChart copied to clipboard
HorizontalBarChart values not showing (v3.0.1)
The test code:
mChart = (HorizontalBarChart) findViewById(R.id.chart);
mChart.getDescription().setEnabled(false);
mChart.setMaxVisibleValueCount(30);
mChart.setPinchZoom(true);
mChart.setDoubleTapToZoomEnabled(false);
mChart.setDrawGridBackground(false);
mChart.setHighlightPerTapEnabled(false);
mChart.getAxisLeft().setEnabled(false);
mChart.getAxisRight().setEnabled(false);
mChart.setFitBars(true);
mChart.animateY(1000);
final ArrayList<BarEntry> values = new ArrayList<>();
values.add(new BarEntry(0, 1, "1"));
values.add(new BarEntry(1, 4, "2"));
values.add(new BarEntry(2, 7, "3"));
values.add(new BarEntry(3, 7, "4"));
values.add(new BarEntry(4, 7, "5"));
values.add(new BarEntry(5, 4, "6"));
values.add(new BarEntry(6, 3, "7"));
values.add(new BarEntry(7, 20, "8"));
BarDataSet dataSet = new BarDataSet(values, "Test");
ArrayList<Integer> colors = new ArrayList<>();
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());
dataSet.setColors(colors);
dataSet.setDrawValues(true);
dataSet.setValueTextSize(14f);
dataSet.setValueTextColor(ContextCompat.getColor(this, R.color.primary_text_color));
dataSet.setHighlightEnabled(false);
dataSet.setValueFormatter(new IValueFormatter() {
@Override
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
return (int) value + "";
}
});
ArrayList<IBarDataSet> dataSets = new ArrayList<>();
dataSets.add(dataSet);
BarData barData = new BarData(dataSets);
XAxis xl = mChart.getXAxis();
xl.setTextColor(ContextCompat.getColor(this, R.color.primary_text_color));
xl.setTextSize(14f);
xl.setLabelCount(values.size());
xl.setDrawLabels(true);
xl.setPosition(XAxis.XAxisPosition.BOTTOM);
xl.setDrawAxisLine(true);
xl.setDrawGridLines(false);
xl.setGranularity(1f);
xl.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return values.get((int) value).getData().toString();
}
});
mChart.setData(barData);
mChart.invalidate();
when I change the values.add(new BarEntry(7, 20, "8")); to values.add(new BarEntry(7, 6, "8")); the values is invisible:
i have the problem , please help me if you have any solution
+1
Is this fixed?. i am facing same issue
+1
+1