var plot; if(!kwArgs || !("type" in kwArgs)){ plot = new dc.plot2d.Default(this, kwArgs); }else{ plot = typeof kwArgs.type == "string" ? new dc.plot2d[kwArgs.type](this, kwArgs) : new kwArgs.type(this, kwArgs); } plot.name = name; plot.dirty = true; if(name in this.plots){ this.stack[this.plots[name]].destroy(); this.stack[this.plots[name]] = plot; }else{ this.plots[name] = this.stack.length; this.stack.push(plot); } this.dirty = true; return this;