.net实现3D饼图(源码1)

<iframe align="top" marginwidth="0" marginheight="0" src="http://www.zealware.com/46860.html" frameborder="0" width="468" scrolling="no" height="60"></iframe>

点击此处下载源码+test代码(99KB,rar)

本来想改改几个bug再整理下发上来的。但是最近工作比较紧张,没有时间。发出来大家看看。多提提意见。帮忙改改。

using System;
using System.Collections;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;


namespace qchart
... {
/**////<summary></summary>
///chart的摘要说明。
///抽象类,所有chart的父类
///

publicabstractclassChart
...{

publicintwidth,height;
publicintcount=-1;
publicArrayListal=null;
publicBitmapbitmap=null;

publicChart()
...{
init(
400,300);
}


publicChart(intw,inth)
...{
init(w,h);
}


privatevoidinit(intw,inth)
...{
width
=w;
height
=h;
}



publicvoidsaveBitmap(stringfile)
...{
bitmap.Save(file,ImageFormat.Jpeg);
}


publicvoidsaveBitmap(Streamstream)
...{

bitmap.Save(stream,ImageFormat.Jpeg);
}


publicabstractvoidcreateBitmap();

}

}


using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections;
using System.IO;

namespace qchart
... {
/**////<summary></summary>
///饼图的抽象类,所有样式的饼图继承此类
///

publicabstractclassPieChart:Chart
...{
publicintstartAngle=0;

publicPieChart()
...{
init(
400,300);
}

publicPieChart(intw,inth)
...{
init(w,h);
}


privatevoidinit(intw,inth)
...{
width
=w;
height
=h;
al
=newArrayList();
}




publicvoidaddPieData(intval,stringname)
...{
PieDatapd
=newPieData(val,name);
al.Add(pd);
count
++;
}


publicvoidaddPieData(int[]vals,string[]names)
...{
intl=vals.Lengthnames.Length?vals.Length:names.Length;
for(inti=0;il;i++)
...{
addPieData(vals[i],names[i]);
}

//count+=l;
}


publicvoidremovePieData(intindex)
...{
if(index>=0&&indexcount)
...{
al.RemoveAt(index);
count
--;
}

}




}

}

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections;
using System.IO;

namespace qchart
... {
/**////<summary></summary>
///
///

publicclassPieChart2D:PieChart
...{

publicPieChart2D():base()
...{

}

publicPieChart2D(intw,inth):base(w,h)
...{

}



publicoverridevoidcreateBitmap()
...{
//用指定的大小和格式初始化Bitmap类的新实例
bitmap=newBitmap(width,height);
//创建绘图对象
Graphicsg=Graphics.FromImage(bitmap);
//清除整个绘图面并以透明背景色填充
//g.Clear(Color.Transparent);
g.Clear(Color.Snow);

Rectangler
=newRectangle(0,0,width,height);

//int[]angle={30,60,90,45,135};
intsum=startAngle;

Penp
=newPen(Color.YellowGreen);

for(inti=0;icount;i++)
...{
PieDatapd
=(PieData)al[i];
floatf=Convert.ToSingle(pd.val);
g.FillPie(Qcommon.b[i
%12],r,sum,f);
g.DrawPie(p,r,sum,f);
sum
+=Convert.ToInt32(f);
}


}





}

}

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections;
using System.IO;
using System.Drawing.Drawing2D;

namespace qchart
... {
/**////<summary></summary>
///
///

publicclassPieChart3D:PieChart
...{
staticreadonlyintdeta=30;
//staticreadonlyintdpt=5;

publicPieChart3D():base()
...{

}

publicPieChart3D(intw,inth):base(w,h)
...{

}



publicoverridevoidcreateBitmap()
...{
//boolflag=false;

//用指定的大小和格式初始化Bitmap类的新实例
bitmap=newBitmap(width,height);
//创建绘图对象
Graphicsg=Graphics.FromImage(bitmap);
//清除整个绘图面并以透明背景色填充
//g.Clear(Color.Transparent);
g.Clear(Color.Snow);

Rectanglers
=newRectangle((width-400)/2-50,(height-300)/2+deta/2,400,300);

//g.FillPie(Qcommon.b[0],rs,0,180);

Rectangler
=newRectangle((width-400)/2-50,(height-300)/2-deta/2,400,300);
//Rectanglerc=newRectangle((width-400)/2+50,(height-300)/2,300,300);

intsum=startAngle%360;

Penp
=newPen(Color.YellowGreen);
Penps
=newPen(Color.DarkGray);

Pointpt
=newPoint();
doublea=r.Width/2d;
doubleb=r.Height/2d;
分享到:
评论
happmaoo
  • 浏览: 1286842 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

你可能感兴趣的:(.net,工作,F#,360)