VML Chart 控件[3]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 lxx8402 的 blog

 ocontainer.appendchild(vline);

 this.axisx.ln = eval(this.width*10 - this.margin[0]) - this.margin[2] - 300;
 var vline = document.createelement("v:line");
 vline.id = "idcoordx";
 vline.from = this.margin[0] +","+ eval(this.height*10 - this.margin[3]);
 vline.to = eval(this.width*10 - this.margin[2]) +","+ eval(this.height*10 - this.margin[3]);
 vline.style.zindex = 8;
 vline.style.position = "absolute";
 vline.strokecolor = this.axisx.color
 vline.strokeweight = 1;

 var vstroke = document.createelement("v:stroke");
 vstroke.endarrow = "classic";

 vline.appendchild(vstroke);
 ocontainer.appendchild(vline); 
};

//画x轴刻度
_p.drawlinex = function(ocontainer){
 var totalpoint = this.seriescollection[0].all.length;
 var icol  = totalpoint + 1;
 var fcolwidth = math.floor(this.axisx.ln/icol);
 this.axisx.width= fcolwidth;
 var showpoint = this.axisx.showpoint,step = 1;
 if(totalpoint > showpoint) {
  if(totalpoint < showpoint*2)
   showpoint = math.round(3*showpoint/5);
  step = math.round(totalpoint/showpoint);
 }
 else showpoint = totalpoint;

 this.axisx.showpoint = showpoint;
 
 var newline, newstroke, newshape, newtext;
 var px,ln;
 var y = eval(this.height*10 - this.margin[3]);

 for(var i=1; i<=showpoint; i++){
  ln = i*step;
  if(ln>totalpoint) break;
  newline   = document.createelement("v:line");
  px    = this.margin[0] + (i-1)*fcolwidth * step;
  newline.from = px +","+ y;
  newline.to  = px +","+ eval(y + this.axisx.spacing);
  newline.style.zindex = 8;
  newline.style.position = "absolute";

  newstroke = document.createelement("<v:stroke color='"+ this.axisx.color +"'>");
  newline.appendchild(newstroke);

  ocontainer.appendchild(newline);

  newshape= document.createelement("<v:shape style='position:absolute;left:"+ eval(px-80) +";top:"+ eval(y+this.axisx.spacing) +";width:200px;height:150px;z-index:8' coordsize='21600,21600' fillcolor='white'></v:shape>");

  newtext = document.createelement("<v:textbox inset='0pt,0pt,0pt,0pt' style='font-size:12px;v-text-anchor:top-right-baseline;color:"+ this.axisy.color +"'></v:textbox>");
  
  
  newtext.innerhtml = this.seriescollection[0].all[ln-1].name;
  newshape.appendchild(newtext);

  ocontainer.appendchild(newshape);
 }
};

//画y轴刻度
_p.drawliney = function(ocontainer){
 var maxdata = this.maxs();
 maxdata  += (4 - maxdata % 4)
 var showpoint = this.axisy.showpoint;
 var dcs = 1;
 for(var i=showpoint; i>0; i--){
  if(maxdata % i == 0){
   dcs = i;
   this.axisy.showpoint = i;
   break;
  }
 }
 
 var newline, newstroke, newshape, newtext;
 var py;
 var x = this.margin[0];
 var frowheight = math.floor(this.axisy.ln/dcs);
 this.axisy.width = maxdata;  //y轴时存放最大值

 for(var i=0; i<=dcs; i++){
  py = eval(this.height*10 - this.margin[3]) - i*frowheight;
  if(i!=0){
   newline   = document.createelement("v:line");
   newline.from = eval(x-this.axisy.spacing) +","+ py;
   newline.to  = x +","+ py;
   newline.style.zindex = 8;
   newline.style.position = "absolute";

   newstroke = document.createelement("<v:stroke color='"+ this.axisy.color +"'>");
   newline.appendchild(newstroke);

   ocontainer.appendchild(newline);
  }

  newshape= document.createelement("<v:shape style='position:absolute;left:"+ eval(x-200) +";top:"+ eval(py-50) +";width:200px;height:150px;z-index:8' coordsize='21600,21600' fillcolor='white'></v:shape>");

  newtext = document.createelement("<v:textbox inset='0pt,0pt,0pt,0pt' style='font-size:12px;v-text-anchor:top-right-baseline;color:"+ this.axisy.color +"'></v:textbox>");
  
  
  newtext.innerhtml = i*(maxdata/dcs);
  newshape.appendchild(newtext);

  ocontainer.appendchild(newshape);  
 }
};

//画图例
_p.drawsmallseries=function(ocontainer){

本文关键:jascript vml chart 图形 图表
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top