现在的位置: 首页 > 综合 > 正文

gid+实现多种统计图 ,支持负坐标

2013年10月03日 ⁄ 综合 ⁄ 共 3410字 ⁄ 字号 评论关闭
using System;
using System.Web.UI;
using System.Data;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Web;
using System.ComponentModel;
using System.Collections ;

namespace EI.Control
{
    
/// <summary>
    
///    柱状图控件
    
///    需要传入列表项名,值,超级连接地址
    
/// </summary>

    [ToolboxData("<{0}:Columniation runat=server></{0}:Columniation>")]
    
public class Columniation: System.Web.UI.WebControls.WebControl
    
{  
        
private const int _colorLimit = 12;  //颜色列表
       private Color[] _color = 
            

                Color.Chocolate,
                Color.YellowGreen,
                Color.Olive,
                Color.DarkKhaki,
                Color.Sienna,
                Color.PaleGoldenrod,
                Color.Peru,
                Color.Tan,
                Color.Khaki,
                Color.DarkGoldenrod,
                Color.Maroon,
                Color.OliveDrab
            }
;

        
        
        
        
private DataTable items;//列表项名称和值
       

        
private string text="实时数据";
        
private string datastd="标准值";
        
private string data="实时数据";


        
int kds=10//刻度数
        float kddw=100;  //没刻度大小

        
int zmheight=500//真个图区高
        int zmwidth=740;  //真个图区宽

        
int height=400;//呈现区高
        int width=730;
        
int cxtop=30;//呈现区距顶距离
        int cxleft=30;//呈现区左边距离

        Color bzlink
=Color.Black;//标准线颜色
    

        
int Chart_Flag=1;
        Bitmap bm ;

        
int Displacement =0//获取负坐标刻度数

      
    

        [Bindable(
true),
        Category(
"Appearance"),
        DefaultValue(
"")]
        
public string Text
        
{
            
get
            
{
                
return text;
            }


            
set
            
{
                text 
= value;
            }

        }

        
        [Bindable(
true),
        Category(
"Appearance"),
        DefaultValue(
"")]
        
public string DataStdName
        
{
            
get
            
{
                
return datastd;
            }


            
set
            
{
                datastd 
= value;
            }

        }


        [Bindable(
true),
        Category(
"Appearance"),
        DefaultValue(
"")]
        
public string DataName
        
{
            
get
            
{
                
return data;
            }


            
set
            
{
                data 
= value;
            }

        }


        
/// <summary>
        
/// 需要呈现的数据
        
/// </summary>

        public DataTable Items
        
{
            
set
            
{items=value;}
        }


        
/// <summary>
        
/// 需要显示的刻度量
        
/// </summary>

        public int Kdcount
        
{
            
set {kds=value;}
        }


        
/// <summary>
        
/// 刻度大小
        
/// </summary>


        
public float Kddw
        
{set{kddw=value;}}
        


        
public int ChatStyle
        
{set{this.Chart_Flag=value;}}


        
/// <summary> 
        
/// 将此控件呈现给指定的输出参数。
        
/// </summary>
        
/// <param text="output"> 要写出到的 HTML 代码 </param>

        protected override void Render(HtmlTextWriter output)
        
{
            
//if(dt==null)
            
//{
            
//    return "没有数据";
            
//}
            
//设计样式
            kd(items);
            output.Write(makeimage(items,
"c:/"));

            
        }


        
private string makeimage(DataTable dt,string imagefile)
        
{
            

            
string url="";
        
            
switch(Chart_Flag)
            
{
                
case 1:
                

抱歉!评论已关闭.