Basic tutorial-Section 8 piesampledemo. CS

Source: Internet
Author: User

Section 8 piesampledemo. CS: I will give a rough introduction to the pie chart, as shown in. Using system; using system. drawing; using system. collections; using zedgraph; namespace zedgraph. demo {/// <summary> /// summary description for simpledemo. /// </Summary> public class piesampledemo: demobase {public piesampledemo (): Base ("Code project pie sample", "Pie sample", demotype. pie, demotype. tutorial) {graphpane mypane = base. graphpane; // set the graphpane title mypane. title = "2004 ze DGRAPH sales by region/N ($ m) "; mypane. fontspec. isitalic = true; mypane. fontspec. size = 24f; mypane. fontspec. family = "times"; // fill the pane background with a color gradient mypane. panefill = New fill (color. white, color. goldenrod, 45.0f); // No fill for the Axis background mypane. axisfill. type = filltype. none; // set the legend to an arbitrary location mypane. legend. position = legendpos. float; Mypane. legend. location = new location (0.95f, 0.15f, coordtype. panefraction, alignh. right, alignv. top); mypane. legend. fontspec. size = 10f; mypane. legend. ishstack = false; // Add some pie slices pieitem segment1 = mypane. addpieslice (20, color. navy, color. white, 45f, 0, "North"); pieitem segment3 = mypane. addpieslice (30, color. purple, color. white, 45f ,. 0, "East"); pieitem segment4 = mypane. A Ddpieslice (10.21, color. limegreen, color. white, 45f, 0, "West"); pieitem segment2 = mypane. addpieslice (40, color. sandybrown, color. white, 45f, 0.2, "South"); pieitem segment6 = mypane. addpieslice (250, color. red, color. white, 45f, 0, "Europe"); pieitem segment7 = mypane. addpieslice (50, color. blue, color. white, 45f, 0.2, "Pac rim"); pieitem segment8 = mypane. addpieslice (400, color. green, Co Lor. white, 45f, 0, "South America"); pieitem segment9 = mypane. addpieslice (50, color. yellow, color. white, 45f, 0.2, "Africa"); segment2.labeldetail. fontspec. fontcolor = color. red; // sum up the pie values curvelist curves = mypane. curvelist; double Total = 0; For (INT x = 0; x <curves. count; X ++) Total + = (pieitem) curves [x]). value; // make a text label to highlight the total value text Item text = new textitem ("total 2004 sales/N" + "$" + total. tostring () + "M", 0.18f, 0.40f, coordtype. panefraction); text. location. alignh = alignh. center; text. location. alignv = alignv. bottom; text. fontspec. border. isvisible = false; text. fontspec. fill = New fill (color. white, color. fromargb (255,100,100), 45f); text. fontspec. stringalignment = stringalignment. center; mypane. graphitemlist. A Dd (text); // create a drop shadow for the total value text item textitem text2 = new textitem (text); text2.fontspec. fill = New fill (color. black); text2.location. X + = 0.008f; text2.location. Y + = 0.01f; mypane. graphitemlist. add (text2); base. zedgraphcontrol. axischange () ;}} code analysis: let's add the relevant properties of the legend class. // Set the legend to an arbitrary location mypane. legend. position = legendpos. float; mypane. legend. location = new location (0.95f, 0.15f, coordtype. panefraction, alignh. right, alignv. top); mypane. legend. fontspec. size = 10f; mypane. legend. ishstack = false; legendpos is an enumeration with 13 enumerated values: Top , Left , Right , Bottom , Insidetopleft , Insidetopright , Insidebotleft , Insidebotright , Float , Topcenter , Botshortenter , TopflushleftAnd Bottomflushleft .I will not explain the specific meaning. It is about the legend position. Location is a class that specifies the specific coordinates of legend. Note that only when legendpos is FloatLocation takes effect. The fontspec class is a font class that contains some settings about the font. Ishstack is a legend attribute. It sets whether the display mode of text and graphics in legend is horizontal or vertical. The main character of this section is pieitem class: pieitem segment6 = mypane. addpieslice (250, color. red, color. white, 45f, 0, "Europe"); pie reloads five constructor functions. The preceding constructor has the most parameters. There are six constructor functions in total, meaning: proportion of the entire pie chart, gradient color 1, gradient color 2, gradient color angle, distance from the center, text comments of the pie chart. The pie chart also inherits zedgraph. curveitem, unlike other products that inherit curveitem, pieitem has a value attribute, allowing you to conveniently access the value of the pieitem instance, this makes it easy to dynamically change the proportion of a pie in the entire pie area. For the use of other attributes and methods of pie charts, we will introduce them in the pie chart chapter.

 

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.