Android Development Chart Achartengine pie chart

Source: Internet
Author: User
<span id="Label3"></p><p><p>First step: get a pie chart object from the factory</p></p><p><p>Graphicalview graphicalview=chartfactory.getpiechartview (getbasecontext (), dataset, renderer);//pie Chart<br>Step two: Set DataSet data</p></p><pre class="java"><pre class="java">double[] values={412.0,542.0,486.0,900.1}; Categoryseries dataset=buildcategorydataset ("test Pie chart", values);</pre></pre><p><p><br></p></p><pre class="java"><pre class="java">Protected categoryseries buildcategorydataset (String title, double[] values) {categoryseries series = new Category        Series (title);        Series.add ("poor", values[0]);        Series.add ("substandard", values[1]);        Series.add ("standards", values[2]);        Series.add ("excellent", values[3]);      Return series; }</pre></pre><p><p>Step three: Set Rendering parameters</p></p><pre class="java"><pre class="java">int[] colors={color.blue,color.green,color.magenta,color.red}; Defaultrenderer Renderer=buildcategoryrenderer (colors);</pre></pre><pre class="java">Protected defaultrenderer buildcategoryrenderer (int[] colors)  {         defaultrenderer renderer = new defaultrenderer ();                renderer.setlegendtextsize (20); /set the text size of the       //renderer.setzoombuttonsvisible in the lower left-hand corner (true);//set display Zoom-out button            renderer.setzoomenabled (false);//setting does not allow zooming in and out .             renderer.setcharttitletextsize (30);//set The text size of the chart title           renderer.setcharttitle ("statistical Results");//set The title of the chart     The default is centered on the top of the display           renderer.setlabelstextsize (20);// Font size of tagged text on pie chart           //renderer.setlabelscolor (Color.WHITE) ;//color of tagged text on pie chart           renderer.setpanenabled (false);//set Whether you can pan            //renderer.setdisplayvalues (true);//whether The value is displayed            renderer.setclickenabled (true);//settings can be clicked          renderer.setmargins (new int[] { 20, 30, 15,0 });         //margins - an array containing the margin  size values, in this order: top, left, bottom, right         for  (int color : colors)  {           simpleseriesrenderer r = new simpleseriesrenderer ();           r.setcolor (color);           reNderer.addseriesrenderer (r);        }         return renderer;      }</pre><p><p>Fourth step: put the Graphicalview object in the specified layout</p></p><p><p><span style="width:auto;float:none;height:auto;"><span style="width:auto;float:none;height:auto;color:#0000ff;font-size:12px;">layout</span></span>= (linearlayout) Findviewbyid (r.id.linearlayout);<br>Layout.removeallviews ();<br>Layout.setbackgroundcolor (color.black);<br>Layout.addview (graphicalview, New Layoutparams (layoutparams.match_parent,layoutparams.match_parent</p></p><p><p></p></p><p><p>This article is from the "it software development materials" blog, Please be sure to keep this source http://491733638.blog.51cto.com/3913830/1663412</p></p><p><p>Android Development Chart Achartengine pie chart</p></p></span>

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.