如何在饼图中显示数量,当我将光标悬停在饼图上时,我有此代码,但它不起作用。我是这个 C# 代码的新手
DataTable dt = new DataTable();
conexion.Open();
SqlDataAdapter da = new SqlDataAdapter("Select\r\ncount([referral_id]) as 'Count',\r\n[referral_type] as 'Type'\r\n\r\nfrom AlteryxDB.dbo.t_prd_pbixpipeline_crt2023\r\n\r\nwhere [ref_status]='Pending' and \r\n([recipient_eid] ='22216' and [referral_eid]='22216')\r\n\r\ngroup by\r\n[referral_type]", conexion);
da.Fill(dt);
chart3.DataSource = dt;
conexion.Close();
chart3.Series["Count"].XValueMember = "Type";
chart3.Series["Count"].YValueMembers = "Count";
我尝试放
chart3.Series["Count"].labeltooltip = "Count"
属性名称有拼写错误。设置
tooltip
的正确属性是 ToolTip
。此外,您可能还需要 ToolTip
来显示。
您的代码的更新版本 -
DataTable dt = new DataTable();
conexion.Open();
SqlDataAdapter da = new SqlDataAdapter("SELECT COUNT([referral_id]) as 'Count', [referral_type] as 'Type' FROM AlteryxDB.dbo.t_prd_pbixpipeline_crt2023 WHERE [ref_status]='Pending' AND ([recipient_eid] ='22216' AND [referral_eid]='22216') GROUP BY [referral_type]", conexion);
da.Fill(dt);
conexion.Close();
chart3.DataSource = dt;
chart3.Series["Count"].XValueMember = "Type";
chart3.Series["Count"].YValueMembers = "Count";
chart3.Series["Count"].ToolTip = "#VALX: #VALY";
参考:ToolTip类