Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 使用饼图添加用户名_Asp.net_Pie Chart - Fatal编程技术网

Asp.net 使用饼图添加用户名

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

我对饼图很陌生,我有一个饼图显示秒到hh:mm:ss,但我还需要包括用户名,这是我的代码

   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)成功了!谢谢你的帮助!请将其标记为已回答,这可能有助于其他有类似疑问的人。