我通过Windows窗体应用程序创建图表,我的代码可以工作,但我想改变图片中这些的颜色,我不知道他们的名字,代码: output picture
我想将颜色而不是蓝色更改为GreenYellow,而不是将橙色更改为Bisque。
代码完全正常,但这两个颜色与列的颜色不同! 我的代码是:
MySqlConnection cn = new MySqlConnection("Database=growing_together;Data Source=localhost;User Id=root;password=;CHARSET=utf8;");
DataTable dt2 = new DataTable();
cn.Open();
MySqlDataReader dR;
MySqlCommand QryDerniereAnnee, QryAnneeCourante;
int derniereAnnee = DateTime.Today.Year - 1;
QryDerniereAnnee = new MySqlCommand("SELECT Extract(month from date_facture) as numMois,MONTHNAME(date_facture) as mois, SUM(montant) as sommeM from facture where Extract(year from date_facture)=" + derniereAnnee.ToString() + " GROUP BY mois order by numMois", cn);
QryAnneeCourante = new MySqlCommand("SELECT Extract(month from date_facture) as numMois,MONTHNAME(date_facture) as mois, SUM(montant) as sommeM from facture where Extract(year from date_facture)=" + DateTime.Today.Year + " GROUP BY mois order by numMois", cn);
try
{
Series last = new Series("Last Year "+derniereAnnee);
dR = QryDerniereAnnee.ExecuteReader();
int i1=0;
while (dR.Read())
{
last.Points.AddXY(dR.GetString("mois"), dR.GetInt32("sommeM"));
last.Points[i1].Color = Color.GreenYellow;
i1++;
}
dR.Close();
chart2.Series.Add(last);
Series current = new Series("Current Year " + DateTime.Today.Year);
dR = QryAnneeCourante.ExecuteReader();
int i2 = 0;
while (dR.Read())
{
current.Points.AddXY(dR.GetString("mois"), dR.GetInt32("sommeM"));
current.Points[i2].Color = Color.Bisque;
i2++;
}
dR.Close();
chart2.Series.Add(current);
chart2.AlignDataPointsByAxisLabel();
}
catch(Exception e1)
{
MessageBox.Show("Chart cannot be displayed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}