0

I am new to android , I used GraphView library to draw a BarGraph it looks ok but the problem is that the horizontal labels does not matches with the bar and the width of bars is too small as compared to labels. Yes i have used the setHorizontalLabels(10) methods as i need the horizontal vales as Integers But still problem is the same Please help me

Thanks in Advance

Irshad A Khan
  • 141
  • 1
  • 11

1 Answers1

1

I solved it on my own Its now working according to my need.

the solution is to customize the library project

1)download zip GraphView-Master from the below [Link-] [https://github.com/jjoe64/GraphView/archive/master.zip]1

2)Just modify the things as said below There are quick fixes:

 // In BarGraphView.java

    //float colwidth = (graphwidth - (2 * border)) / values.length;
    float colwidth = graphwidth / values.length;

    // In GraphView.java

    // horizontal labels + lines
    int hors = horlabels.length;
    for (int i = 0; i <= horlabels.length; i++) {
    paint.setColor(Color.BLACK);
    float x = ((graphwidth / hors) * i) + horstart;
    canvas.drawLine(x, height - border, x, border, paint);
    paint.setTextAlign(Align.CENTER);
    if (i < horlabels.length) {
    paint.setColor(Color.BLACK);
    canvas.drawText(horlabels[i], x + (graphwidth / hors) / 2, height - 4, paint);
    }
    }

3) Use the new generated lib in your project Please do not forget to remove the previously used .jar else it will give you Dalvik error

4)The same issue is been discussed here on this link

Hope this would be helpful

Irshad A Khan
  • 141
  • 1
  • 11