Asp.net 使用饼图添加用户名
我对饼图很陌生,我有一个饼图显示秒到hh:mm:ss,但我还需要包括用户名,这是我的代码Asp.net 使用饼图添加用户名,asp.net,pie-chart,Asp.net,Pie Chart,我对饼图很陌生,我有一个饼图显示秒到hh:mm:ss,但我还需要包括用户名,这是我的代码 string easystone = ConfigurationManager.ConnectionStrings["easystone"].ConnectionString; SqlConnection con = new SqlConnection(easystone); SqlDataAdapter graph = new SqlDataAdapter("SELECT[User
string easystone = ConfigurationManager.ConnectionStrings["easystone"].ConnectionString;
SqlConnection con = new SqlConnection(easystone);
SqlDataAdapter graph = new SqlDataAdapter("SELECT[User] , sum(time) as [time] FROM avgtime3 group by[user]", con);
DataTable graphdata = new DataTable();
graph.Fill(graphdata);
chart1.DataSource = graphdata;
chart1.ChartAreas["ChartArea1"].AxisX.Title = "";
foreach (DataRow row in graphdata.Rows)
{
int total = (int)row["time"];
int index = chart1.Series["Series1"].Points.AddXY(row["User"], new object[] { total });
chart1.Series["Series1"].Points[index].Label = // I need the username to go here.
chart1.Series["Series1"].Points[index].Label = string.Format("{0:00}:{1:00}:{2:00}", (total / 60) / 60, (total / 60) % 60, total % 60);
}
在用户名前面加上时间前缀
chart1.Series["Series1"].Points[index].Label = row["User"].ToString() + " : " + string.Format("{0:00}:{1:00}:{2:00}", (total / 60) / 60, (total / 60) % 60, total % 60);
可能您想在标签上显示用户名和时间。因此,在用户名前面加上时间前缀<代码>图表1.Series[“Series1”]点[index].Label=row[“User”].ToString()+:“+string.Format(“{0:00}:{1:00}:{2:00}),(total/60)/60,(total/60)%60,total%60)代码>成功了!谢谢你的帮助!请将其标记为已回答,这可能有助于其他有类似疑问的人。