Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Understanding _initAttr #4

Open
samselikoff opened this issue Sep 30, 2013 · 0 comments
Open

Understanding _initAttr #4

samselikoff opened this issue Sep 30, 2013 · 0 comments

Comments

@samselikoff
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant