Draw an arc comparison chart and draw an arc

Source: Internet
Author: User

Draw an arc comparison chart and draw an arc

The arc comparison chart was first seen in ExcelPro's chart blog. At that time, I thought it was quite interesting that the figure could be put like this. Today I suddenly found this figure in <Excel can be used like this> edited by Chen,

It took a moment to add it to my open-source chart library XCL-Charts.

First, let's look at an example in the Demo:

The effect is quite self-satisfied. There is not much to say about the graph itself. Just paste the implementation code of calling the chart library.

/*** Copyright 2014 XCL-Charts *** Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file before t in compliance with the License. * You may be obtain a copy of the License at ** http://www.apache.org/licenses/LICENSE-2.0 ** Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "as is" BASIS, * without warranties or conditions of any kind, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ** @ Project XCL-Charts * @ Description Android chart base class library * @ author XiongChuanLiang <br/> (xcl_168@aliyun.com) * @ license http://www.apache.org/licenses/ Apache v2 License * @ version 1.5 */package com. demo. xclcharts. view; import java. util. arrayList; import java. util. using list; import java. util. list; import org. xclcharts. chart. arcLineChart; import org. xclcharts. chart. arcLineData; import org. xclcharts. renderer. XChart; import org. xclcharts. renderer. XEnum; import android. content. context; import android. graphics. canvas; import android. graphics. color; import android. graphics. paint; import android. graphics. paint. align; import android. util. attributeSet; import android. util. log;/*** @ ClassName ArcLineChart01View * @ Description Example of an arc comparison graph * @ author XiongChuanLiang <br/> (xcl_168@aliyun.com) */public class ArcLineChart01View extends TouchView {private String TAG = "ArcLineChart01View"; private ArcLineChart chart = new ArcLineChart (); private region list <ArcLineData> chartData = new region list <ArcLineData> (); public ArcLineChart01View (Context context) {super (context); // TODO Auto-generated constructor stubinitView ();} public ArcLineChart01View (Context context, AttributeSet attrs) {super (context, Context, attrs); initView ();} public ArcLineChart01View (Context context, AttributeSet attrs, int defStyle) {super (context, attrs, defStyle); initView ();} private void initView () {chartDataSet (); chartRender () ;}@ Override protected void onSizeChanged (int w, int h, int oldw, int oldh) {super. onSizeChanged (w, h, oldw, oldh); // chart size range chart. setChartRange (w, h);} private void chartRender () {try {// set the default indent px value in the drawing area. int [] ltrb = getpiedefadefaspadding (); chart. setPadding (ltrb [0], ltrb [1], ltrb [2], ltrb [3]); // background chart. setApplyBackgroundColor (true); chart. setBackgroundColor (Color. WHITE); // border chart. getBorder (). getLinePaint (). setColor (Color. rgb (83,178, 50); chart. showRoundBorder (); // Title chart. setTitle ("arc comparison chart"); chart. addSubtitle ("(XCL-Charts Demo)"); chart. setTitleVerticalAlign (XEnum. verticalAlign. BOTTOM); // display the legend chart. getPlotLegend (). showLegend (); // bind the data source chart. setDataSource (chartData); // tag offset chart. setLabelOffsetX (30f); // proportion of the inner ring radius // chart. setInnerRadius (0.6f); // set the addAttrInfo ();} catch (Exception e) {// TODO Auto-generated catch blockLog. e (TAG, e. toString () ;}} private void chartDataSet () {// set the chart data source chartData. add (new ArcLineData ("closed", "29%-closed", (0.29*100), (int) Color. rgb (155,187, 90); chartData. add (new ArcLineData ("inspect", "53%-inspect", (0.53*100), (int) Color. rgb (191, 79, 75); chartData. add (new ArcLineData ("open", "76%", (0.76*100), (int) Color. rgb (242,167, 69); chartData. add (new ArcLineData ("workdone", "86%", (0.86*100), (int) Color. (rgb (60,173,213); chartData. add (new ArcLineData ("dispute", "36%", (0.36*100), (int) Color. rgb (90, 79, 88);} private void addAttrInfo () {/////////////////////////////////////// ////////////////////// set the Additional Information Paint paintLib = new Paint (); paintLib. setColor (Color. rgb (46,164,212); paintLib. setTextAlign (Align. CENTER); paintLib. setTextSize (30); paintLib. setAntiAlias (true); chart. getPlotAttrInfo (). addAttributeInfo (XEnum. location. TOP, "arc bar chart", 0.1f, paintLib); chart. getPlotAttrInfo (). addAttributeInfo (XEnum. location. BOTTOM, "XCL-Charts", 0.4f, paintLib); Paint paintSrc = new Paint (); paintSrc. setTextAlign (Align. CENTER); paintSrc. setTextSize (25); paintSrc. setAntiAlias (true); paintSrc. setColor (int) Color. rgb (41, 34,102); chart. getPlotAttrInfo (). addAttributeInfo (XEnum. location. BOTTOM, "ExcelPro", 0.2f, paintSrc ); //////////////////////////////////////// /// //} @ Override public void render (Canvas canvas) {try {chart. render (canvas);} catch (Exception e) {Log. e (TAG, e. toString () ;}@ Overridepublic List <XChart> bindChart () {// TODO Auto-generated method stubList <XChart> lst = new ArrayList <XChart> (); lst. add (chart); return lst ;}}
The implementation details are encapsulated in the library. If you upload them to github, you can directly view the source code implementation. The caller takes the preceding steps, binds the data source, and adds text information displayed in the inner ring. I have never said anything about it. I have used a chart library to understand it at a glance.

Now let's show you how to implement it and explain its origins. Close.


MAIL: xcl_168@aliyun.com

BLOG: blog.csdn.net/xcl168







How to draw an arc with ps






How to draw an arc in PS

After you draw the curve in the second image, right-click the path on the path tab and select the stroke path, provided that you select the paint brush size and paint style.

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.