Skip to content

Documentation source code request #2

@rodryquintero

Description

@rodryquintero

Hello. This plugin is amazing. I was reading the source code and trying to understand the logic behind it, as I may need to make some modifications (or a different script altogether) to meet a very specific request from a customer.

I would like to know more about how you created the arrays for the rows and columns, as well as doing the arrays holding the data resulting from the column/row arrangements.

Here is an example.

 _generate_trees: function() {
         var node, i;
         var mask = (1 << this.fields.length) - 1;
         this.xtree = {
            childs: {}
         };
         this.ytree = {
            childs: {}
         };
         for (var k in this.indexes[mask]) {
            if (this.indexes[mask].hasOwnProperty(k)) {
               var mindex = this._idx2arr(k);

               node = this.xtree;

               for (i = 0; i < this.xfields.length; i++) {
                  if (typeof node.childs[mindex[this.xfields[i]]] === "undefined") {
                     node.childs[mindex[this.xfields[i]]] = {
                        childs: {}
                     };
                  }
                  node = node.childs[mindex[this.xfields[i]]];

               }

               node = this.ytree;

               for (i = 0; i < this.yfields.length; i++) {
                  if (typeof node.childs[mindex[this.yfields[i]]] === "undefined") {
                     node.childs[mindex[this.yfields[i]]] = {
                        childs: {}
                     };
                  }
                  node = node.childs[mindex[this.yfields[i]]];
               }
            }
         }
      }

I got lost trying to figure out the use of bitmasks for the array indices. Could you please document these parts of the source, or perhaps point me to some information that may help get a better understanding of the logic.

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions