I'm trying to understand the initAttr function:
function _initAttr(internalName, d3Name, defaultValue) {
if (!this.base.attr(d3Name)) {
this[internalName] = defaultValue;
this.base.attr(d3Name, defaultValue);
} else {
this[internalName] = this.base.attr(d3Name);
}
}
It seems like after you use it
// make sure container height and width are set.
_initAttr.call(this, "_width", "width", 200);
_initAttr.call(this, "_height", "height", 200);
these lines become unnecessary:
// setup some reasonable defaults
chart._width = chart.base.attr("width") || 200;
chart._height = chart.base.attr("height") || 200;
since in either case (svg width/height are already set, or they're not) the initAttr function is assigning a value to this._width and this._height. What am I missing?
I'm trying to understand the
initAttrfunction:It seems like after you use it
these lines become unnecessary:
since in either case (svg width/height are already set, or they're not) the
initAttrfunction is assigning a value to this._width and this._height. What am I missing?