Basic Tutorial Chapter--The eighth section PieSampleDemo.cs introduction

Source: Internet
Author: User

In this section I introduce the pie chart roughly, as shown below.

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 = "Zedgraph Sales by Regionn ($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 a 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 (Color.navy, Color.White, 45f, 0, "North");

Pieitem Segment3 = Mypane.addpieslice (Color.purple, Color.White, 45f,. 0, "East");

Pieitem segment4 = Mypane.addpieslice (10.21, Color.limegreen, Color.White, 45f, 0, "West");

Pieitem Segment2 = Mypane.addpieslice (Color.sandybrown, Color.White, 45f, 0.2, "South");

Pieitem segment6 = Mypane.addpieslice (color.red, Color.White, 45f, 0, "Europe");

Pieitem segment7 = Mypane.addpieslice (M, Color.Blue, Color.White, 45f, 0.2, "Pac Rim");

Pieitem segment8 = Mypane.addpieslice (Color.green, Color.White, 45f, 0, "South America");

Pieitem segment9 = Mypane.addpieslice (M, 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

Textitem Text = new Textitem ("Total-salesn" + "$" + 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, MB), 45F);

Text. Fontspec.stringalignment = Stringalignment.center;

MYPANE.GRAPHITEMLIST.ADD (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 ();

}

}

}

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.