几个常用函数

8 篇文章 0 订阅

<script language="javascript">
function show(pie){
 pie.strokecolor=pie.fillcolor;
 pie.strokeweight=2;
}
function hide(pie){
 pie.strokecolor="white";
 pie.strokeweight=1;
}
function msg(pie){
  alert(pie.title);
//  window.location.href="qx1.asp?id=1"
}
</script>
<style>
.PIE_TEXT {
 BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 2px; FONT-SIZE: 11px; BACKGROUND: #ffffee; OVERFLOW: hidden; BORDER-LEFT: #cccccc 1px solid; ; WIDTH: expression(this.w = ((this.innerText.length>20)?100:(''))); PADDING-TOP: 2px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: Arial; WHITE-SPACE: nowrap; LETTER-SPACING: 1px; POSITION: absolute; TEXT-OVERFLOW: ellipsis;
</style>
<%
function PieChart(total,tb_color,table_x,table_y,all_width,all_height)
 tb_height=30
 total_no=ubound(total,1)
 totalpie=0
 for i=1 to total_no
  totalpie=totalpie+cint(total(i,1))
 next
 PreAngle=0
 for i=1 to total_no
   response.write "<v:shape title='分类:"&total(i,0)&"&#10;数量:"&total(i,1)&"&#10;百分比:"&formatnumber(cint(total(i,1))*100/totalpie,2,-1)&"%' οnmοuseοver='show(this)' οnmοuseοut='hide(this)' href='#' id='_x0000_s1025' alt='' style='position:absolute;cursor:hand;left:"&table_x&"px;top:"&table_y&"px;width:"&all_width&"px;height:"&all_height&"px;z-index:1' coordsize='1500,1400' o:spt='100' adj='0,,0' path='m750,700ae750,700,750,700,"&int(23592960*PreAngle)&","&int(23592960*cint(total(i,1))/totalpie)&"xe' fillcolor='"&tb_color(i,1)&"' strokecolor='#FFFFFF'><v:fill color2='"&tb_color(i,1)&"' rotate='t' focus='100%' type='gradient'/><v:stroke joinstyle='round'/><v:formulas/><v:path o:connecttype='segments'/></v:shape>"&CHr(13)
   PreAngle=PreAngle+cint(total(i,1))/totalpie
 next
 pie=3.14159265358979
 TempPie=0
 for i=1 to total_no
   TempAngle=pie*2*(cint(total(i,1))/(TotalPie*2)+TempPie)
   x1=table_x+all_width/2+cos(TempAngle)*all_width*3/8
   y1=table_y+all_height/2-sin(TempAngle)*all_height*3/8
   x2=table_x+all_width/2+cos(TempAngle)*all_width*3/4
   y2=table_y+all_height/2-sin(TempAngle)*all_height*3/4
   if x2>table_x+all_width/2 then
     x3=x2
     x4=x3
   else
     x3=x2-20
     x4=x3-60
   end if
   response.write "<v:line  id='_x0000_s1025' alt='' style='position:absolute;left:0;text-align:left;top:0;z-index:1' from='"&x1&"px,"&y1&"px' to='"&x2&"px,"&y2&"px' coordsize='21600,21600' strokecolor='"&tb_color(i,1)+"' strokeweight='1px'></v:line>"
   response.write "<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:"&x4&"px;top:"&y2-10&"px;width:110px;height:20px;z-index:1'>"
   response.write "<v:textbox class='PIE_TEXT' inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>"&formatnumber(cint(total(i,1))*100/totalpie,2,-1)&"% "&total(i,0)&"</td></tr></table></v:textbox></v:shape>"
   TempPie=TempPie+cint(total(i,1))/TotalPie
  ' response.write TempPie&"<br>"
 next
end function
function BarChart(total,tb_color,table_x,table_y,thickness,table_width,all_width,all_height)
'参数含义(传递的数组,颜色,横坐标,纵坐标,柱子的厚度,柱子的宽度,图表的宽度,图表的高度)
line_color="#69d"
left_width=30
length=thickness/2
total_no=ubound(total,1)
temp1=0
for i=1 to total_no
  totalnum=totalnum+cint(total(i,1))
next
for i=1 to total_no
 if temp1<cint(total(i,1)) then
  temp1=cint(total(i,1))
 end if
next
temp1=int(temp1)
if temp1>9 then
 temp2=mid(cstr(temp1),2,1)
 if temp2>4 then
  temp3=(int(temp1/(10^(len(cstr(temp1))-1)))+1)*10^(len(cstr(temp1))-1)
 else
  temp3=(int(temp1/(10^(len(cstr(temp1))-1)))+0.5)*10^(len(cstr(temp1))-1)
 end if
else
 if temp1>4 then
  temp3=10
 else
  temp3=5
 end if
end if
temp4=temp3
response.write "<!--[if gte vml 1]><v:rect id='_x0000_s1027' alt='' style='position:absolute;left:"&table_x+left_width&"px;top:"&table_y&"px;width:"&all_width&"px;height:"&all_height&"px;z-index:-1' fillcolor='#9cf' stroked='f'><v:fill rotate='t' angle='-45' focus='100%' type='gradient'/></v:rect><![endif]-->"  '背景色
response.write "<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='"&table_x+left_width&"px,"&table_y+all_height&"px' to='"&table_x+all_width+left_width&"px,"&table_y+all_height&"px'/><![endif]-->"  '底边
response.write "<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='"&table_x+left_width&"px,"&table_y&"px' to='"&table_x+left_width&"px,"&table_y+all_height&"px'/><![endif]-->" '垂直外边
response.write "<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='"&table_x+left_width+length&"px,"&table_y&"px' to='"&table_x+left_width+length&"px,"&table_y+all_height-length&"px' strokecolor='"&line_color&"'/><![endif]-->"
'  垂直里边
for i=0 to all_height-1 step all_height/5
response.write "<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='"&table_x+left_width&"px,"&table_y+all_height-length-i&"px' to='"&table_x+left_width+length&"px,"&table_y+all_height-i&"px' strokecolor='"&line_color&"'/><![endif]-->"
'垂直背景坐标线
response.write "<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='"&table_x+left_width+length&"px,"&table_y+all_height-length-i&"px' to='"&table_x+all_width+left_width&"px,"&table_y+all_height-length-i&"px' strokecolor='"&line_color&"'/><![endif]-->" '背景坐标线
response.write "<!--[if gte vml 1]><v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='"&table_x+(left_width-15)&"px,"&table_y+i&"px' to='"&table_x+left_width&"px,"&table_y+i&"px'/><![endif]-->"
'垂直坐标线
response.write "<!--[if gte vml 1]><v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:"&table_x&"px;top:"&table_y+i&"px;width:"&left_width&"px;height:18px;z-index:1'>"
response.write "<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='right'>"&temp4&"</td></tr></table></v:textbox></v:shape><![endif]-->"
'纵坐标说明
temp4=temp4-temp3/5
next
table_space=(all_width-table_width*total_no)/total_no
for i=1 to total_no
temp_space=table_x+left_width+table_space*(i-1/2)+table_width*(i-1)
response.write "<v:rect id='_x0000_s1025' title='类别:"&total(i,0)&"&#10;数量:"&total(i,1)&"&#10;百分比:"&formatnumber(cint(total(i,1))*100/totalnum,2,-1)&"%' style='position:absolute;left:"
response.write temp_space
response.write "px;top:"
response.write table_y+all_height*(1-(cint(total(i,1))/temp3))
response.write "px;width:"&table_width&"px;height:"&all_height*(cint(total(i,1))/temp3)&"px;z-index:1' fillcolor='"&tb_color(i,1)&"'>"
response.write "<v:fill color2='"&tb_color(i,1)&"' rotate='t' type='gradient'/>"
response.write "<o:extrusion v:ext='view' backdepth='"&thickness&"pt' color='"&tb_color(i,1)&"' on='t'/>"
response.write "</v:rect>"
'住状条
response.write "<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:"&temp_space-table_space/2&"px;top:"&table_y+all_height+1&"px;width:"&table_space+table_width&"px;height:18px;z-index:1'>"
response.write "<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='center'>"&total(i,0)&"</td></tr></table></v:textbox></v:shape>"  '横坐标说明
next
end function
function LineChart(total,table_x,table_y,all_width,all_height)
'参数含义(传递的数组,横坐标,纵坐标,图表的宽度,图表的高度,折线条数)
line_color="#69f"
left_width=70
total_no=ubound(total,1)
temp1=0
for i=1 to total_no
  if temp1<total(i,1) then temp1=total(i,1)
next
temp1=int(temp1)
if temp1>9 then
 temp2=mid(cstr(temp1),2,1)
 if temp2>4 then
  temp3=(int(temp1/(10^(len(cstr(temp1))-1)))+1)*10^(len(cstr(temp1))-1)
 else
  temp3=(int(temp1/(10^(len(cstr(temp1))-1)))+0.5)*10^(len(cstr(temp1))-1)
 end if
else
 if temp1>4 then temp3=10 else temp3=5
end if
temp4=temp3
response.write "<v:rect id='_x0000_s1027' alt='' style='position:absolute;left:"&table_x+left_width&"px;top:"&table_y&"px;width:"&all_width&"px;height:"&all_height&"px;z-index:-1' fillcolor='#9cf' stroked='f'><v:fill rotate='t' angle='-45' focus='100%' type='gradient'/></v:rect>"'背景
for i=0 to all_height step all_height/5
 response.write "<v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='"&table_x+left_width+length&"px,"&table_y+all_height-length-i&"px' to='"&table_x+all_width+left_width&"px,"&table_y+all_height-length-i&"px' strokecolor='"&line_color&"'/>"'背景线
 response.write "<v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='"&table_x+(left_width-15)&"px,"&table_y+i&"px' to='"&table_x+left_width&"px,"&table_y+i&"px'/>"
 response.write ""
 response.write "<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:"&table_x&"px;top:"&table_y+i&"px;width:"&left_width&"px;height:18px;z-index:1'>"
 response.write "<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='right'>"&temp4&"</td></tr></table></v:textbox></v:shape>"
 temp4=temp4-temp3/5
next
response.write "<v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='"&table_x+left_width&"px,"&table_y+all_height&"px' to='"&table_x+all_width+left_width&"px,"&table_y+all_height&"px'><v:stroke endarrow='block'/></v:line>"'横坐标线
response.write "<v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='"&table_x+left_width&"px,"&table_y&"px' to='"&table_x+left_width&"px,"&table_y+all_height&"px'><v:stroke endarrow='block'/></v:line>"'纵坐标线
 response.write "<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:"&table_x+left_width-50&"px;top:"&table_y-20&"px;width:100px;height:18px;z-index:1'>"
 response.write "<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='center'>纵坐标</td></tr></table></v:textbox></v:shape>"
 response.write "<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:"&table_x+left_width+all_width&"px;top:"&table_y+all_height-9&"px;width:100px;height:18px;z-index:1'>"
 response.write "<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>横坐标</td></tr></table></v:textbox></v:shape>"
 for i=1 to total_no-1
   x1=table_x+left_width+all_width*(i-1)/total_no
   y1=table_y+(temp3-total(i,1))*(all_height/(temp3))
   x2=table_x+left_width+all_width*i/total_no
   y2=table_y+(temp3-total(i+1,1))*(all_height/(temp3))
   response.write "<v:line id=""_x0000_s1025"" alt="""" style='position:absolute;left:0;text-align:left;top:0;z-index:1' from="""&x1&"px,"&y1&"px"" to="""&x2&"px,"&y2&"px"" coordsize=""21600,21600"" strokecolor=""red"" strokeweight=""1"">"
  response.write "</v:line>"&CHR(13)
  response.write "<v:oval id=""_x0000_s1026"" style='position:absolute;left:"&x2-2&"px;top:"&y2-2&"px;width:4px;height:4px;z-index:1' fillcolor=""green"" strokecolor=""green""/>"&CHR(13)
  response.write "<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:"&x1&"px;top:"&y1-15&"px;width:60px;height:18px;z-index:1'><v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>"&formatnumber(total(i,1))&"</td></tr></table></v:textbox></v:shape>"
next
response.write "<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:"&table_x+left_width+all_width*(total_no-1)/total_no&"px;top:"&table_y+(temp3-total(total_no,1))*(all_height/(temp3))-15&"px;width:60px;height:18px;z-index:1'><v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>"&formatnumber(total(total_no,1))&"</td></tr></table></v:textbox></v:shape>" 
for i=1 to total_no
 response.write "<v:line id='_x0000_s1027' alt='' style='position:absolute;left:0;text-align:left;top:0;flip:y;z-index:-1' from='"&table_x+left_width+all_width*(i-1)/total_no&"px,"&table_y+all_height&"px' to='"&table_x+left_width+all_width*(i-1)/total_no&"px,"&table_y+all_height+15&"px'/>"
 response.write "<v:shape id='_x0000_s1025' type='#_x0000_t202' alt='' style='position:absolute;left:"&table_x+left_width+all_width*(i-1)/total_no&"px;top:"&table_y+all_height&"px;width:"&all_width/total_no&"px;height:18px;z-index:1'>"
 response.write "<v:textbox inset='0px,0px,0px,0px'><table cellspacing='3' cellpadding='0' width='100%' height='100%'><tr><td align='left'>"&total(i,0)&"</td></tr></table></v:textbox></v:shape>"
next
end function
%>
DataGrid
<PUBLIC:COMPONENT>
<PUBLIC:ATTACH EVENT="oncontentready"   ONEVENT="fnInit()"   />
<PUBLIC:ATTACH EVENT="onclick"   ONEVENT="fnClick()"   />
<METHOD NAME="menubarpush"/>
<SCRIPT LANGUAGE="JScript">
//window.onerror = function fnNoOp() {return true; };
function fnInit() {
 element.border = 0;
 element.cellSpacing = 0;
 element.cellPadding = 0;
// element.style.tableLayout = "fixed";

 element.style.borderLeft="1px solid ThreeDDarkShadow";
 element.style.borderTop="1px solid ThreeDDarkShadow";
 element.style.borderRight="1px solid black";
 element.style.borderBottom="1px solid black";

 for(var i=0;i<element.rows.length;i++)
 {
  var _tr = element.rows[i];
  for(var j=0;j<_tr.cells.length;j++)
  {
   var _td = _tr.cells(j);
   _td.noWrap = true;
   if(i==0)
   {
    var _div = window.document.createElement("div");
    _div.style.borderLeft = "1px solid ButtonHighlight";
    _div.style.borderTop = "1px solid ButtonHighlight";
    _div.style.borderRight = "1px solid ButtonShadow";
    _div.style.borderBottom = "1px solid ButtonShadow";
    _div.style.backgroundColor = "ButtonFace";
    _div.style.width = "100%";
    _div.style.height = "100%";
    _div.innerHTML = _td.innerHTML;
    _td.innerHTML = "";
    _td.appendChild(_div);
    _td.style.borderRight = "1px solid black";
    _td.style.borderBottom = "1px solid black";
    _td.align = "center";
    /**/
    _tr.attachEvent("onmousedown", fnMousedown);
    _tr.attachEvent("onmousemove",fnMousemove);
    _tr.attachEvent("onmouseover",fnMouseover);
    _tr.attachEvent("onselectstart",fnCancel);
    window.document.attachEvent("onmouseup", fnMouseup);
    window.document.attachEvent("onmousemove",fnMouseMove);
   }
   else{
    _td.style.borderRight = "1px solid #000000";
    _td.style.borderBottom = "1px solid #000000";
    _td.style.height = 18;
   }
  }
//  _td = _tr.insertCell(0);
//  var _div = window.document.createElement("div");
//  _div.style.borderLeft = "1px solid ButtonHighlight";
//  _div.style.borderTop = "1px solid ButtonHighlight";
//  _div.style.borderRight = "1px solid ButtonShadow";
//  _div.style.borderBottom = "1px solid ButtonShadow";
//  _div.style.backgroundColor = "ButtonFace";
//  _div.style.width = "100%";
//  _div.style.height = "100%";
//  _div.innerHTML = "&nbsp;&nbsp;";
//  _td.appendChild(_div);
//  _td.style.borderRight = "1px solid black";
//  _td.style.borderBottom = "1px solid black";
 }
 var _line = window.document.createElement("DIV");
 _line.style.position = "absolute";
 _line.style.backgroundColor="#000000";
 _line.style.width=1;
 window.document.body.appendChild(_line);
 element.myline = _line;
 element.myline.style.display = "none";
}
function fnMouseover(){
 return;
}
function fnMouseMove(){
 if(!element.splitlocked) return;
 fnMousemove();  
}
function fnMousemove(){
 var oEl = event.srcElement;
 element.myline.style.left = window.event.x;
 element.myline.style.top = getTop(element);
 element.myline.style.height = element.parentElement.clientHeight;
 if(element.splitlocked) return;
 if(!IfSplitLocation(oEl)) return;
}
function fnClick(){
 var oEl = event.srcElement;
}
function fnMousedown(){
 var oEl = event.srcElement;
 if(!IfSplitLocation(oEl)) return;
 element.myline.style.display = "";
 element.splitlocked  = true;
 window.document.attachEvent("onselectstart",fnCancel);
}
function fnMouseup()
{
 element.myline.style.display = "none";
 element.splitlocked  = false;
 element.document.body.style.cursor='default';
 if(element.curResizeTD == null) return;
 var otd = element.curResizeTD;
 var otdLeft = getLeft(otd);
 var otdwidth =  element.myline.style.pixelLeft - otdLeft
 if(otdwidth < 0) return;
 otd.style.width = otdwidth;
 window.document.detachEvent("onselectstart",fnCancel);
}
function IfSplitLocation(oEl)
{
 if(oEl.tagName == "DIV")
  oEl = oEl.parentElement;
 if(oEl.tagName == "TD")
 {
  if(Math.abs(event.offsetX - oEl.clientWidth) <= 5)
  {
   element.curResizeTD = oEl;
   element.document.body.style.cursor='col-resize';
  }
  else if (Math.abs(event.offsetX) <= 5 && oEl.cellIndex>0){
   if(oEl.cellIndex>0){
    element.curResizeTD = oEl.parentElement.cells(oEl.cellIndex-1);
    element.document.body.style.cursor='col-resize';
   }
  }
  else{
   element.curResizeTD = null;
   element.document.body.style.cursor='default';
   return false;
  }
 }
 return true;
}
function getTop(e){
 var t=e.offsetTop;
 while(e=e.offsetParent){
  t+=e.offsetTop;
  }
 return t;
}
function getLeft(e){
 var l=e.offsetLeft;
 while(e=e.offsetParent){
  l+=e.offsetLeft;
  }
 return l;
}
/*****************************************************
禁止拖动
*****************************************************/
function fnCancel(){
  window.event.returnValue = false;
  return false;
}
</SCRIPT>
</PUBLIC:COMPONENT>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值