how to display values on chart graph using c#

偶尔善良 提交于 2019-12-12 05:29:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!