我有一个根据数据库中的数据创建的图表。如果我从数据库中获取的数据为空,则不会显示图表,但图例仍然可见。如果图表没有数据,如何隐藏图例标签?
conn.Open();
SqlDataAdapter Adapt = new SqlDataAdapter($"SELECT column_name1,
sum (column_name2) as mySum FROM table
WHERE YEAR(date_column) = 2019 group by column_name1", conn);
chart.Fill(ds);
chart.DataSource = ds;
chart.Series["Sum"].XValueMember = "column_name1";
chart.Series["Sum"].YValueMembers = "mySum";
chart.Series["Sum"].IsValueShownAsLabel = true;
conn.Close();