js对象实例化

 var bar4 = new RGraph.Bar('cvs', [[21,31,13, 43,42, 25,42, 29,59, 28,40, 10]])
js对象实例化
 
如何实例化呢?
 
见下,如果不用this,不能为RGraph.Bar这个“类”添加属性,可以再调试的时候,发现这些属性是一个一个出现的
 
RGraph.Bar = function (id, data) { // Get the canvas and context objects
this.id = id;
this.canvas = document.getElementById(id);
this.context = this.canvas.getContext ? this.canvas.getContext("2d") : null;
this.canvas.__object__ = this;
this.type = 'bar';
this.max = 0;
this.stackedOrGrouped = false;
this.isRGraph = true;
this.uid = RGraph.CreateUID();
this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.CreateUID();
this.colorsParsed = false;
}
 
里面放入方法也是正常的
 
posted @ 2012-12-29 16:34  yunchong1019  阅读(1102)  评论(0编辑  收藏  举报