点击此处下载源码+test代码(99KB,rar)
本来想改改几个bug再整理下发上来的。但是最近工作比较紧张,没有时间。发出来大家看看。多提提意见。帮忙改改。
using
System;
using
System.Drawing;
using
System.Drawing.Imaging;
using
System.Collections;
using
System.IO;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
namespace
qchart
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
...
{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**////
/// 饼图的抽象类,所有样式的饼图继承此类
///
public abstract class PieChart : Chart
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
public int startAngle = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public PieChart()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
init(400, 300);
}
public PieChart(int w,int h)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
init(w, h);
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void init(int w, int h)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
width = w;
height = h;
al = new ArrayList();
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public void addPieData(int val,string name)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
PieData pd = new PieData(val,name);
al.Add(pd);
count++;
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public void addPieData(int[] vals,string[] names)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
int l = vals.Length<names.Length?vals.Length:names.Length;
for(int i=0;i<l;i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
addPieData(vals[i],names[i]);
}
//count += l ;
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public void removePieData(int index)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
if(index >= 0 && index <=count)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
al.RemoveAt(index);
count--;
}
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
}
using
System;
using
System.Drawing;
using
System.Drawing.Imaging;
using
System.Collections;
using
System.IO;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
namespace
qchart
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
...
{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**////
///
///
public class PieChart2D : PieChart
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public PieChart2D() : base()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
}
public PieChart2D(int w, int h) : base(w, h)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public override void createBitmap()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
//用指定的大小和格式初始化 Bitmap 类的新实例
bitmap = new Bitmap(width, height);
//创建绘图对象
Graphics g = Graphics.FromImage(bitmap);
//清除整个绘图面并以透明背景色填充
//g.Clear(Color.Transparent);
g.Clear(Color.Snow);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Rectangle r = new Rectangle(0, 0, width, height);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//int[] angle = {30,60,90,45,135} ;
int sum = startAngle;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Pen p = new Pen(Color.YellowGreen);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i = 0; i <= count; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
PieData pd = (PieData)al[i];
float f = Convert.ToSingle(pd.val);
g.FillPie(Qcommon.b[i % 12], r, sum, f);
g.DrawPie(p, r, sum, f);
sum += Convert.ToInt32(f);
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
}
using
System;
using
System.Drawing;
using
System.Drawing.Imaging;
using
System.Collections;
using
System.IO;
using
System.Drawing.Drawing2D;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
namespace
qchart
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
...
{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**////
///
///
public class PieChart3D : PieChart
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
static readonly int deta = 30;
//static readonly int dpt = 5;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public PieChart3D() : base()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
}
public PieChart3D(int w, int h):base(w,h)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public override void createBitmap()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
//bool flag = false;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//用指定的大小和格式初始化 Bitmap 类的新实例
bitmap = new Bitmap(width , height );
//创建绘图对象
Graphics g = Graphics.FromImage(bitmap);
//清除整个绘图面并以透明背景色填充
//g.Clear(Color.Transparent);
g.Clear(Color.Snow);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Rectangle rs = new Rectangle((width - 400) / 2 - 50, (height - 300) / 2 + deta/2, 400, 300);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//g.FillPie(Qcommon.b[0], rs, 0, 180);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Rectangle r = new Rectangle((width - 400) / 2 - 50 , (height - 300)/2 - deta/2, 400, 300);
//Rectangle rc = new Rectangle((width - 400) / 2 + 50, (height - 300) / 2, 300, 300);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int sum = startAngle % 360;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Pen p = new Pen(Color.YellowGreen);
Pen ps = new Pen(Color.DarkGray);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Point pt = new Point();
double a = r.Width / 2d;
double b = r.Height / 2d;
pt.X = r.X + r.Width / 2;
pt.Y = r.Y + r.Height / 2;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//画底面和侧边
for (int i = 0; i <= count; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
double af = sum / 180d * Math.PI;
int sign = Math.Sign(Math.Cos(af));
double k = Math.Tan(af);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
double dx = sign * Math.Sqrt(1 / (1 / (a * a) + k * k / (b * b)));
double dy = k * dx;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int x = pt.X + (int)dx;
int y = pt.Y + (int)dy;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PieData pd = (PieData)al[i];
float f = Convert.ToSingle(pd.val);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int nextsum = (sum + Convert.ToInt32(f)) % 360;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
g.FillPie(Qcommon.b[i % 12], rs, sum, f);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (sum > 180)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
if (nextsum < 180)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
g.FillPolygon(Qcommon.b[i % 12], new Point[] ...{ new Point(pt.X + (int)a, pt.Y), new Point(pt.X + (int)a, pt.Y + deta), pt });
g.DrawLine(p, new Point(pt.X + (int)a, pt.Y), new Point(pt.X + (int)a, pt.Y + deta));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//pt = subsidy(g, sum, p, pt, a, b, i + 1, x, y, nextsum);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Point pend = findPoint(nextsum, a, b, pt);
if (nextsum < 90)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
printSmailRect(g, i, pend);
g.DrawLine(p, new Point(pend.X, pend.Y + deta), new Point(pt.X, pt.Y + deta));
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
}
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
if (nextsum > 180)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
if (sum <= 90)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
// 第一象限,补上小正方形就可以了。
g.FillRectangle(Qcommon.b[i % 12], x - deta, y, deta, deta);
}
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**////// start
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pt = subsidy(g, sum, p, pt, a, b, i, x, y, nextsum);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**////// end
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// 处理180 度
if (sum == 180)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
if (i == 0)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
g.FillPolygon(Qcommon.b[(al.Count - 1) % 12], new Point[] ...{ new Point(pt.X - (int)a, pt.Y), new Point(pt.X - (int)a, pt.Y + deta), pt });
}
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
g.FillPolygon(Qcommon.b[(i - 1) % 12], new Point[] ...{ new Point(pt.X - (int)a, pt.Y), new Point(pt.X - (int)a, pt.Y + deta), pt });
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
g.DrawLine(p, new Point(pt.X - (int)a, pt.Y), new Point(pt.X - (int)a, pt.Y + deta));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pt = subsidy(g, sum, p, pt, a, b, i, x, y, nextsum);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// 画底图扇形
g.DrawPie(ps, rs, sum, f);
// 画start本处竖线
g.DrawLine(p, new Point(x, y), new Point(x, y + deta));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
sum = nextsum;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//this.saveBitmap("e:/qchart/temp/A" + i.ToString() + ".jpg");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}//for
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int labelWidth = r.Right + deta;
int labelHeight = deta;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
sum = startAngle % 360;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// 画顶面
for (int i = 0; i <= count; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PieData pd = (PieData)al[i];
float f = Convert.ToSingle(pd.val);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int nextsum = sum + Convert.ToInt32(f);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
g.FillPie(Qcommon.b[i % 12], r, sum, f);
g.DrawPie(p, r, sum, f);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
g.FillRectangle(Qcommon.b[i % 12], labelWidth, labelHeight, 10, 10);
g.DrawString(pd.name, Qcommon.LegendFont, Qcommon.b[i % 12], new PointF(labelWidth + 14, labelHeight));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
labelHeight += 16;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
sum = nextsum;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**/////this.saveBitmap("e:/qchart/temp/B" + i.ToString() + ".jpg");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}//for
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//g.DrawArc(p, rs, 0, 180);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void printSmailRect(Graphics g, int i, Point pend)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
Brush br = null;
if (i == count)
br = Qcommon.b[0];
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
br = Qcommon.b[(i>0?(i - 1):i) % 12];
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
g.FillRectangle(Qcommon.b[0], pend.X - deta, pend.Y, deta, deta);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private Point subsidy(Graphics g, int sum, Pen p, Point pt, double a, double b, int i, int x, int y, int nextsum)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
Point pend = findPoint(nextsum, a, b, pt);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// 填充底图扇形
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**/////g.FillPie(Qcommon.b[i % 12], rs, sum, f);
// 补偿三角形 :// 侧面的竖线端点加上前一个位置的上面的顶点
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (i == 0)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
if (sum <= 90)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
// 第一象限,补上小正方形就可以了。
g.FillRectangle(Qcommon.b[0], x - deta, y, deta, deta);
}
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
g.FillPolygon(Qcommon.b[0], new Point[] ...{ new Point(x, y), new Point(x, y + deta), new Point(pt.X + (int)a, pt.Y) });
}
}
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
//g.FillPolygon(Qcommon.b[i - 1], new Point[] { new Point(x, y), new Point(pend.X, pend.Y + deta), pend });
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (sum <= 90)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
// 第一象限,补上小正方形就可以了。
g.FillRectangle(Qcommon.b[i % 12], x - deta, y, deta, deta);
}
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
float pref = Convert.ToSingle(((PieData)al[i - 1]).val);
int presum = sum - Convert.ToInt32(pref);
if (presum < 0) presum += 360;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// 侧面的竖线端点加上前一个位置的上面的顶点
Point prept = findPoint(presum, a, b, pt);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
g.FillPolygon(Qcommon.b[i - 1], new Point[] ...{ new Point(x, y), new Point(x, y + deta), prept });
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (i == count)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
printLine(g, p, pend);
}
return pt;
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void printLine(Graphics g, Pen p, Point pend)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
g.DrawLine(p,pend,new Point(pend.X,pend.Y + deta));
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private Point findPoint(int presum,double a,double b,Point pt)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
double af = presum / 180d * Math.PI;
int sign = Math.Sign(Math.Cos(af));
double k = Math.Tan(af);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
double dx = sign * Math.Sqrt(1 / (1 / (a * a) + k * k / (b * b)));
double dy = k * dx;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int x = pt.X + (int)dx;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
int y = pt.Y + (int)dy;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return new Point(x,y);
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
}
using
System;
using
System.Drawing;
using
System.Drawing.Imaging;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
namespace
qchart
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
...
{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**////
/// qcommon 的摘要说明。
///
public class Qcommon
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
public static Brush[] b = ...{ Brushes.Purple,
Brushes.LightSkyBlue,
Brushes.Pink,
Brushes.SeaGreen,
Brushes.Tomato,
Brushes.RoyalBlue,
Brushes.Orange,
Brushes.DarkGray,
Brushes.PowderBlue,
Brushes.OliveDrab,
Brushes.Navy,
Brushes.Magenta
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public static Font LegendFont = new Font("宋体", 8, FontStyle.Regular);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
}
}
using
System;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
namespace
qchart
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
...
{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
/**////
/// 饼图的数据格式
///
public class PieData
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
public PieData(double val,string name)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
...{
this.val = val ;
this.name = name ;
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public double val;
public string name = null;
}
}