ASP.NET中使用C#语言的动态饼图 [英] Dynamic pie chart in ASP.NET with C# language
本文介绍了ASP.NET中使用C#语言的动态饼图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在饼图中运行时绑定数据,但我不知道x轴和y轴的值
什么我试过了:
// dstotal = objemp.getdata();
// string s = dstotal.Tables [0] .Rows [0] [Mtotal]。ToString();
// string s1 = dstotal.Tables [1] .Rows [0] [Etotal]。ToString();
// int count = Convert.ToInt16(s);
// int count1 = Convert.ToInt16(s1);
string [] xVal = { 费用, 收入};
double [] yVal = { 3 , 5 };
Chart1.Series [ 0 ]。Points.DataBindXY(xVal,yVal);
Chart1.Legends [ 0 ]。Enabled = true ;
解决方案
ASP.NET 4及以上版本有一个图表控件,可以使用饼图,但没有X ,Y轴你无法绑定饼图
见下面的片段我已经给出了一个样本来绑定饼图
protected void Page_Load( object sender,EventArgs e)
{
double [] yValues = { 71 。 15 , 23 。 19 , 5 。 66 };
string [] xValues = { AAA , BBB, CCC};
Chart1.Series [ 默认]。Points.DataBindXY(xValues,yValues);
Chart1.Series [ 默认]。积分[ 0 ]。颜色= Color.MediumSeaGreen;
Chart1.Series [ 默认]。点[ 1 ]。颜色= Color.PaleGreen;
Chart1.Series [ 默认]。点[ 2 ]。颜色= Color.LawnGreen;
Chart1.Series [ 默认]。ChartType = SeriesChartType.Pie ;
Chart1.Series [ 默认] [ PieLabelStyle] = 禁用跨度>;
Chart1.ChartAreas [ ChartArea1]。Area3DStyle.Enable3D = < span class =code-keyword> true ;
Chart1.Legends [ 0 ]。Enabled = true ;
}
了解更多详情见下面链接
如何使用ASP.Net和C#创建饼图 [ ^
i want to bind data at run time in a pie chart but i do not know the values of x-axis and y-axis
What I have tried:
//dstotal = objemp.getdata();
//string s = dstotal.Tables[0].Rows[0]["Mtotal"].ToString();
//string s1 = dstotal.Tables[1].Rows[0]["Etotal"].ToString();
//int count = Convert.ToInt16(s);
//int count1 = Convert.ToInt16(s1);
string[] xVal = { "Expenses", "Income" };
double[] yVal = { 3, 5 };
Chart1.Series[0].Points.DataBindXY(xVal, yVal);
Chart1.Legends[0].Enabled = true;
解决方案
ASP.NET 4 and above has a charting control, you can use pie chart from it, but without X,Y axis you are unable to bind pie chart
see below snippet in that i have given a sample to bind pie chart
protected void Page_Load(object sender, EventArgs e) { double[] yValues = { 71.15, 23.19, 5.66 }; string[] xValues = { "AAA", "BBB", "CCC" }; Chart1.Series["Default"].Points.DataBindXY(xValues, yValues); Chart1.Series["Default"].Points[0].Color = Color.MediumSeaGreen; Chart1.Series["Default"].Points[1].Color = Color.PaleGreen; Chart1.Series["Default"].Points[2].Color = Color.LawnGreen; Chart1.Series["Default"].ChartType = SeriesChartType.Pie; Chart1.Series["Default"]["PieLabelStyle"] = "Disabled"; Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true; Chart1.Legends[0].Enabled = true; }
for more details see below link
How to create a Pie chart using ASP.Net and C#[^]
这篇关于ASP.NET中使用C#语言的动态饼图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文