漂亮的饼图和柱状图

来源:互联网 发布:linux echo写入 编辑:程序博客网 时间:2024/04/30 12:28

补充要兼容FF,那就要改了:参考兼容网站:http://www.walterzorn.com/jsgraphics/jsgraphics_e.htm

 

要过年了,还是把这个没有研究好的东西总结一下吧!

在网上找到一个强人的VML做的漂亮的这些图,确实不错,但是一个页面放一个图确实可以,但我循环放多个图就不行了!我只好把里面的功能屏闭了一些,再加一点功能。才算是交了个差,但是没原来那个酷了!

主要是里面的VML那里不太熟!年后再看看吧

 代码:

1:一个reportcontrol的.dll,这里不能传文件,晕

2:应用代码:

这里面的arraylist这个对象是一个item 元素的数组

 public class Item
  {
   public Item(string text, int value)
   {
    this._text = text;
    this._value = value;
   }

   private string _text;
   public string Text
   {
    get
    {
     return _text;
    }
   }

   private int _value;
   public int Value
   {
    get
    {
     return _value;
    }
   }
  }

 

private void BindDL(string thisCom_id ,string thisType)
  {
   

   string F0F1Str = this.GetCom_select(thisCom_id,thisType);
   string F0Str = this.GetCom_select_F0_NO(F0F1Str);
   if(F0Str != "")
   {
    string[] arr = F0Str.Split(',');
    int height = 360;
    int top = 50;
    int j = 1;
    for(int i=0 ;i<arr.Length;i++)
    {
     if(arr[i].ToString() != "")
     {
      
      string SQL= "select * from Spec_info where F0001="+int.Parse(arr[i].ToString());
      SqlDataReader reader ;
      reader = SqlHelper.ExecuteReader(MyConfig.MyConfigSectionHandler.ConnectionString,CommandType.Text ,SQL);

      while(reader.Read())
      {//这里是要判断在 Spec_info 中设定的其它不正常情况
      }
      reader.Close();
      ArrayList arraylist = new ArrayList();
      arraylist.Add(new Item("异常人数",int.Parse(GetTypeCount(arr[i].ToString(),"异常",this.Com_id,thisType))));
      arraylist.Add(new Item("正常人数",int.Parse(GetTypeCount(arr[i].ToString(),"正常",this.Com_id,thisType))));
      arraylist.Add(new Item("未检人数",int.Parse(GetTypeCount(arr[i].ToString(),"未检",this.Com_id,thisType))));
      
      string panelID = "Panel"+j.ToString();
      
      Chart(panelID,"1",arraylist,height,600,50,top,"<a href='#' onclick='to("+arr[i].ToString()+")'>"+this.GetCate_Name(arr[i].ToString())+"</a>");
      
      top=top+height+10;
      j++;
      //break;
         //this.Panel1.Controls.Add(panel);
      //dr["people_name"] = GetPeople_Name(arr[i].ToString(),"异常",this.Com_id);
      
     }
    }
   }
   

  }

 


  private void Chart(string panel,string tag,ArrayList arraylist,int thisheight ,int thiswidth,int thisleft ,int thistop,string title)
  {
   WebChart chart = null;
   
   if (tag == "1")
   {
    chart = new PieChart();
    //chart.Unit_total = "800";
    chart.ScriptUrl = "../../Scripts/pieChart.js";
     
   }
   else
   {
    chart = new ColumnChart();
    //chart.Unit_total = "800";
    chart.ScriptUrl = "../../Scripts/columnChart.js";

   }
   chart.StyleFileUrl = "../../Scripts/WebChart.css"; 
   chart.ReportTitle=title;
   chart.DataSource = arraylist;
   chart.DataTextField = "Text";
   chart.DataValueField = "Value";
   chart.Width = thiswidth;
   chart.Height = thisheight;
   chart.Left = thisleft;
   chart.Top = thistop;
   chart.DataBind();
   //this.Panel1.Controls.Add(chart);
   System.Web.UI.WebControls.Panel pan =(Panel)Page.FindControl(panel);
   pan.Controls.Add(chart);
  }

 

 

大概差不多了

我主要是做医疗的YLwebC里面的 chart时用到,自己记得找

感谢网上的这两位强人

http://www.cnblogs.com/Infinity/archive/2007/08/13/340941.html   (这个是JS的)

 

http://www.cnblogs.com/jmtek/archive/2006/02/23/336073.html   (这个是写成了控件)