我希望显示Expr1中的数据而不是日期。 我的意思是VALUE LABEL应该由Expr1而不是Date编写。 有谁知道该怎么做?
我的桌子:
-------------------------------------
NameOfRas | Date | Expr1
--------------------------------------
Food | 07/09/2019 | 13
--------------------------------------
Hotel | 09/09/2019 | 32
--------------------------------------
Museum | 12/09/2019 | 52
--------------------------------------
然后用C#编写代码:
SqlDataReader myReader = null;
chart4.Titles.Clear();
chart4.Titles.Add("Общая диаграмма по датам и видам расходов");
chart4.Titles[0].Font = new System.Drawing.Font("Utopia", 16);
SqlCommand myCommand = new SqlCommand("SELECT Rashod.NameOfRas, SpendByDays.Date, SUM(Price) AS Expr1 FROM SpendByDays, Rashod WHERE Rashod.ID_ras = SpendByDays.ID_ras GROUP BY Rashod.NameOfRas, SpendByDays.Date", conn);
myCommand.Parameters.Clear();
conn.Open();
myReader = myCommand.ExecuteReader();
if (myReader.HasRows)
{
chart4.Series.Clear();
chart4.Series.Add(new Series("")
{
ChartType = SeriesChartType.Column
});
chart4.Palette = ChartColorPalette.Pastel;
chart4.Series[0].IsValueShownAsLabel = true;
chart4.Series[0].Points.DataBindXY(myReader, "NameOfRas", myReader, "Date");
chart4.Legends[0].Enabled = true;
chart4.Visible = true;
}
else
{
chart4.Visible = false;
MessageBox.Show("Ничего не найдено", "Information", MessageBoxButtons.OK);
}
myReader.Close();
conn.Close();