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

Documentation source code request #2

Open
rodryquintero opened this issue Nov 5, 2014 · 0 comments
Open

Documentation source code request #2

rodryquintero opened this issue Nov 5, 2014 · 0 comments

Comments

@rodryquintero
Copy link

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.

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