问题
I need to display points values in chart graph when I tried the result was
But I want it like
My code is
SqlCommand territorycommand = new SqlCommand("select Terriotry,TotalAcheivmentVol,Forecast from ForecastTotal where Year = '" + DateTime.Now.Year.ToString() + "' and Terriotry = '" + territory + "' and month = '"+Month+"'", conn);
try
{
conn.Open();
mydatareader = territorycommand.ExecuteReader();
while (mydatareader.Read())
{
chart1.Series["TotalAchievment"].Points.AddXY(mydatareader.GetString(0), mydatareader.GetInt32(1));
chart1.Series["Forecast"].Points.AddY(mydatareader.GetInt32(2));
chart1.ChartAreas[0].AxisX.LabelStyle.Interval = 1;
chart1.ChartAreas[0].AxisX.Interval = 1;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
conn.Close();
Is this possible ?
回答1:
You can show series value in label as:
chart1.Series["TotalAchievment"].IsValueShownAsLabel = true
chart1.Series["Forecast"].IsValueShownAsLabel = true
来源:https://stackoverflow.com/questions/44784648/how-to-display-values-on-chart-graph-using-c-sharp