柱形图控件

柱形图控件   关键字  柱形图 asp.net2.0柱形图 柱形图控件 免费柱形图控件

asp.net制作柱形图有很多方法 使用GDI+也可以实现.这里我使用的是asp.net2.0的开源柱形图控件。

ZedGraph

我将 他的绘图事件封装成了一个类 这样就可以方便的调用了

None.gif using  System;
None.gif
using  System.Data;
None.gif
using  System.Configuration;
None.gif
using  System.Web;
None.gif
using  System.Web.Security;
None.gif
using  System.Web.UI;
None.gif
using  System.Web.UI.WebControls;
None.gif
using  System.Web.UI.WebControls.WebParts;
None.gif
using  System.Web.UI.HtmlControls;
None.gif
using  System.Collections;
None.gif
using  System.Drawing;
None.gif
using  ZedGraph;
None.gif
using  ZedGraph.Web;
None.gif
None.gif
public   class  mymap
ExpandedBlockStart.gifContractedBlock.gif    
dot.gif {
InBlock.gif      
public  string userame;
InBlock.gif      
public ArrayList _date;
InBlock.gif    
public mymap()
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        _date 
= new ArrayList();
InBlock.gif
InBlock.gif
ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif
ExpandedBlockEnd.gif    }

None.gif  
public   class  mydate
ExpandedBlockStart.gifContractedBlock.gif  
dot.gif {
InBlock.gif      
public double x1;
InBlock.gif      
public double x2;
InBlock.gif      
public double x3;
InBlock.gif      
public double x4;
InBlock.gif
InBlock.gif
InBlock.gif
ExpandedBlockEnd.gif  }

None.gif    
public   class  mygraph
ExpandedBlockStart.gifContractedBlock.gif    
dot.gif {
InBlock.gif
InBlock.gif
InBlock.gif
InBlock.gif        
public static void OnRenderGraph(ZedGraphWeb zgw, Graphics g, MasterPane masterPane,mymap m)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            GraphPane myPane 
= masterPane[0];
InBlock.gif
InBlock.gif            myPane.Title.Text 
= "员工业绩图:"+m.userame; //captaion
ExpandedSubBlockStart.gifContractedSubBlock.gif
            string[] labels2 = dot.gif"100""800""1000""2000" };
InBlock.gif            myPane.YAxis.MajorTic.IsBetweenLabels 
= true;
InBlock.gif            myPane.YAxis.Title.Text 
= "款额(万元)";
InBlock.gif            myPane.YAxis.Scale.Max
=30;
InBlock.gif            myPane.YAxis.Scale.Min 
= 0;
InBlock.gif          
InBlock.gif            myPane.YAxis.Type 
= AxisType.Exponent;
InBlock.gif            myPane.XAxis.Title.Text 
= "月业绩";
InBlock.gif            
//myPane.YAxis.Title.Text = "Gross Sales, $Thousands";
InBlock.gif

InBlock.gif            PointPairList list 
= new PointPairList();
InBlock.gif            PointPairList list2 
= new PointPairList();
InBlock.gif            PointPairList list3 
= new PointPairList();
InBlock.gif            PointPairList list4 
= new PointPairList();
InBlock.gif
InBlock.gif            Random rand 
= new Random();
InBlock.gif            
InBlock.gif            
for (double x = 0; x < 12; x +=1.0)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
double y = ((mydate)m._date[(int)x]).x1;
InBlock.gif                
double y2 = ((mydate)m._date[(int)x]).x2;
InBlock.gif                
double y3 = ((mydate)m._date[(int)x]).x3;
InBlock.gif                
double y4 = ((mydate)m._date[(int)x]).x4;
InBlock.gif
InBlock.gif                list.Add(x, y);
InBlock.gif                
InBlock.gif                list2.Add(x, y2);
InBlock.gif                list3.Add(x, y3);
InBlock.gif                list4.Add(x, y4);
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            BarItem myCurve 
= myPane.AddBar("计划回款", list, Color.Blue);
InBlock.gif            myCurve.Bar.Fill 
= new Fill(Color.Blue, Color.White, Color.Blue);
InBlock.gif            BarItem myCurve2 
= myPane.AddBar("实际回款", list2, Color.Red);
InBlock.gif            myCurve2.Bar.Fill 
= new Fill(Color.Red, Color.White, Color.Red);
InBlock.gif            BarItem myCurve3 
= myPane.AddBar("铺货款", list3, Color.Green);
InBlock.gif            myCurve3.Bar.Fill 
= new Fill(Color.Green, Color.White, Color.Green);
InBlock.gif            BarItem myCurve4 
= myPane.AddBar("任务额", list4, Color.Aqua);
InBlock.gif            myCurve4.Bar.Fill 
= new Fill(Color.Green, Color.White, Color.Aqua);
InBlock.gif
InBlock.gif            myPane.XAxis.MajorTic.IsBetweenLabels 
= true;
ExpandedSubBlockStart.gifContractedSubBlock.gif            
string[] labels = dot.gif"1月""2月""3月""4月""5月","6月","7月","8月","9月","10月","11月","12月" };
InBlock.gif            myPane.XAxis.Scale.TextLabels 
= labels;
InBlock.gif            myPane.XAxis.Type 
= AxisType.Text;
InBlock.gif        
InBlock.gif            myPane.Fill 
= new Fill(Color.White, Color.FromArgb(200100255), 45.0f);
InBlock.gif            myPane.Chart.Fill 
= new Fill(Color.White, Color.LightGoldenrodYellow, 45.0f);
InBlock.gif
InBlock.gif            masterPane.AxisChange(g);
InBlock.gif
ExpandedSubBlockEnd.gif        }

InBlock.gif        
ExpandedBlockEnd.gif    }

None.gif
None.gif

转载于:https://www.cnblogs.com/heavencloud/archive/2007/06/18/787045.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值