本文整理汇总了C#中Chart.CreatePieChart方法的典型用法代码示例。如果您正苦于以下问题:C# Chart.CreatePieChart方法的具体用法?C# Chart.CreatePieChart怎么用?C# Chart.CreatePieChart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chart
的用法示例。
在下文中一共展示了Chart.CreatePieChart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: toolQuery_Click
private void toolQuery_Click(object sender, EventArgs e)
{
if (toolcbxBaseType.SelectedItem != null)
{
DataRow dr = null;
Chart chart = new Chart();
int? intAmount = null;
DataTable dtTemp = new DataTable();
string strTableMeanings = toolcbxBaseType.Text; //某个类别表的名称(如:信用等级表、客户等级表等等)
string strTable = dicKeyValue[toolcbxBaseType.SelectedIndex].ToString(); //某个具体的类别表(共有两个字段:*Code和*Name)
try
{
//添加“代码”“名称”“数量”三个列于内存表(dtTemp)
DataColumn dc1 = new DataColumn("Code", typeof (string));
dtTemp.Columns.Add(dc1);
DataColumn dc2 = new DataColumn("Name", typeof (string));
dtTemp.Columns.Add(dc2);
DataColumn dc3 = new DataColumn("Amount", typeof (Int32));
dtTemp.Columns.Add(dc3);
DataTable dtBaseType = db.GetDataTable("Select * From " + strTable, strTable);
string strCodeColumn = dtBaseType.Columns[0].ColumnName;
string strNamecolumn = dtBaseType.Columns[1].ColumnName;
foreach (DataRow row in dtBaseType.Rows)
{
dr = dtTemp.NewRow(); //得到与该DataTable具有相同结构的一个DataRow对象
dr["Code"] = row[strCodeColumn];
dr["Name"] = row[strNamecolumn];
intAmount =
db.GetSingleObject("Select Count(*) From BSCustomer Where " + strCodeColumn + " = '" +
row[strCodeColumn] + "'") as int?;
if (!intAmount.HasValue)
{
intAmount = 0;
}
dr["Amount"] = intAmount.Value;
dtTemp.Rows.Add(dr);
}
//增加客户档案中未设置情况的信息
dr = dtTemp.NewRow();
dr["Code"] = DBNull.Value;
dr["Name"] = "未设定";
intAmount =
db.GetSingleObject("Select Count(*) From BSCustomer Where " + strCodeColumn + " is null ") as
int?;
if (!intAmount.HasValue)
{
intAmount = 0;
}
dr["Amount"] = intAmount.Value;
dtTemp.Rows.Add(dr);
//绘制饼形图
if (dtTemp.Rows.Count > 0)
{
picPie.Image = chart.CreatePieChart("类型分析", "——" + strTableMeanings, 679, 384, dtTemp, 2);
}
}
catch (Exception ex)
{
throw ex;
}
}
}