{"action":"created","comment":{"url":"https://api.github.com/repos/plotly/plotly.js/pulls/comments/131024986","pull_request_review_id":53963585,"id":131024986,"diff_hunk":"@@ -0,0 +1,283 @@\n+/**\n+* Copyright 2012-2017, Plotly, Inc.\n+* All rights reserved.\n+*\n+* This source code is licensed under the MIT license found in the\n+* LICENSE file in the root directory of this source tree.\n+*/\n+\n+'use strict';\n+\n+var Axes = require('../plots/cartesian/axes');\n+var Lib = require('../lib');\n+var PlotSchema = require('../plot_api/plot_schema');\n+var BADNUM = require('../constants/numerical').BADNUM;\n+\n+exports.moduleType = 'transform';\n+\n+exports.name = 'aggregate';\n+\n+var attrs = exports.attributes = {\n+    enabled: {\n+        valType: 'boolean',\n+        dflt: true,\n+        description: [\n+            'Determines whether this aggregate transform is enabled or disabled.'\n+        ].join(' ')\n+    },\n+    groups: {\n+        // TODO: groupby should support string or array grouping this way too\n+        // currently groupby only allows a grouping array\n+        valType: 'string',\n+        strict: true,\n+        noBlank: true,\n+        arrayOk: true,\n+        dflt: 'x',\n+        description: [\n+            'Sets the grouping target to which the aggregation is applied.',\n+            'Data points with matching group values will be coalesced into',\n+            'one point, using the supplied aggregation functions to reduce data',\n+            'in other data arrays.',\n+            'If a string, *groups* is assumed to be a reference to a data array',\n+            'in the parent trace object.',\n+            'To aggregate by nested variables, use *.* to access them.',\n+            'For example, set `groups` to *marker.color* to aggregate',\n+            'about the marker color array.',\n+            'If an array, *groups* is itself the data array by which we aggregate.'\n+        ].join(' ')\n+    },\n+    aggregations: {\n+        _isLinkedToArray: 'style',\n+        array: {","path":"src/transforms/aggregate.js","position":null,"original_position":51,"commit_id":"b6ccc01878ebf7edf164576932e2153d8c0088f5","original_commit_id":"9e8374708e5248f61e56bff290d24ea5544e8e3c","user":{"login":"alexcjohnson","id":2678795,"avatar_url":"https://avatars3.githubusercontent.com/u/2678795?v=4","gravatar_id":"","url":"https://api.github.com/users/alexcjohnson","html_url":"https://github.com/alexcjohnson","followers_url":"https://api.github.com/users/alexcjohnson/followers","following_url":"https://api.github.com/users/alexcjohnson/following{/other_user}","gists_url":"https://api.github.com/users/alexcjohnson/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcjohnson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcjohnson/subscriptions","organizations_url":"https://api.github.com/users/alexcjohnson/orgs","repos_url":"https://api.github.com/users/alexcjohnson/repos","events_url":"https://api.github.com/users/alexcjohnson/events{/privacy}","received_events_url":"https://api.github.com/users/alexcjohnson/received_events","type":"User","site_admin":false},"body":"> In groupby, `groups` = data by which trace is grouped (should this be `target`?)\r\n\r\naggregate has *both* `groups` (in the main container) and `target` (in each `aggregation`) - I suppose we could make *all* of these be `target` but that's starting to sound a bit confusing.","created_at":"2017-08-02T23:48:39Z","updated_at":"2017-08-02T23:48:39Z","html_url":"https://github.com/plotly/plotly.js/pull/1924#discussion_r131024986","pull_request_url":"https://api.github.com/repos/plotly/plotly.js/pulls/1924","_links":{"self":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/comments/131024986"},"html":{"href":"https://github.com/plotly/plotly.js/pull/1924#discussion_r131024986"},"pull_request":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/1924"}}},"pull_request":{"url":"https://api.github.com/repos/plotly/plotly.js/pulls/1924","id":133613049,"html_url":"https://github.com/plotly/plotly.js/pull/1924","diff_url":"https://github.com/plotly/plotly.js/pull/1924.diff","patch_url":"https://github.com/plotly/plotly.js/pull/1924.patch","issue_url":"https://api.github.com/repos/plotly/plotly.js/issues/1924","number":1924,"state":"open","locked":false,"title":"Aggregate transforms","user":{"login":"alexcjohnson","id":2678795,"avatar_url":"https://avatars3.githubusercontent.com/u/2678795?v=4","gravatar_id":"","url":"https://api.github.com/users/alexcjohnson","html_url":"https://github.com/alexcjohnson","followers_url":"https://api.github.com/users/alexcjohnson/followers","following_url":"https://api.github.com/users/alexcjohnson/following{/other_user}","gists_url":"https://api.github.com/users/alexcjohnson/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcjohnson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcjohnson/subscriptions","organizations_url":"https://api.github.com/users/alexcjohnson/orgs","repos_url":"https://api.github.com/users/alexcjohnson/repos","events_url":"https://api.github.com/users/alexcjohnson/events{/privacy}","received_events_url":"https://api.github.com/users/alexcjohnson/received_events","type":"User","site_admin":false},"body":"Adds an `aggregate` transform type, which is actually a closer analog of sql `groupby` than the `groupby` transform is because it coalesces all values in each group to a single output, and leaves the results all in a single trace. Each array attribute needs an aggregation function; if not provided we fall back on `\"first\"` ie the first value encountered in the group.\r\n\r\nNote that some data types / aggregation function combinations don't make much sense, but we allow them anyway: date sums (we add milliseconds since 1970 and then convert back to a date), category sums (we add category serial numbers), category averages (we average serial numbers then round). The tests include an example to show how this plays out.\r\n\r\nI did NOT implement any sort of binning in this PR. That will be a separate PR so it can add binning to `groupby` as well.\r\n\r\ncc @rreusser @etpinard ","created_at":"2017-08-02T02:53:45Z","updated_at":"2017-08-02T23:48:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"796ba0fd97f7e29cc3e6d15572f930c1069c23db","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/plotly/plotly.js/pulls/1924/commits","review_comments_url":"https://api.github.com/repos/plotly/plotly.js/pulls/1924/comments","review_comment_url":"https://api.github.com/repos/plotly/plotly.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/plotly/plotly.js/issues/1924/comments","statuses_url":"https://api.github.com/repos/plotly/plotly.js/statuses/b6ccc01878ebf7edf164576932e2153d8c0088f5","head":{"label":"plotly:aggregateby","ref":"aggregateby","sha":"b6ccc01878ebf7edf164576932e2153d8c0088f5","user":{"login":"plotly","id":5997976,"avatar_url":"https://avatars2.githubusercontent.com/u/5997976?v=4","gravatar_id":"","url":"https://api.github.com/users/plotly","html_url":"https://github.com/plotly","followers_url":"https://api.github.com/users/plotly/followers","following_url":"https://api.github.com/users/plotly/following{/other_user}","gists_url":"https://api.github.com/users/plotly/gists{/gist_id}","starred_url":"https://api.github.com/users/plotly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plotly/subscriptions","organizations_url":"https://api.github.com/users/plotly/orgs","repos_url":"https://api.github.com/users/plotly/repos","events_url":"https://api.github.com/users/plotly/events{/privacy}","received_events_url":"https://api.github.com/users/plotly/received_events","type":"Organization","site_admin":false},"repo":{"id":45646037,"name":"plotly.js","full_name":"plotly/plotly.js","owner":{"login":"plotly","id":5997976,"avatar_url":"https://avatars2.githubusercontent.com/u/5997976?v=4","gravatar_id":"","url":"https://api.github.com/users/plotly","html_url":"https://github.com/plotly","followers_url":"https://api.github.com/users/plotly/followers","following_url":"https://api.github.com/users/plotly/following{/other_user}","gists_url":"https://api.github.com/users/plotly/gists{/gist_id}","starred_url":"https://api.github.com/users/plotly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plotly/subscriptions","organizations_url":"https://api.github.com/users/plotly/orgs","repos_url":"https://api.github.com/users/plotly/repos","events_url":"https://api.github.com/users/plotly/events{/privacy}","received_events_url":"https://api.github.com/users/plotly/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/plotly/plotly.js","description":"The open source JavaScript graphing library that powers plotly","fork":false,"url":"https://api.github.com/repos/plotly/plotly.js","forks_url":"https://api.github.com/repos/plotly/plotly.js/forks","keys_url":"https://api.github.com/repos/plotly/plotly.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/plotly/plotly.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/plotly/plotly.js/teams","hooks_url":"https://api.github.com/repos/plotly/plotly.js/hooks","issue_events_url":"https://api.github.com/repos/plotly/plotly.js/issues/events{/number}","events_url":"https://api.github.com/repos/plotly/plotly.js/events","assignees_url":"https://api.github.com/repos/plotly/plotly.js/assignees{/user}","branches_url":"https://api.github.com/repos/plotly/plotly.js/branches{/branch}","tags_url":"https://api.github.com/repos/plotly/plotly.js/tags","blobs_url":"https://api.github.com/repos/plotly/plotly.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/plotly/plotly.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/plotly/plotly.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/plotly/plotly.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/plotly/plotly.js/statuses/{sha}","languages_url":"https://api.github.com/repos/plotly/plotly.js/languages","stargazers_url":"https://api.github.com/repos/plotly/plotly.js/stargazers","contributors_url":"https://api.github.com/repos/plotly/plotly.js/contributors","subscribers_url":"https://api.github.com/repos/plotly/plotly.js/subscribers","subscription_url":"https://api.github.com/repos/plotly/plotly.js/subscription","commits_url":"https://api.github.com/repos/plotly/plotly.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/plotly/plotly.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/plotly/plotly.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/plotly/plotly.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/plotly/plotly.js/contents/{+path}","compare_url":"https://api.github.com/repos/plotly/plotly.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/plotly/plotly.js/merges","archive_url":"https://api.github.com/repos/plotly/plotly.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/plotly/plotly.js/downloads","issues_url":"https://api.github.com/repos/plotly/plotly.js/issues{/number}","pulls_url":"https://api.github.com/repos/plotly/plotly.js/pulls{/number}","milestones_url":"https://api.github.com/repos/plotly/plotly.js/milestones{/number}","notifications_url":"https://api.github.com/repos/plotly/plotly.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/plotly/plotly.js/labels{/name}","releases_url":"https://api.github.com/repos/plotly/plotly.js/releases{/id}","deployments_url":"https://api.github.com/repos/plotly/plotly.js/deployments","created_at":"2015-11-05T23:27:17Z","updated_at":"2017-08-02T16:11:54Z","pushed_at":"2017-08-02T22:33:39Z","git_url":"git://github.com/plotly/plotly.js.git","ssh_url":"git@github.com:plotly/plotly.js.git","clone_url":"https://github.com/plotly/plotly.js.git","svn_url":"https://github.com/plotly/plotly.js","homepage":"https://plot.ly/javascript/","size":255260,"stargazers_count":6632,"watchers_count":6632,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":702,"mirror_url":null,"open_issues_count":396,"forks":702,"open_issues":396,"watchers":6632,"default_branch":"master"}},"base":{"label":"plotly:master","ref":"master","sha":"b2e54861dfe9960a7bb447f0a622d4198a4e22c7","user":{"login":"plotly","id":5997976,"avatar_url":"https://avatars2.githubusercontent.com/u/5997976?v=4","gravatar_id":"","url":"https://api.github.com/users/plotly","html_url":"https://github.com/plotly","followers_url":"https://api.github.com/users/plotly/followers","following_url":"https://api.github.com/users/plotly/following{/other_user}","gists_url":"https://api.github.com/users/plotly/gists{/gist_id}","starred_url":"https://api.github.com/users/plotly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plotly/subscriptions","organizations_url":"https://api.github.com/users/plotly/orgs","repos_url":"https://api.github.com/users/plotly/repos","events_url":"https://api.github.com/users/plotly/events{/privacy}","received_events_url":"https://api.github.com/users/plotly/received_events","type":"Organization","site_admin":false},"repo":{"id":45646037,"name":"plotly.js","full_name":"plotly/plotly.js","owner":{"login":"plotly","id":5997976,"avatar_url":"https://avatars2.githubusercontent.com/u/5997976?v=4","gravatar_id":"","url":"https://api.github.com/users/plotly","html_url":"https://github.com/plotly","followers_url":"https://api.github.com/users/plotly/followers","following_url":"https://api.github.com/users/plotly/following{/other_user}","gists_url":"https://api.github.com/users/plotly/gists{/gist_id}","starred_url":"https://api.github.com/users/plotly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plotly/subscriptions","organizations_url":"https://api.github.com/users/plotly/orgs","repos_url":"https://api.github.com/users/plotly/repos","events_url":"https://api.github.com/users/plotly/events{/privacy}","received_events_url":"https://api.github.com/users/plotly/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/plotly/plotly.js","description":"The open source JavaScript graphing library that powers plotly","fork":false,"url":"https://api.github.com/repos/plotly/plotly.js","forks_url":"https://api.github.com/repos/plotly/plotly.js/forks","keys_url":"https://api.github.com/repos/plotly/plotly.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/plotly/plotly.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/plotly/plotly.js/teams","hooks_url":"https://api.github.com/repos/plotly/plotly.js/hooks","issue_events_url":"https://api.github.com/repos/plotly/plotly.js/issues/events{/number}","events_url":"https://api.github.com/repos/plotly/plotly.js/events","assignees_url":"https://api.github.com/repos/plotly/plotly.js/assignees{/user}","branches_url":"https://api.github.com/repos/plotly/plotly.js/branches{/branch}","tags_url":"https://api.github.com/repos/plotly/plotly.js/tags","blobs_url":"https://api.github.com/repos/plotly/plotly.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/plotly/plotly.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/plotly/plotly.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/plotly/plotly.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/plotly/plotly.js/statuses/{sha}","languages_url":"https://api.github.com/repos/plotly/plotly.js/languages","stargazers_url":"https://api.github.com/repos/plotly/plotly.js/stargazers","contributors_url":"https://api.github.com/repos/plotly/plotly.js/contributors","subscribers_url":"https://api.github.com/repos/plotly/plotly.js/subscribers","subscription_url":"https://api.github.com/repos/plotly/plotly.js/subscription","commits_url":"https://api.github.com/repos/plotly/plotly.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/plotly/plotly.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/plotly/plotly.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/plotly/plotly.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/plotly/plotly.js/contents/{+path}","compare_url":"https://api.github.com/repos/plotly/plotly.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/plotly/plotly.js/merges","archive_url":"https://api.github.com/repos/plotly/plotly.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/plotly/plotly.js/downloads","issues_url":"https://api.github.com/repos/plotly/plotly.js/issues{/number}","pulls_url":"https://api.github.com/repos/plotly/plotly.js/pulls{/number}","milestones_url":"https://api.github.com/repos/plotly/plotly.js/milestones{/number}","notifications_url":"https://api.github.com/repos/plotly/plotly.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/plotly/plotly.js/labels{/name}","releases_url":"https://api.github.com/repos/plotly/plotly.js/releases{/id}","deployments_url":"https://api.github.com/repos/plotly/plotly.js/deployments","created_at":"2015-11-05T23:27:17Z","updated_at":"2017-08-02T16:11:54Z","pushed_at":"2017-08-02T22:33:39Z","git_url":"git://github.com/plotly/plotly.js.git","ssh_url":"git@github.com:plotly/plotly.js.git","clone_url":"https://github.com/plotly/plotly.js.git","svn_url":"https://github.com/plotly/plotly.js","homepage":"https://plot.ly/javascript/","size":255260,"stargazers_count":6632,"watchers_count":6632,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":702,"mirror_url":null,"open_issues_count":396,"forks":702,"open_issues":396,"watchers":6632,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/1924"},"html":{"href":"https://github.com/plotly/plotly.js/pull/1924"},"issue":{"href":"https://api.github.com/repos/plotly/plotly.js/issues/1924"},"comments":{"href":"https://api.github.com/repos/plotly/plotly.js/issues/1924/comments"},"review_comments":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/1924/comments"},"review_comment":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/1924/commits"},"statuses":{"href":"https://api.github.com/repos/plotly/plotly.js/statuses/b6ccc01878ebf7edf164576932e2153d8c0088f5"}}}}
{"actor":{"display_login":"alexcjohnson"}}