我試圖用列值的名稱來標記我的餅圖(在這種情況下,這將是機器名稱和它旁邊的百分比),這是相當困難的。默認情況下,在C#中,我從MySQL數據庫繪製它基於列「機器」上採集數據,而下面是我目前擁有的代碼,這將只顯示百分比:在c#中的餅圖標籤的文字和百分比
string DatabaseCountMachines = "SELECT Machine, COUNT(*) total FROM completed GROUP BY Machine";
MySqlConnection conDataBase = new MySqlConnection(constring);
MySqlCommand cmdDataBase = new MySqlCommand(DatabaseCountMachines, conDataBase);
MySqlDataReader StatsbyMachine;
try
{
conDataBase.Open();
StatsbyMachine = cmdDataBase.ExecuteReader();
while (StatsbyMachine.Read())
{
this.chartMachine.Series["Series1"].Points.AddXY(StatsbyMachine.GetString("Machine"), StatsbyMachine.GetString("total"));
this.chartMachine.Series["Series1"].CustomProperties = "PieLabelStyle=Outside";
this.chartMachine.Series["Series1"].Label = "#LEGENDTEXT" + "#PERCENT";
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
在餅圖中,x值不適用。 (你可以使用'AddY')你可以顯示你想要的圖像嗎? – TaW