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.