Use zedgraph as a chart (1)

Source: Internet
Author: User

You need to make a statistical function. Of course, charts are the most intuitive choice. As for controls, if you want to use open-source components, you must first check the information on the Internet. There are quite a few examples of charts, zedgraph ,. net charts, nplot, xscharting, davechart, and nchart each have their own characteristics. My statistical function is relatively simple, so I have no specific choice to use it. I chose zedgraph directly.
First, create a pie chart and analyze the code.

Create a window application, introduce zedgraph DLL, place a zedgraphcontrol control on form, set its height and width, and add the following code, and call this method in form_load.

Public void createchart (zedgraphcontrol zgc)
{
Graphpane mypane = zgc. graphpane;

// Set the title and title style of the chart.
Mypane. Title. Text = "2004 zedgraph sales by region \ n ($ m )";
Mypane. Title. fontspec. isitalic = true;
Mypane. Title. fontspec. size = 24f;
Mypane. Title. fontspec. Family = "Times New Roman ";

// Set the background color
Mypane. Fill = New fill (color. White, color. goldenrod, 45.0f );
// Set the color fill of the chart. If it is set to filltype. None, the fill color is the same as the background color.
Mypane. Chart. Fill. type = filltype. None;

// Set the legend size and position
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;

/*
* Set the parts of a pie chart
* The parameters of addpieslice are value, color, gradient, gradient size, distance from the center, and name.
*/
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. addpieslice (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, color. White, 45f, 0, "South America ");
Pieitem segment9 = mypane. addpieslice (50, color. Yellow, color. White, 45f, 0.2, "Africa ");

Zgc. axischange ();
}

Okay, run it directly and a simple pie chart will appear.


Technorati: Using zedgraph as a chart

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.