Achartengine Android Line chart Column chart and other sharp weapon

Source: Internet
Author: User

Http://www.eoeandroid.com/thread-548233-1-6.html

Recently, the company project to use the line chart, the status type of the icon to use the line chart, column chart, and can be dynamically displayed, in the Internet to find a lot of demo, basically is to write dead data, the following first let us see Achartengine Introduction

Achartengine Run an example diagram: Each diagram requires a dataset (dataset) and a renderer set (Renderer);

--Data set: It's made up of a lot of data,

--renderer: Also made up of different sub-renderers,

--Get activity or component: The Chart factory (chartfactory) can generate graphicalview with graphs or graphicalactivity by calling datasets (datasets) and renderer collections (Renderer) ;


/

Then the analysis is completed, in fact, the main use of two major categories, one is the data set, one is the renderer

Achartengine is a library of charts for Android apps. It currently supports the table type:
Line chart
Area chart
Scatter chart
Time Chart
Bar chart
Pie chart
Bubble chart
Doughnut chart
Range (high to low) bar chart
Dial Graph/Table pressure
Merge (rows, rows, scatter charts, bars, bar ranges, any combination of bubbles) figure
Three-dimensional line chart

It is not practical to apply activity to the project, which causes the UI to be slow, and we can render it to the component by getting the component, the code is as follows:

How do I embed a line chart in a position on the interface?
You can use many of the Getxxxxview methods in the Chartfactory class to return a Graphicalview with a line chart, and then pass the position View.addview (Graphicalview) Way to add a line chart to the control you specified.

How do you do this if you have text in the x-axis of your project? Check it out. Api,api as follows

Addxtextlabel
public void Addxtextlabel (double x, java.lang.String text)
Adds a new text label for the specified X axis value.
Parameters:
X-the X Axis Value
Text-the text Label

(Check the API at work is a good habit, English is not good also have to force themselves, to read English documents)
Know how to use, OK, let's experiment First, mrenderer.setxlabels (0);
Mrenderer.addxtextlabel (1, "Guomao");
Mrenderer.addxtextlabel (2, "Computer");
Mrenderer.addxtextlabel (3, "Music");
OK, let's run a bit ....
Success
Because the project requirements are from the server to obtain coordinate values, the client to do display, according to the information given by the server, to determine whether it is a line chart, or a pie chart display
Now there are two very important data, one is the coordinate value, such as the line chart: X-axis, y-coordinate, and the x-axis of the text display

Later will write a tool class, used to get coordinate values from the server, and then converted to the required array, the landlord will be summarized in time to update the hope that you give support, if there is a need to modify the code in the place or everyone has a better idea, welcome to put forward
This topic was reviewed by Philippines 1010 on 2014-10-11 13:58 by <ignore_js_op>

Study on the pie chart of line chart Demo.zip

2.78 MB, download number of times: 26

Achartengine Android Line chart Column chart and other sharp weapon

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.