{"action":"created","issue":{"url":"https://api.github.com/repos/crossfilter/reductio/issues/40","repository_url":"https://api.github.com/repos/crossfilter/reductio","labels_url":"https://api.github.com/repos/crossfilter/reductio/issues/40/labels{/name}","comments_url":"https://api.github.com/repos/crossfilter/reductio/issues/40/comments","events_url":"https://api.github.com/repos/crossfilter/reductio/issues/40/events","html_url":"https://github.com/crossfilter/reductio/issues/40","id":159607691,"number":40,"title":"Top alias array errors when defining an alias (ex: 'group.top(1)[0].complete' is undefined)","user":{"login":"JasonBrannon","id":13629948,"avatar_url":"https://avatars.githubusercontent.com/u/13629948?v=3","gravatar_id":"","url":"https://api.github.com/users/JasonBrannon","html_url":"https://github.com/JasonBrannon","followers_url":"https://api.github.com/users/JasonBrannon/followers","following_url":"https://api.github.com/users/JasonBrannon/following{/other_user}","gists_url":"https://api.github.com/users/JasonBrannon/gists{/gist_id}","starred_url":"https://api.github.com/users/JasonBrannon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JasonBrannon/subscriptions","organizations_url":"https://api.github.com/users/JasonBrannon/orgs","repos_url":"https://api.github.com/users/JasonBrannon/repos","events_url":"https://api.github.com/users/JasonBrannon/events{/privacy}","received_events_url":"https://api.github.com/users/JasonBrannon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-10T10:40:13Z","updated_at":"2016-06-12T03:43:36Z","closed_at":null,"body":"Occurs when defining a reductio.alias(mapping) or reductio.aliasProp(mapping), Attempting to return the k records according to the natural order of the dimension by specifying the alias per the API reference. \r\n\r\n> On the group, we can then call the following function to retrieve the new count value.\r\n\r\n> `group.top(1)[0].newCount();`\r\n\r\n`//Sample Data\r\nvar data = [\r\n\t{\"type\":\"exe\",\"total\":24,\"handled\":0,\"nothandled\":24},\r\n\t{\"type\":\"exe\",\"total\":1,\"handled\":0,\"nothandled\":1},\r\n\t{\"type\":\"exe\",\"total\":1,\"handled\":0,\"nothandled\":1},\r\n\t{\"type\":\"exe\",\"total\":1,\"handled\":0,\"nothandled\":1},\r\n\t{\"type\":\"exe\",\"total\":1,\"handled\":0,\"nothandled\":1}\r\n]\r\n\r\n// Set crossfilter\r\nvar ndx = crossfilter(dirData);\r\n\r\n// Dimension\r\nvar dim = ndx.dimension(function(d) {return \"\" + d.type;});\r\n\r\n// Group            \r\nvar group = dim.group();\r\n\r\n// reductio.alias(mapping)\r\nvar reducer = reductio().count(true)\r\n\t.sum(function(d) { return +d.handled; })                 \r\n\t.aliasProp({\r\n\tnewCount: function(g) { return g.count; },\r\n\tcomplete: function(g) { return g.sum * 100 / g.count; }\r\n});      \r\nreducer(group);  //<-- WORKS\r\n\r\n// Optimal Result:\r\n//[object Object](1) = [\r\n//\t{\"key\":\"dir\",\"value\":{\"count\":5,\"sum\":28,\"newCount\":28,\"complete\":0}}\r\n//]\r\n\r\n\r\n//On the group, attempt to call the following to retrieve the complete value.\r\ngroup.top(1)[0].complete();  //<-- ERROR\r\n//group.top(1)[0]; //<-- works\r\n\r\n// Suboptimal Result:\r\n//TypeError: group.top(1)[0].complete is not a function. (In 'group.top(1)[0].complete()', 'group.top(1)[0].complete' is undefined)`\r\n"},"comment":{"url":"https://api.github.com/repos/crossfilter/reductio/issues/comments/225408328","html_url":"https://github.com/crossfilter/reductio/issues/40#issuecomment-225408328","issue_url":"https://api.github.com/repos/crossfilter/reductio/issues/40","id":225408328,"user":{"login":"esjewett","id":4822,"avatar_url":"https://avatars.githubusercontent.com/u/4822?v=3","gravatar_id":"","url":"https://api.github.com/users/esjewett","html_url":"https://github.com/esjewett","followers_url":"https://api.github.com/users/esjewett/followers","following_url":"https://api.github.com/users/esjewett/following{/other_user}","gists_url":"https://api.github.com/users/esjewett/gists{/gist_id}","starred_url":"https://api.github.com/users/esjewett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/esjewett/subscriptions","organizations_url":"https://api.github.com/users/esjewett/orgs","repos_url":"https://api.github.com/users/esjewett/repos","events_url":"https://api.github.com/users/esjewett/events{/privacy}","received_events_url":"https://api.github.com/users/esjewett/received_events","type":"User","site_admin":false},"created_at":"2016-06-12T03:43:36Z","updated_at":"2016-06-12T03:43:36Z","body":"Thanks for the report. What version of Reductio are you using? And can you let me know what `console.log(group.top(1)[0])` looks like?"}}
{"actor":{"display_login":"esjewett"}}