问题描述
目前手上已经有行情分析软件。现在需要做个渤商所现货交易的走势分析图,嵌入到网页,进行显示。
解决方案
解决方案二:
如果你有接口的话,自己开发一个ActiveX签入到页面里面显示。
解决方案三:
privatevoidCreateImage(intID){//定义画布大小intheight=440,width=600;System.Drawing.Bitmapimage=newSystem.Drawing.Bitmap(width,height);//创建Graphics类对象Graphicsg=Graphics.FromImage(image);try{//清空图片背景色g.Clear(Color.White);Fontfont=newSystem.Drawing.Font("Arial",9,FontStyle.Regular);Fontfont1=newSystem.Drawing.Font("宋体",20,FontStyle.Regular);Fontfont2=newSystem.Drawing.Font("Arial",8,FontStyle.Regular);System.Drawing.Drawing2D.LinearGradientBrushbrush=newSystem.Drawing.Drawing2D.LinearGradientBrush(newRectangle(0,0,image.Width,image.Height),Color.Blue,Color.Blue,1.2f,true);g.FillRectangle(Brushes.AliceBlue,0,0,width,height);Brushbrush1=newSolidBrush(Color.Blue);Brushbrush2=newSolidBrush(Color.SaddleBrown);stringstr="SELECT*FROMtb_StockWHEREShowYear="+Request["ID"]+"";SqlConnectionCon=newSqlConnection(ConfigurationManager.AppSettings["ConSql"]);Con.Open();SqlCommandCom=newSqlCommand(str,Con);SqlDataReaderdr=Com.ExecuteReader();dr.Read();if(dr.HasRows){g.DrawString(""+ID+"年彩虹A、B股票走势图",font1,brush1,newPointF(130,30));}dr.Close();//画图片的边框线g.DrawRectangle(newPen(Color.Blue),0,0,image.Width-1,image.Height-1);Penmypen=newPen(brush,1);Penmypen2=newPen(Color.Red,2);//绘制线条//绘制纵向线条intx=60;for(inti=0;i<12;i++){g.DrawLine(mypen,x,80,x,340);x=x+40;}Penmypen1=newPen(Color.Blue,2);g.DrawLine(mypen1,x-480,80,x-480,340);//绘制横向线条inty=106;for(inti=0;i<9;i++){g.DrawLine(mypen,60,y,540,y);y=y+26;}g.DrawLine(mypen1,60,y,540,y);//x轴String[]n={"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"};x=35;for(inti=0;i<12;i++){g.DrawString(n[i].ToString(),font,Brushes.Red,x,348);//设置文字内容及输出位置x=x+40;}//y轴String[]m={"900点","800点","700点","600点","500点","400点","300点","200点","100点"};y=100;for(inti=0;i<9;i++){g.DrawString(m[i].ToString(),font,Brushes.Red,10,y);//设置文字内容及输出位置y=y+26;}int[]Count1=newint[12];int[]Count2=newint[12];string[]NumChr=newstring[12];stringcmdtxt2="SELECT*FROMtb_StockWHEREShowYear="+ID+"";SqlCommandCom1=newSqlCommand(cmdtxt2,Con);SqlDataAdapterda=newSqlDataAdapter();da.SelectCommand=Com1;DataSetds=newDataSet();da.Fill(ds);intj=0;for(inti=0;i<12;i++){NumChr[i]=ds.Tables[0].Rows[0][i+1].ToString();}for(j=0;j<12;j++){Count1[j]=Convert.ToInt32(NumChr[j].Split('|')[0].ToString())*26/100;}for(intk=0;k<12;k++){Count2[k]=Convert.ToInt32(NumChr[k].Split('|')[1].ToString())*26/100;}//显示折线效果SolidBrushmybrush=newSolidBrush(Color.Red);Point[]points1=newPoint[12];points1[0].X=60;points1[0].Y=340-Count1[0];points1[1].X=100;points1[1].Y=340-Count1[1];points1[2].X=140;points1[2].Y=340-Count1[2];points1[3].X=180;points1[3].Y=340-Count1[3];points1[4].X=220;points1[4].Y=340-Count1[4];points1[5].X=260;points1[5].Y=340-Count1[5];points1[6].X=300;points1[6].Y=340-Count1[6];points1[7].X=340;points1[7].Y=340-Count1[7];points1[8].X=380;points1[8].Y=340-Count1[8];points1[9].X=420;points1[9].Y=340-Count1[9];points1[10].X=460;points1[10].Y=340-Count1[10];points1[11].X=500;points1[11].Y=340-Count1[11];g.DrawLines(mypen2,points1);//绘制折线//绘制节点的具体值(从数据库中获取指定值)intax=61;Fontsfont1=newSystem.Drawing.Font("Arial",9,FontStyle.Regular);for(intamr=0;amr<12;amr++){PointFpitf1=newPointF(ax,341-Count1[amr]);g.DrawString(NumChr[amr].Split('|')[0].ToString(),sfont1,Brushes.Black,pitf1);ax=ax+40;}Penmypen3=newPen(Color.Black,2);Point[]points2=newPoint[12];points2[0].X=60;points2[0].Y=340-Count2[0];points2[1].X=100;points2[1].Y=340-Count2[1];points2[2].X=140;points2[2].Y=340-Count2[2];points2[3].X=180;points2[3].Y=340-Count2[3];points2[4].X=220;points2[4].Y=340-Count2[4];points2[5].X=260;points2[5].Y=340-Count2[5];points2[6].X=300;points2[6].Y=340-Count2[6];points2[7].X=340;points2[7].Y=340-Count2[7];points2[8].X=380;points2[8].Y=340-Count2[8];points2[9].X=420;points2[9].Y=340-Count2[9];points2[10].X=460;points2[10].Y=340-Count2[10];points2[11].X=500;points2[11].Y=340-Count2[11];g.DrawLines(mypen3,points2);//绘制折线intbx=61;Fontsfont2=newSystem.Drawing.Font("Arial",9,FontStyle.Regular);for(intbmr=0;bmr<12;bmr++){PointFpitf2=newPointF(bx,341-Count2[bmr]);g.DrawString(NumChr[bmr].Split('|')[1].ToString(),sfont2,Brushes.Red,pitf2);bx=bx+40;}//绘制标识g.DrawRectangle(newPen(Brushes.Red),150,370,250,50);//绘制范围框g.FillRectangle(Brushes.Red,250,380,20,10);//绘制小矩形g.DrawString("彩虹A股",font2,Brushes.Red,270,380);g.FillRectangle(Brushes.Black,250,400,20,10);g.DrawString("彩虹B股",font2,Brushes.Black,270,400);//类型输出并显示图片到页面中System.IO.MemoryStreamms=newSystem.IO.MemoryStream();image.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);Response.ClearContent();Response.ContentType="image/Gif";Response.BinaryWrite(ms.ToArray());}