Search code examples
javaandroidgraphandroid-graphview

Graph Without Rounded End Caps


I did managed to draw the graph that i wanted but some how I'm getting rounded end caps at the end of the graph lines.

I wrote my code using the GraphView lib for a series of data using this :

GraphViewSeries line1Series = new GraphViewSeries("LINE ONE", new GraphViewSeriesStyle(Color.BLUE, 100), exampleSeries2); 

How can I change the end cap from rounded to a straight end cap like this one:
https://cloud.githubusercontent.com/assets/7545176/4953542/227d9380-6682-11e4-88fd-4ad1f4a5ac14.png


Solution

  • The easiest thing is probably to clone the project from github and alter the onDraw() method in GraphView.java (line 154 as of now) from:

    paint.setStrokeCap(Paint.Cap.ROUND);
    

    to

    paint.setStrokeCap(Paint.Cap.BUTT);