Teechart作图控件使用(data文件做数据源)

InBlock.gif 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) 
InBlock.gif                { 
InBlock.gif 
InBlock.gif                        MyChart.Height = heigth; 
InBlock.gif                        MyChart.Width = width; 
InBlock.gif                         string path_virtual = HttpRuntime.AppDomainAppVirtualPath; 
InBlock.gif                        MyChart.GetChartFile = path_virtual +  "/GetChart.aspx"
InBlock.gif                        MyChart.Chart.Axes.Left.AutomaticMinimum =  true
InBlock.gif                        MyChart.Chart.Axes.Left.Minimum = 0; 
InBlock.gif                         this.MyChart.Chart.Axes.Left.Grid.Color = Color.FromArgb(0x75, 0x75, 0x75);    
InBlock.gif                         if (chart_title.Contains( "局部")) 
InBlock.gif                        { 
InBlock.gif                                 this.MyChart.Chart.Header.Text = jufangComPlantArr(chart_title)[0]; 
InBlock.gif                        } 
InBlock.gif                         else 
InBlock.gif                        { 
InBlock.gif                                 this.MyChart.Chart.Header.Text = chart_title; 
InBlock.gif                        } 
InBlock.gif                         this.MyChart.Chart.Header.Transparent =  true
InBlock.gif                         this.MyChart.Chart.Header.Transparency = 100; 
InBlock.gif                         this.MyChart.Chart.Header.Shadow.Visible =  true
InBlock.gif                         this.MyChart.Chart.Header.Shadow.Transparency = 0; 
InBlock.gif                         this.MyChart.Chart.Legend.Visible = legend_visible; 
InBlock.gif                         this.MyChart.Chart.Legend.FontSeriesColor =  true
InBlock.gif                         this.MyChart.Chart.Legend.Color = Color.Black; 
InBlock.gif                         this.MyChart.Chart.Legend.LegendStyle = LegendStyles.Series; 
InBlock.gif                         this.MyChart.Chart.Legend.Shadow.Color = Color.DarkGray; 
InBlock.gif                         this.MyChart.TempChart = TempChartStyle.Httphandler; 
InBlock.gif                         this.MyChart.Chart.Walls.Visible =  true
InBlock.gif                         this.MyChart.Chart.Walls.Back.Height = 390; 
InBlock.gif                         this.MyChart.Chart.Walls.Back.Visible =  true
InBlock.gif                         this.MyChart.Chart.Walls.Back.Gradient.StartColor = Color.FromArgb(0x4f, 0x4e, 0x55); 
InBlock.gif                         this.MyChart.Chart.Walls.Back.Gradient.EndColor = Color.FromArgb(0x4f, 0x4e, 0x55); 
InBlock.gif                         this.MyChart.Chart.Walls.Back.Gradient.MiddleColor = Color.FromArgb(0x4f, 0x4e, 0x55); 
InBlock.gif 
InBlock.gif                } 
InBlock.gif 
InBlock.gif //方法 
InBlock.gif 
InBlock.gif     public  void draw(Table tb) 
InBlock.gif                { 
InBlock.gif                        MyChart =  new WebChart(); 
InBlock.gif                        MyChart.ID =  "chart1"
InBlock.gif                        InitializeChart(400, 700, System.Drawing.Color.FromArgb(254, 234, 234, 255), System.Drawing.Color.FromArgb(254, 234, 234, 255),  "ceshi"truefalsetrue); 
InBlock.gif                         List< float> list =  new List< float>(); 
InBlock.gif                         byte[] a =  null
InBlock.gif                         byte[] bt =  new  byte[4]; 
InBlock.gif                        FileStream fs =  new FileStream( "G:\\51pt\\09-12-22-16-51-04-1C.dat", FileMode.Open); 
InBlock.gif                        a =  new  byte[fs.Length]; 
InBlock.gif                        fs.Read(a, 0, a.Length); 
InBlock.gif                        fs.Close(); 
InBlock.gif                         int j = 0; 
InBlock.gif                         for ( int i = 0; i < a.Length; i++) 
InBlock.gif                        { 
InBlock.gif                                bt[j] =  byte.Parse(a[i].ToString()); 
InBlock.gif                                j++; 
InBlock.gif                                 if ((i + 1) % 4 == 0) 
InBlock.gif                                { 
InBlock.gif                                        j = (i + 1) % 4; 
InBlock.gif                                        Array.Reverse(bt); 
InBlock.gif                                         float f = BitConverter.ToSingle(bt, 0); 
InBlock.gif                                        list.Add(f); 
InBlock.gif                                } 
InBlock.gif                        } 
InBlock.gif                        Line l1 =  new Line();    
InBlock.gif                        MyChart.Chart.Series.Add(l1); 
InBlock.gif                         for ( int i = 0; i < list.Count; i++) 
InBlock.gif                        { 
InBlock.gif                                MyChart.Chart.Series[0].Add(Convert.ToDouble(i), Convert.ToDouble(list[i])); 
InBlock.gif                        } 
InBlock.gif                        TableRow tr =  new TableRow(); ; 
InBlock.gif                        TableCell tc =  new TableCell() ; 
InBlock.gif                        tc.Controls.Add(MyChart); 
InBlock.gif                        tr.Cells.Add(tc); 
InBlock.gif                        tb.Rows.Add(tr); 
InBlock.gif                } 
运行结果如下


本文转自 BruceAndLee 51CTO博客,原文链接:http://blog.51cto.com/leelei/308600,如需转载请自行联系原作者

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值