My application requires graph library and I am using achartengine graph library. My app requires graph to be only 50% of the screen and other part is used to display some other information.
Is it possible have xml resource file for achartengine's graph APIs and how to do it?
I tried to find an example but didn't find it. Is it supported or not?
This is a FAQ for AChartEngine. The AChartEngine demo application is available for download here: AChartEngine demo
In the demo source code you can see an example on how to embed a chart into an existing view.
Basically, in the activity descriptor .xml file, we have defined the following as a placeholder for the chart. Of course, other user interface components go together with this layout:
ChartDemo/layout/xy_chart.xml near Line 27
We define a local variable:
ChartDemo/src/org.achartengine.chartdemo.demo.chart/XYChartBuilder.java near Line 68
We instantiate it on the onResume() method of the activity:
ChartDemo/src/org.achartengine.chartdemo.demo.chart/XYChartBuilder.java near Line 163
Whenever new data is added (when the user presses the "Add" button in our case, a new point is added in the current series and:
ChartDemo/src/org.achartengine.chartdemo.demo.chart/XYChartBuilder.java near Line 147
So here is a self sufficient place to find all about AChartEngine. Which includes link to download,
Which are latest for now(while posting this answer). Now follow these easy steps in order to add new chart file:
Now right click on file and add it to build path, like in image
Now as define in previous answers, add following code to your class:
To get detail about any class of AChartEngineAPI, download achartengine-1.1.0-javadocs.zip and open by clicking in index.html
achartengine-1.1.0-demo-source.zip will be helpful during further deepar development where you can take reference for all charts
You can write your xml like this...
and the java code snippet is
There are two sets of APIs in
ChartFactory
. For eg.getLineChartView()
andgetLineChartIntent()
. So former is used to get a graphical view which can be added to customized layout and later is used to get the intent. In above example Dan has usedgetLineChartView()
API which returns aGraphicalView
.