关于图的问题 [英] Question about graph

查看:75
本文介绍了关于图的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过从列表框中的复选框中选择产品以及从datetimepicker的日期之间进行选择来创建数据库中的数据的图表,当单击该按钮以在图形中生成图形值时,在每个系列中显示相同的数据,我不知道如何解决此问题

这是我的代码

i need to create chart with data from my database by select product from checkbox in listbox and between date from datetimepicker bet when click the button for generate graph value in graph show same data for every series i don''t know how to fix this problem

this is my code

if (row.Cells[1].Value != null && (bool)row.Cells[1].FormattedValue)
                {                       
                        String idtoselect = row.Cells[0].Value.ToString();
                        String str1 = idtoselect.ToString();
                        
                        try
                        {
                            string sql2 = "select NAME_Product from Product where  Product.ID_Product = '"+str1+"' ";
                            SqlCommand testcommand2 = new SqlCommand(sql2, conn);
                            rdr = testcommand2.ExecuteReader();

                            while (rdr.Read())
                            {
                                test = rdr["NAME_Product"].ToString();

                            }
                            rdr.Close();

                            try
                            {
                                CultureInfo ci = new CultureInfo("th-TH");
                                string sql = "SELECT * FROM Order1 where ID_Product = '"+str1+"' AND DATE_Order BETWEEN '" + dateTimePicker1.Value.ToString("s") + "' AND '" + dateTimePicker2.Value.ToString("s") + "' ";
                                da = new SqlDataAdapter(sql, conn);
                                ds = new DataSet();
                                da.Fill(ds, "Order1");
                                chart1.DataSource = ds.Tables["Order1"];
                                chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
                                
                                chart1.Series.Add(test);
                                chart1.Series[test].ChartArea = "ChartArea1";
                                chart1.Series[test].BorderWidth = 4;
                                chart1.Series[test].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;                                
                                chart1.Series[test].YValueMembers += "QUANTITY_Order";
                                chart1.Series[test].XValueMember += "DATE_Order";

                                chart1.DataBind();
                                MessageBox.Show("test :" );
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("test :" + ex);
                            }
       
                        }
                        catch
                        {
                            MessageBox.Show("exception");
                        }



这是我的输出

http://image.ohozaa.com/view/80v2q]

如果我输错了单词,我感到非常抱歉,因为我的英语不好.

感谢您的回答



and this my output

http://image.ohozaa.com/view/80v2q]

i''m so sorry if i type a wrong word because my english is not good

Thank you for answer

推荐答案

在C#论坛中查看我对这个问题的回答:http://www.codeproject.com/Messages/4141515/Re-Question-about-Chart-in-Csharp.aspx [ ^ ]
See my answer to this question in the C# forum: http://www.codeproject.com/Messages/4141515/Re-Question-about-Chart-in-Csharp.aspx[^]


这篇关于关于图的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆