VML Chart 控件[1]

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

本文简介:选择自 lxx8402 的 blog

file: vmlgraph1_0_1.js

//------------------------------------------------------------
// copyright (c) 2003-2004 leadinsoft. all rights reserved.
// version 1.0.1
// ahthor dolphin
//------------------------------------------------------------
var bstsingle  = 0; //chart边框为单线
var bstdouble  = 1; //chart边框为双线
var fstsolid  = 0; //chart背景实心填充
var fsttexture  = 1; //chart背景材质填充
var fstregular  = "regular"  //字体:正常
var fstitalic  = "italic"; //字体:斜体
var fstbold   = "bold"; //字体:粗体
var atleft   = "left"; //chart标题左对齐
var atcenter  = "center"; //chart标题居中
var atright   = "right"; //chart标题右对齐

//定义 vml chart 基类
function graph(){
 this.text    = new text();
 this.border    = new border();
 this.width    = 500;
 this.height    = 300;
 this.fill    = new fill();
 this.legend    = new legend();
 this.seriescollection = [];
 this.container   = null;
 this.shadow    = false;
 this.vmlobject   = null;
};

//获取graph类的一个引用
var _p = graph.prototype;
//通过基类初始化chart
_p.initialise = function(){
 if(this.container == null) return;
 var o;
 //画外框
 var group = document.createelement("v:group");
 group.style.width = this.width+"pt";
 group.style.height = this.height+"pt";
 group.coordsize  = this.width*10 +"," + this.height*10;
 group.id   = "group1";

 //添加一个背景层
 var vrect = document.createelement("v:rect");
 vrect.style.width = (this.width*10-100) +"px";
 vrect.style.height = this.height*10+ "px";
 vrect.coordsize  = "21600,21600";

 group.appendchild(vrect);
 o = vrect;
 //设置边框大小
 vrect.strokeweight = this.border.width;
 //设置边框颜色
 vrect.strokecolor = this.border.color;
 
 //设置背景
 if(this.fill.style == fstsolid){
  vrect.fillcolor = this.fill.color;
 }
 else{
  if(this.fill.background != null)
   vrect.style.backgroundimage = this.fill.background;
  else
   vrect.fillcolor = this.fill.color;
 }
 //边框是否为双线
 if(this.border.style == bstdouble){
  var tmp = document.createelement("v:rect");
  tmp.style.width  = (this.width*10-300) +"px";
  tmp.style.height = (this.height*10-200)+ "px";
  tmp.style.top  = "100px";
  tmp.style.left  = "100px";
  tmp.strokecolor  = this.border.color;
  if(this.fill.style == fstsolid){
   tmp.fillcolor = this.fill.color;
  }
  else{
   if(this.fill.background != null)
    tmp.style.backgroundimage = this.fill.background;
   else
    tmp.fillcolor = this.fill.color;
  }
  var filltmp = document.createelement("v:fill");
  filltmp.type = "frame";
  tmp.appendchild(filltmp);
  group.appendchild(tmp);
  o = tmp;
 }

 //画标题
 var vcaption = document.createelement("v:textbox");
 vcaption.style.fontsize  = this.text.font.size +"px";
 vcaption.style.color  = this.text.font.color;
 vcaption.style.height  = this.text.height +"px";
 vcaption.style.fontweight = this.text.font.style;
 vcaption.innerhtml   = this.text.text;
 vcaption.style.textalign = this.text.alignment;

 o.appendchild(vcaption);

 //画阴影
 if(this.shadow){
  var vshadow = document.createelement("v:shadow");
  vshadow.on  = "t";
  vshadow.type = "single";
  vshadow.color = "graytext";
  vshadow.offset = "4px,4px";
  vrect.appendchild(vshadow);
 }
 
 this.vmlobject = group;
 this.container.appendchild(group);
};

//画具体图形
_p.draw = function(){
 alert("基类不能够实例化具体数据");
};

//增加序列
_p.addseries = function(o){
 var icount = this.seriescollection.length;
 if(o.title == null)
  o.title    = "series"+ icount;
 this.seriescollection[icount] = o;

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

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

go top