C#和R.NET如何绘制列表框 [英] C# and R.NET How to plot the listbox

查看:63
本文介绍了C#和R.NET如何绘制列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试开发一个可以预测农产品价格的应用程序.

我已经在C#和MySql之间建立了连接. (实际上,我可以从MySql加载数据并将其保存在列表框中)
我还通过R.NET在C#和R之间建立了连接.
但是现在,为了执行一些统计分析和图表,我需要您的帮助来创建图表,方法是从列表框中加载两个值,或者直接从我的数据库中加载.
这两个值是我的数据库表中的Date,AnnualPrice.

Hi all,

I am trying to develop an application which will forecast prices of agricultural products.

I have made the connection between C# and MySql. (Actually i can load data from MySql and save them in a listbox)
I also have made the connection between C# and R through R.NET

but now, in order to perform some statistical analysis and charts i need your help to create a Chart by loading the two values from the listbox OR direct from my database.
The two values are Date,AnnualPrice in my db table.

string constring = "datasource=localhost;port=3306;username=root;password=;";//connect to server
            MySqlConnection conDataBase = new MySqlConnection(constring);
            MySqlCommand cmdDataBase = new MySqlCommand("Select Date,AnnualPrice from db_og.historicprices;", conDataBase);

try
            {
                conDataBase.Open();
                MySqlDataReader myReader = cmdDataBase.ExecuteReader();
                while (myReader.Read())
                {
                   
                    DataPrices DataPrice = new DataPrices();

                   

                    ListViewItem item = new ListViewItem(myReader["Date"].ToString());
                    item.SubItems.Add(myReader["AnnualPrice"].ToString());

                    listView1.Items.Add(item);
                    engine.SetSymbol("plot1", listView1);
                    engine.Evaluate("plot(item$Date, item$AnnualPrice)");
                }//end while   

            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);

            }

推荐答案

日期,项目


AnnualPrice)"); } // 结束 } 捕获(例外) { MessageBox.Show(ex.Message); }
AnnualPrice)"); }//end while } catch (Exception ex) { MessageBox.Show(ex.Message); }


这篇关于C#和R.NET如何绘制列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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