Introduction and use of achartengine (drawing Toolkit provided by Google for android)

Source: Internet
Author: User

Introduction and use of achartengine (drawing Toolkit provided by Google for android)
AChartEngine (ACE) is an open-source drawing Toolkit provided by Google for Android. It integrates multiple graphics Functions: line chart, scatter chart, bubble chart, column chart, pie chart, and meter chart. : Http://download.csdn.net/detail/u013647453/8511203 (jar package and development documentation including 1.1.0) Official Website: http://code.google.com/p/achartengine (need to flip the wall download)
The following is a simple AndroidStudio1.1 project core code I developed: 1. After creating a project, put the download achartengine-1.1.0.jar into the libs folder, right-click Add as library. You can use this toolkit.
2. You need to add a node to the node AndroidManifest. xml, such as: (because, calling this package is achieved by initiating an org. achartengine. GraphicalActivity in a new package)

3. Several Functions in the Code Section: mainly set rendering effects such as data and graphic colors

// Set the axis name and maximum, minimum scale value, and Title name private void setChart (XYMultipleSeriesRenderer renderer) {renderer. setChartTitle ("Algorithm"); renderer. setXTitle ("X Axis"); renderer. setYTitle ("Y Axis"); renderer. setXAxisMin (0); renderer. setXAxisMax (30); renderer. setYAxisMin (0); renderer. setYAxisMax (200);} // set the graphic rendering attribute private inline getBarRenderer () {inline renderer = new inline (); SimpleSeriesRenderer simpleSeriesRenderer = new SimpleSeriesRenderer (); simpleSeriesRenderer. setColor (Color. RED); renderer. addSeriesRenderer (simpleSeriesRenderer); simpleSeriesRenderer = new SimpleSeriesRenderer (); simpleSeriesRenderer. setColor (Color. GRAY); renderer. addSeriesRenderer (simpleSeriesRenderer); setChart (renderer); return renderer;} // get the private dataset getBarDataset () {dataset = new XYMultipleSeriesDataset (); Random random = new Random (); for (int I = 0; I <2; I ++) {CategorySeries = new CategorySeries ("Algorithm" + (I + 1); for (int k = 0; k <10; k ++) {series. add (50 + random. nextInt () % 150);} dataset. addSeries (series. toXYSeries ();} return dataset ;}
Call part:
XYMultipleSeriesRenderer renderer = getBarRenderer();        Intent intents = ChartFactory.getBarChartIntent(this, getBarDataset(), renderer, BarChart.Type.DEFAULT);        startActivity(intents);
The running effect is as follows:

For more instructions, see the official development documentation in the downloaded file.

Related Article

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.