private void InitializeChart( int heigth, int width, Color back_color_start, Color back_color_end, string chart_title, bool legend_visible, bool is_3d, bool isDate)
                {

                        MyChart.Height = heigth;
                        MyChart.Width = width;
                         string path_virtual = HttpRuntime.AppDomainAppVirtualPath;
                        MyChart.GetChartFile = path_virtual + "/GetChart.aspx";
                        MyChart.Chart.Axes.Left.AutomaticMinimum = true;
                        MyChart.Chart.Axes.Left.Minimum = 0;
                         this.MyChart.Chart.Axes.Left.Grid.Color = Color.FromArgb(0x75, 0x75, 0x75);    
                         if (chart_title.Contains( "局部"))
                        {
                                 this.MyChart.Chart.Header.Text = jufangComPlantArr(chart_title)[0];
                        }
                         else
                        {
                                 this.MyChart.Chart.Header.Text = chart_title;
                        }
                         this.MyChart.Chart.Header.Transparent = true;
                         this.MyChart.Chart.Header.Transparency = 100;
                         this.MyChart.Chart.Header.Shadow.Visible = true;
                         this.MyChart.Chart.Header.Shadow.Transparency = 0;
                         this.MyChart.Chart.Legend.Visible = legend_visible;
                         this.MyChart.Chart.Legend.FontSeriesColor = true;
                         this.MyChart.Chart.Legend.Color = Color.Black;
                         this.MyChart.Chart.Legend.LegendStyle = LegendStyles.Series;
                         this.MyChart.Chart.Legend.Shadow.Color = Color.DarkGray;
                         this.MyChart.TempChart = TempChartStyle.Httphandler;
                         this.MyChart.Chart.Walls.Visible = true;
                         this.MyChart.Chart.Walls.Back.Height = 390;
                         this.MyChart.Chart.Walls.Back.Visible = true;
                         this.MyChart.Chart.Walls.Back.Gradient.StartColor = Color.FromArgb(0x4f, 0x4e, 0x55);
                         this.MyChart.Chart.Walls.Back.Gradient.EndColor = Color.FromArgb(0x4f, 0x4e, 0x55);
                         this.MyChart.Chart.Walls.Back.Gradient.MiddleColor = Color.FromArgb(0x4f, 0x4e, 0x55);

                }

//方法

     public void draw(Table tb)
                {
                        MyChart = new WebChart();
                        MyChart.ID = "chart1";
                        InitializeChart(400, 700, System.Drawing.Color.FromArgb(254, 234, 234, 255), System.Drawing.Color.FromArgb(254, 234, 234, 255), "ceshi", true, false, true);
                         List< float> list = new List< float>();
                         byte[] a = null;
                         byte[] bt = new byte[4];
                        FileStream fs = new FileStream( "G:\\51pt\\09-12-22-16-51-04-1C.dat", FileMode.Open);
                        a = new byte[fs.Length];
                        fs.Read(a, 0, a.Length);
                        fs.Close();
                         int j = 0;
                         for ( int i = 0; i < a.Length; i++)
                        {
                                bt[j] = byte.Parse(a[i].ToString());
                                j++;
                                 if ((i + 1) % 4 == 0)
                                {
                                        j = (i + 1) % 4;
                                        Array.Reverse(bt);
                                         float f = BitConverter.ToSingle(bt, 0);
                                        list.Add(f);
                                }
                        }
                        Line l1 = new Line();    
                        MyChart.Chart.Series.Add(l1);
                         for ( int i = 0; i < list.Count; i++)
                        {
                                MyChart.Chart.Series[0].Add(Convert.ToDouble(i), Convert.ToDouble(list[i]));
                        }
                        TableRow tr = new TableRow(); ;
                        TableCell tc = new TableCell() ;
                        tc.Controls.Add(MyChart);
                        tr.Cells.Add(tc);
                        tb.Rows.Add(tr);
                }
运行结果如下
Teechart作图控件使用(data文件做数据源)_第1张图片