我试图用列值的名称来标记我的饼图(在这种情况下,这将是机器名称和它旁边的百分比),这是相当困难的。默认情况下,在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