Achartengine does not show value for single data

100 views Asked by At

I am researching about Achartengine for drawing simple line charts.
I got stuck on a single interesting thing.

I have already set:

renderer.setDisplayChartValues(true);
renderer.setChartValuesTextSize(30f);

However, it only shows the value when my data has two or more values.
I captured the screen for you to easily understand my point.

enter image description here enter image description here

Does anyone know why?
Please help me.

1

There are 1 answers

1
Phantômaxx On BEST ANSWER

Ihad the same issue. I solved it by editing the aChartEngine source code.

In particular, in:

XYChart.java - drawChartValuesText()

I changed this

protected void drawChartValuesText(Canvas canvas, XYSeries series, SimpleSeriesRenderer renderer,
    Paint paint, List<Float> points, int seriesIndex, int startIndex)
{
    if (points.size() > 1) { // there are more than one point

to this

protected void drawChartValuesText(Canvas canvas, XYSeries series, SimpleSeriesRenderer renderer,
    Paint paint, List<Float> points, int seriesIndex, int startIndex)
{
    if (points.size() > 2) { // there are more than one point

So, 1 has to become 2, and it magically works.
Credits and respects to Matthieu Holz for the precious hint