Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Draw graph in Android?

Tags:

android

graph

I want to draw graph like shown in the attached image.

I already tried by aChartEngine but it's not working successfully.

enter image description here

like image 672
Girish Patel Avatar asked Sep 22 '12 17:09

Girish Patel


1 Answers

You could create a SurfaceView, in which you can draw to a Canvas in the onDraw() method. To draw your graph, you can use the Path class, and it's moveTo() and lineTo() methods. To change the appearance of the lines, use the Paint class. Then use the Canvases drawPath() method, which takes a Path, and a Paint object. I think it's a bit easier to start with, than OpenGl.

  • SurfaceView
  • Canvas
  • Path
  • Paint

Some tutorial

Update: @Shakti Malik found a pretty good looking library, which looks easy to use: MPAndroidChart

like image 137
Balázs Édes Avatar answered Nov 15 '22 14:11

Balázs Édes