Skip to content

Understanding _initAttr  #4

Description

@samselikoff

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions