日期:2014-05-20  浏览次数:20421 次

有人做过股票K线图没有?怎样在自己的网站实现股票K线图?
RT,我需要6支股票的股票K线图

------解决方案--------------------
UP一下 我也想知道呢
------解决方案--------------------
up
------解决方案--------------------
用activex控件可以实现,但是股票的数据不知道有没有提供web services的
------解决方案--------------------
呵呵,我刚做好个,不过比较简单的.
------解决方案--------------------
up
------解决方案--------------------
给你里面的两个函数吧,整体太麻烦了.
public void AppendLine(string colname, string linecolor, int marks)
{
//个股走势
int prevX = 0, prevY = 0;
int m = chartData.Rows.Count;
for (int i = 0; i < chartData.Rows.Count; i++)
{
DataRow ds = chartData.Rows[i];
string dsk = ds[colname].ToString();
int k = Convert.ToInt32((Convert.ToDouble(ds[colname])));
int tmpx = this.xMargin + i * chartWidth / xSpan;
int tmpy = this.chartHeight + this.yMargin - Convert.ToInt32((Convert.ToDouble(ds[colname]) - minVal) / (ySpan * 1.0 / chartHeight));
if (i > 0)
{
sb.Append( " <v:line style= 'position:absolute;left:0;text-align:left;top:0;z-index:1 ' from= ' " + prevX.ToString() + ", " + prevY.ToString() + " ' to= ' " + tmpx.ToString() + ", " + tmpy.ToString() + " ' ");
sb.Append( " strokecolor= ' " + linecolor + " ' strokeweight= 'thin '> ");
sb.Append( " </v:line> ");
}
DrawMarks(marks, tmpx, tmpy, ds);
prevX = tmpx;
prevY = tmpy;
}
}
private void DrawMarks(int marks, int xPos, int yPos,DataRow dr)
{
for (int i = 1; i < marks+1; i++)
{
string mark1 = dr[ "mark "+i.ToString()].ToString();
string mark1html = dr[ "mark "+i.ToString()+ "html "].ToString();
if (mark1 != " ")
{

sb.Append( " <v:shape id= '_x0000_s1025 ' type= '#_x0000_t202 ' alt= ' " + mark1 + " ' ");
sb.Append( "style= 'position:absolute;left: " + xPos.ToString() + ";top: " + yPos.ToString() + ";width:2000;height:2000;z-index:5 '> ");
sb.Append( " <v:textbox inset= '0,0,0,0 '> ");
sb.Append( " <table cellspacing= '0 ' cellpadding= '0 ' width= '100% ' height= '100% ' > ");
sb.Append( " <tr> <td align= 'left ' style= 'cursor:hand ' title= ' " + mark1 + " '> ");
sb.Append(mark1html + " </td> </tr> </table> ");
sb.Append( " </v:textbox> </v:shape> ");
yPos -= 2000;
}
else
{
break;
}
}
}
------解决方案--------------------
public void AppendLine(string colname, string linecolor, int marks)
{
//个股走势
int prevX = 0, prevY = 0;
int m = chartData.Rows.Count;