如何实现 搜狐或者腾讯网中的股票走势图??

解决方案 »

  1.   

    gdi能搞定吗?
    不懂帮你顶
      

  2.   

    不懂你的意思
    给你一段绘制折线图的代码吧        public Bitmap makeOneBmp(string flg)
            {
                string[] month = new string[12] { "0:00", "2:00", "4:00", "6:00", "8:00", "10:00", "12:00", "14:00", "16:00", "18:00", "20:00", "22:00" };
                float[] d;
                if ("1".Equals(flg))
                {
                    d = new float[12] { 40.5f, 60, 10.8f, 15.6f, 30, 70.9f, 50.3f, 30.7f, 70, 50.4f, 30.8f, 20 };
                }
                else
                {
                    float[] index = new float[12];
                    Random ro = new Random(50);
                    long tick = DateTime.Now.Ticks;
                    Random ran = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32));
                    for (int i = 0; i < 12; i++)
                    {
                        int iResult;
                        int iUp = 100;
                        int iDown = 50;
                        iResult = ran.Next(iDown, iUp);                    double dResult;
                        dResult = ran.NextDouble();                    index[i] = (float)(iResult + dResult);
                    }
                    //d = new float[12] { index[0], index[1], index[2], index[3], index[4], index[5], index[6], index[7], index[8], index[9], index[10], index[11] };
                    d = index;
                }            //画图初始化
                //Bitmap bmap=new Bitmap(500,500);
                Bitmap bmap = new Bitmap(800, 500);
                Graphics gph = Graphics.FromImage(bmap);
                gph.Clear(Color.White);            //PointF cpt=new PointF(40,420);//中心点
                PointF cpt = new PointF(40, 420);//中心点
                //PointF[] xpt = new PointF[3] { new PointF(cpt.Y + 15, cpt.Y), new PointF(cpt.Y, cpt.Y - 8), new PointF(cpt.Y, cpt.Y + 8) };//x轴三角形
                PointF[] xpt = new PointF[3] { new PointF(735, 520), new PointF(720, 520 - 8), new PointF(720, 520 + 8) };//x轴三角形
                PointF[] ypt = new PointF[3] { new PointF(cpt.X, cpt.X - 15), new PointF(cpt.X - 8, cpt.X), new PointF(cpt.X + 8, cpt.X) };//y轴三角形
                // gph.DrawString("某工厂某产品月生产量图表", new Font("宋体", 14), Brushes.Black, new PointF(cpt.X + 60, cpt.X));//图表标题
                //画x轴
                //gph.DrawLine(Pens.Black, cpt.X, cpt.Y, cpt.Y, cpt.Y);
                gph.DrawLine(Pens.Black, cpt.X, cpt.Y, 720, cpt.Y);
                gph.DrawPolygon(Pens.Black, xpt);
                gph.FillPolygon(new SolidBrush(Color.Black), xpt);
                gph.DrawString("月份", new Font("宋体", 12), Brushes.Black, new PointF(700 + 10, cpt.Y + 10));            //画y轴
                gph.DrawLine(Pens.Black, cpt.X, cpt.Y, cpt.X, cpt.X);
                gph.DrawPolygon(Pens.Black, ypt);
                gph.FillPolygon(new SolidBrush(Color.Black), ypt);
                gph.DrawString("单位(万)", new Font("宋体", 12), Brushes.Black, new PointF(0, 7));
                for (int i = 1; i <= 12; i++)
                {
                    //画y轴刻度
                    if (i < 11)
                    {
                        gph.DrawString((i * 10).ToString(), new Font("宋体", 11), Brushes.Black, new PointF(cpt.X - 30, cpt.Y - i * 30 - 6));
                        gph.DrawLine(Pens.Black, cpt.X - 3, cpt.Y - i * 30, cpt.X, cpt.Y - i * 30);
                    }                //画x轴项目
                    gph.DrawString(month[i - 1].Substring(0, 1), new Font("宋体", 11), Brushes.Black, new PointF(cpt.X + i * 30 - 5, cpt.Y + 5));
                    gph.DrawString(month[i - 1].Substring(1, 1), new Font("宋体", 11), Brushes.Black, new PointF(cpt.X + i * 30 - 5, cpt.Y + 20));
                    if (month[i - 1].Length > 2) gph.DrawString(month[i - 1].Substring(2, 1), new Font("宋体", 11), Brushes.Black, new PointF(cpt.X + i * 30 - 5, cpt.Y + 35));
                    //画点
                    gph.DrawEllipse(Pens.Black, cpt.X + i * 30 - 1.5f, cpt.Y - d[i - 1] * 3 - 1.5f, 3, 3);
                    gph.FillEllipse(new SolidBrush(Color.Black), cpt.X + i * 30 - 1.5f, cpt.Y - d[i - 1] * 3 - 1.5f, 3, 3);
                    //画数值
                    gph.DrawString(d[i - 1].ToString(), new Font("宋体", 11), Brushes.Black, new PointF(cpt.X + i * 30, cpt.Y - d[i - 1] * 3));
                    //画折线
                    if (i > 1) gph.DrawLine(Pens.Red, cpt.X + (i - 1) * 30, cpt.Y - d[i - 2] * 3, cpt.X + i * 30, cpt.Y - d[i - 1] * 3);
                }
                //保存输出图片
                //bmap.Save(Response.OutputStream, ImageFormat.Gif);            return bmap;
            }
      

  3.   

    就是要在网页上绘制股票的走势图,据说用什么 vml,可是我看腾讯网上的走势图好像是用flash图片哦
      

  4.   

    搜狐的股票走势图看起来是用flash来做的,请教高手怎么弄出来啊
      

  5.   

    VML 好东西,有机会可以去研究一下。
      

  6.   

    GDI+画图后以图片方式输出到网页中
    也可用VML直接以脚本方式在网页中画,能很好的与后台通信,但VML只有IE才支持...所以这玩意很少用...