AchartEngine provides an easy way of drawing both line and
bar graphs in android platform. In here I describe drawing line graphs.
If it is a maven based project, simply you have to build the project, will be downloaded the jar file to your project.
In above java class, you can refer easily to understand
AchartEngine line graphs implementation. In here, used two pre-defined arrays
as X and Y.
You have to add an Activity called Graphical Activity in AchartEngine to the Manifest as well.
That’s what you all have to do then you can call the
DrawGraph intent.
If you follow these steps properly, you will see the graph
and here is the screenshot for above graph.
You can get this full code from here. It also contains a
code to draw a dynamic line graph. You can also refer on that too. Hope you enjoy this.
First need to add AchartEngine jar file to your android
project. You can download it from here.
If it is maven based
project you can add the dependency and all details are in here.
After you download the jar, add it into the libs folder and
right click on the jar and Select Build the path as Figure 1 follows.
Figure 1 - Configure Build Path |
If it is a maven based project, simply you have to build the project, will be downloaded the jar file to your project.
Figure 2 - Graph class |
Then add those values to TimeSeries which is names as “Line1”
Then you need to add this TimeSeries to XYMultipleSeriesDataset, then that dataset should add to the XYSeriesRender.
Then you need to add this TimeSeries to XYMultipleSeriesDataset, then that dataset should add to the XYSeriesRender.
That renderer is responsible to draw the graph. So it contains features to
customize the graph like setColor, setPointStyle etc.
So you need add that renderer to XYMultipleSeriesRenderer.
Like that you can add so many graphs(renderers) to XYMultipleSeriesRenderer. It
defines a graph uniquely.
So it contains several features to customize each graph
uniquely. It has setChartTitle, setYTitle, setXTitle etc.
Then you need to add XYMultipleSeriesRenderer to the Intent
through ChartFactory which is a pre-defined class in AchartEngine.
You have to add an Activity called Graphical Activity in AchartEngine to the Manifest as well.
Figure 3 - Android Manifest |
Figure 4 - Start the activity |
Figure 5 - Screen shot of the graph |
Comments
Post a Comment