我下了个饼图的控件,里面分别有DundasWebChart.dll和DundasWinChart.dll
但我不晓得咋个用的。。那个高手指导下。。最好有demo
但我不晓得咋个用的。。那个高手指导下。。最好有demo
解决方案 »
- 求助:C#中做了一个WINDOWS服务,想每周一早上8点半抽取数据库数据,不知道如何写,请各位大侠赐教
- 如何判断IP地址的格式正确与否!!!
- 用过Queue类的,探讨下
- 在 System.Data.SqlClient.SqlException 中第一次偶然出现的“System.Data.dll”类型的异常
- 有人用过用友的cell报表不?能不能用程序将excel像cell那样的操作?100分啊,着急!!
- 我要实现像资源管理器中那可以拖动的两边,请问在c# winForm vs2005中怎么实现?我想在中间加一条线,当鼠标到那里变掉,然后可以拖动,请问
- 请问这个用c#如何写(非常急!!!!)
- 关於 Winform 调用 WebService Config的问题
- 关于如何在新窗口中打开链接问题!
- 数据库设计问题
- 再遇表单提交问题,请各位帮忙解释一下为什么会有这样的问题。大家先看代码
- 高分求解,MediaPlayer播放时占用带宽问题
http://support.dundas.com/Default.aspx?section=206
/// <summary>
/// 根据货物所占百分比画饼图
/// </summary>
/// <param name="objgraphics">Graphics类对象</param>
/// <param name="M_str_sqlstr">SQL语句</param>
/// <param name="M_str_table">表名</param>
/// <param name="M_str_Num">数据表中货物数</param>
/// <param name="M_str_tbGName">数据表中货物名称</param>
/// <param name="M_str_title">饼图标题</param>
public void drawPic(Graphics objgraphics,string M_str_sqlstr, string M_str_table, string M_str_Num, string M_str_tbGName, string M_str_title)
{
DataSet myds = datacon.getds(M_str_sqlstr, M_str_table);
float M_flt_total = 0.0f, M_flt_tmp;
int M_int_iloop;
for (M_int_iloop = 0; M_int_iloop < myds.Tables[0].Rows.Count; M_int_iloop++)
{
M_flt_tmp = Convert.ToSingle(myds.Tables[0].Rows[M_int_iloop][M_str_Num]);
M_flt_total += M_flt_tmp;
}
Font fontlegend = new Font("verdana", 9), fonttitle = new Font("verdana", 10, FontStyle.Bold);//设置字体
int M_int_width = 275;//白色背景宽
const int Mc_int_bufferspace = 15;
int M_int_legendheight = fontlegend.Height * (myds.Tables[0].Rows.Count + 1) + Mc_int_bufferspace;
int M_int_titleheight = fonttitle.Height + Mc_int_bufferspace;
int M_int_height = M_int_width + M_int_legendheight + M_int_titleheight + Mc_int_bufferspace;//白色背景高
int M_int_pieheight = M_int_width;
Rectangle pierect = new Rectangle(0, M_int_titleheight, M_int_width, M_int_pieheight);
//加上各种随机色
Bitmap objbitmap = new Bitmap(M_int_width, M_int_height);//创建一个bitmap实例
objgraphics = Graphics.FromImage(objbitmap);
ArrayList colors = new ArrayList();
Random rnd = new Random();
for (M_int_iloop = 0; M_int_iloop < myds.Tables[0].Rows.Count; M_int_iloop++)
colors.Add(new SolidBrush(Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255))));
objgraphics.FillRectangle(new SolidBrush(Color.White), 0, 0, M_int_width, M_int_height);//画一个白色背景
objgraphics.FillRectangle(new SolidBrush(Color.LightYellow), pierect);//画一个亮黄色背景
//以下为画饼图(有几行row画几个)
float M_flt_currentdegree = 0.0f;
for (M_int_iloop = 0; M_int_iloop < myds.Tables[0].Rows.Count; M_int_iloop++)
{
objgraphics.FillPie((SolidBrush)colors[M_int_iloop], pierect, M_flt_currentdegree,
Convert.ToSingle(myds.Tables[0].Rows[M_int_iloop][M_str_Num]) / M_flt_total * 360);
M_flt_currentdegree += Convert.ToSingle(myds.Tables[0].Rows[M_int_iloop][M_str_Num]) / M_flt_total * 360;
}
//以下为生成主标题
SolidBrush blackbrush = new SolidBrush(Color.Black);
StringFormat stringFormat = new StringFormat();
stringFormat.Alignment = StringAlignment.Center;
stringFormat.LineAlignment = StringAlignment.Center;
objgraphics.DrawString(M_str_title, fonttitle, blackbrush, new Rectangle(0, 0, M_int_width, M_int_titleheight), stringFormat);
objgraphics.DrawRectangle(new Pen(Color.Black, 2), 0, M_int_height - M_int_legendheight, M_int_width, M_int_legendheight);
for (M_int_iloop = 0; M_int_iloop < myds.Tables[0].Rows.Count; M_int_iloop++)
{
objgraphics.FillRectangle((SolidBrush)colors[M_int_iloop], 5, M_int_height - M_int_legendheight + fontlegend.Height * M_int_iloop + 5, 10, 10);
objgraphics.DrawString(((String)myds.Tables[0].Rows[M_int_iloop][M_str_tbGName]) + " —— "
+ Convert.ToString(Convert.ToSingle(myds.Tables[0].Rows[M_int_iloop][M_str_Num]) * 100 / M_flt_total) + "%", fontlegend, blackbrush,
20, M_int_height - M_int_legendheight + fontlegend.Height * M_int_iloop + 1);
}
objgraphics.DrawString("总货物数是:" + Convert.ToString(M_flt_total), fontlegend, blackbrush, 5, M_int_height - fontlegend.Height);
string P_str_imagePath = Application.StartupPath.Substring(0, Application.StartupPath.Substring(0,
Application.StartupPath.LastIndexOf("\\")).LastIndexOf("\\"));
P_str_imagePath += @"\Image\image\" + DateTime.Now.ToString("yyyyMMddhhmss") + ".jpg";
objbitmap.Save(P_str_imagePath, ImageFormat.Jpeg);
objgraphics.Dispose();
objbitmap.Dispose();
}
#endregion