制作一个图形饼图在C# [英] Making A Graphic Pie Chart In C#
问题描述
我试图写一个Windows应用程序,显示有七个不等切片(25%,20%,18%,17%,10%,10%,10%),所有的人都饼图将不同颜色
I'm trying to write a Windows Application that shows a pie chart with seven unequal slices (25%, 20%, 18%, 17%, 10%, 10%, 10%) all of them will be colored differently.
到目前为止,我已经做画笔和画刷附加和画出的圆圈的颜色。
So far I have made Pens and Brushes with colors attached and drawn a circle.
这是什么我至今
private void Form1_Paint(object sender, PaintEventArgs e)
{
this.BackColor = Color.White;
this.Text = "Pie Chart";
this.Width = 350;
this.Height = 350;
Pen black = new Pen(Color.Black);
Pen blue = new Pen(Color.Blue);
Pen green = new Pen(Color.Green);
Pen red = new Pen(Color.Red);
Pen orange = new Pen(Color.Orange);
Pen pink = new Pen(Color.Pink);
Pen purple = new Pen(Color.Purple);
Pen magenta = new Pen(Color.Purple);
Brush brBlue = blue.Brush;
Brush brGreen = green.Brush;
Brush brRed = red.Brush;
Brush brOrange = orange.Brush;
Brush brPink = pink.Brush;
Brush brPurple = purple.Brush;
Brush brMagenta = magenta.Brush;
Graphics g = e.Graphics;
g.DrawEllipse(black, 20, 10, 300, 300);
}
我给你的问题。什么是绘制饼图楔形的最简单的方法是什么?
My question to you is. What would be the easiest way to draw the wedges of the pie?
推荐答案
我会建议你看一看<强> ZedGraph
I will advise you to take a look at ZedGraph.
如果你想要一个示例代码的饼图使用GDI实际绘制你可以检查此 教程。 。它采用 FillPie 一> Graphics类的方法。
If you want a sample code to actually draw pieChart using GDI you can check this tutorial.. It uses FillPie Method of Graphics class.
这篇关于制作一个图形饼图在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!