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
|