如何在C#中绘制烛台图表? [英] How Can I Draw Candlestick Chart In C# ?
本文介绍了如何在C#中绘制烛台图表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
i有一个表格,例如100条记录:id- name- open_price - close_price低价和高价 - 日期和......
i想要用它们画一个烛台图表。
i写这段代码从我的表中获取记录:
hi
i have a table with for example 100 record with : id- name- open_price - close_price low and high price - date and ...
i want draw a candlestick chart with them .
i write this code for get records from my table :
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=lenovo;Initial Catalog=getinfo;Integrated Security=True";
con.Open();
string sqlcmd = "select * from database ";
SqlCommand comm = new SqlCommand(sqlcmd, con);
SqlDataAdapter sdap = new SqlDataAdapter();
DataTable dt = new DataTable();
sdap.SelectCommand = comm;
sdap.Fill(dt);
for (int t = 0; t < dt.Rows.Count; t++)
{
??????? draw candlestick chart ??????
}
推荐答案
Web?赢得?两者都有一个图表控件,支持各种显示...
http://www.microsoft.com/en-us/download/details.aspx?id=14422 [ ^ ]
https://code.msdn.microsoft.com/Samples-Environments-for-b01e9c61 [ ^ ]
Web? Win? For both there is a Chart control that support all kinds of display...
http://www.microsoft.com/en-us/download/details.aspx?id=14422[^]
https://code.msdn.microsoft.com/Samples-Environments-for-b01e9c61[^]
此鳕鱼可以绘制烛台图表!我确实支付3
this cod can draw candlestick chart ! i did pay 3
给andrestand !! :-)
to andrestand it !! :-)
DataSet ds = new DataSet();
chart1 = new Chart();
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=xxxx;Initial Catalog=xxxx;Integrated Security=True";
con.Open();
string sql = "Select * from xxxx ";
SqlCommand cmd = new SqlCommand(sql, con);
cmd.CommandType = CommandType.Text;
SqlDataAdapter sa = new SqlDataAdapter();
sa.SelectCommand = cmd;
sa.Fill(ds);
con.Close();
chart1.Series["Daily"].ChartType = SeriesChartType.Candlestick;
chart1.DataSource = sa;
chart1.Series["Daily"].XValueMember = "Date";
chart1.Series["Daily"].YValueMembers = "ghbishtarin, ghkamtarin, ghopen, ghclose";
chart1.DataBind();
chart1.Series["Daily"].BorderColor = System.Drawing.Color.Black;
chart1.Series["Daily"].Color = System.Drawing.Color.Black;
chart1.Series["Daily"].CustomProperties = "PriceDownColor=Green, PriceUpColor=Red";
chart1.Series["Daily"].XValueType = ChartValueType.Date;
chart1.ChartAreas[0].AxisX.MajorGrid.LineWidth = 0;
chart1.ChartAreas[0].AxisY.MajorGrid.LineWidth = 0;
chart1.ChartAreas[0].AxisY.Minimum = 0;
chart1.ChartAreas[0].AxisY.Maximum = 210;
chart1.DataManipulator.IsStartFromFirst = true;
这篇关于如何在C#中绘制烛台图表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文