{"action":"created","comment":{"url":"https://api.github.com/repos/palantir/plottable/pulls/comments/31967866","id":31967866,"diff_hunk":"@@ -206,36 +206,49 @@ export module Components {\n     }\n \n     /**\n-     * Gets the entry under at given pixel position.\n-     * Returns an empty Selection if no entry exists at that pixel position.\n-     *\n-     * @param {Point} position\n-     * @returns {d3.Selection}\n+     * Gets the Entities (representing Legend entries) at a particular point. \n+     * Returns an empty array if no Entities are present at that location.\n+     * \n+     * @param {Point} p\n+     * @returns {Entity<Legend>[]}\n      */\n-    public getEntry(position: Point): d3.Selection<void> {\n+    public entitiesAt(p: Point) {\n       if (!this._isSetup) {\n-        return d3.select(null);\n+        return [];\n       }\n \n-      var entry = d3.select(null);\n+      var entities: Entity<Legend>[] = [];\n       var layout = this._calculateLayoutInfo(this.width(), this.height());\n       var legendPadding = this._padding;\n+      var domain = this._scale.domain();\n+      var legend = this;\n       this._content.selectAll(\"g.\" + Legend.LEGEND_ROW_CLASS).each(function(d: any, i: number) {\n         var lowY = i * layout.textHeight + legendPadding;\n         var highY = (i + 1) * layout.textHeight + legendPadding;\n+        var symbolY = (lowY + highY) / 2;\n         var lowX = legendPadding;\n         var highX = legendPadding;\n         d3.select(this).selectAll(\"g.\" + Legend.LEGEND_ENTRY_CLASS).each(function(value: string) {\n           highX += layout.entryLengths.get(value);\n-          if (highX >= position.x && lowX <= position.x &&\n-              highY >= position.y && lowY <= position.y) {\n-            entry = d3.select(this);\n+          var symbolX = lowX + layout.textHeight / 2;\n+          if (highX >= p.x && lowX <= p.x &&\n+              highY >= p.y && lowY <= p.y) {\n+            var entrySelection = d3.select(this);\n+            var datum = entrySelection.datum();\n+            var index = domain.indexOf(datum);\n+            entities.push({\n+              datum: datum,\n+              index: index,\n+              position: { x: symbolX, y: symbolY },\n+              selection: entrySelection,\n+              component: legend","path":"src/components/legend.ts","position":50,"original_position":50,"commit_id":"1269d3b470efe3e8df8d9923ca6e8b3a7fed2995","original_commit_id":"4e9ce3330bf73ed0c2aab3df0db0e1dfa53591d5","user":{"login":"aicioara","id":3248682,"avatar_url":"https://avatars.githubusercontent.com/u/3248682?v=3","gravatar_id":"","url":"https://api.github.com/users/aicioara","html_url":"https://github.com/aicioara","followers_url":"https://api.github.com/users/aicioara/followers","following_url":"https://api.github.com/users/aicioara/following{/other_user}","gists_url":"https://api.github.com/users/aicioara/gists{/gist_id}","starred_url":"https://api.github.com/users/aicioara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aicioara/subscriptions","organizations_url":"https://api.github.com/users/aicioara/orgs","repos_url":"https://api.github.com/users/aicioara/repos","events_url":"https://api.github.com/users/aicioara/events{/privacy}","received_events_url":"https://api.github.com/users/aicioara/received_events","type":"User","site_admin":false},"body":"For example you push the `entitySelection`, but then the datum is just calling `.datum()` on that selection, which seems redundant. Then `legend` is just `this`, but `entitySelection` is just `d3.select(this)`, so `entitySelection` in itself seems redundant. It also exposes a d3 entity to the consumer of a public method, which I thought we avoid at all costs","created_at":"2015-06-08T22:46:27Z","updated_at":"2015-06-08T22:46:27Z","html_url":"https://github.com/palantir/plottable/pull/2243#discussion_r31967866","pull_request_url":"https://api.github.com/repos/palantir/plottable/pulls/2243","_links":{"self":{"href":"https://api.github.com/repos/palantir/plottable/pulls/comments/31967866"},"html":{"href":"https://github.com/palantir/plottable/pull/2243#discussion_r31967866"},"pull_request":{"href":"https://api.github.com/repos/palantir/plottable/pulls/2243"}}},"pull_request":{"url":"https://api.github.com/repos/palantir/plottable/pulls/2243","id":37114965,"html_url":"https://github.com/palantir/plottable/pull/2243","diff_url":"https://github.com/palantir/plottable/pull/2243.diff","patch_url":"https://github.com/palantir/plottable/pull/2243.patch","issue_url":"https://api.github.com/repos/palantir/plottable/issues/2243","number":2243,"state":"open","locked":false,"title":"[Legend] Return Entities instead of Selection when getting entries","user":{"login":"jtlan","id":1440449,"avatar_url":"https://avatars.githubusercontent.com/u/1440449?v=3","gravatar_id":"","url":"https://api.github.com/users/jtlan","html_url":"https://github.com/jtlan","followers_url":"https://api.github.com/users/jtlan/followers","following_url":"https://api.github.com/users/jtlan/following{/other_user}","gists_url":"https://api.github.com/users/jtlan/gists{/gist_id}","starred_url":"https://api.github.com/users/jtlan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtlan/subscriptions","organizations_url":"https://api.github.com/users/jtlan/orgs","repos_url":"https://api.github.com/users/jtlan/repos","events_url":"https://api.github.com/users/jtlan/events{/privacy}","received_events_url":"https://api.github.com/users/jtlan/received_events","type":"User","site_admin":false},"body":"`Entity` is now generic on the `Component` type:\r\n```Typescript\r\nexport interface Entity<C extends Component> {\r\n  datum: any;\r\n  index: number;\r\n  position: Point;\r\n  selection: d3.Selection<any>;\r\n  component: C;\r\n}\r\n```\r\n\r\nAnd `Plots.PlotEntity` extends `Entity`:\r\n```Typescript\r\ninterface PlotEntity extends Entity<Plot> {\r\n  dataset: Dataset;\r\n  component: Plot;\r\n}\r\n```\r\n\r\nOn `Legend`, `entitiesAt()` replaces `getEntry()`, returns `Entity<Legend>[]`. Usually, only one `Entity` is ever returned. The method is still named `entitiesAt()` for consistency with the `Plot` methods. Multiple `Entries` might be returned if the query point is exactly on the border between them.","created_at":"2015-06-07T22:55:22Z","updated_at":"2015-06-08T22:46:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"282e16f1f283355ab721c094db2ad4ad57e66cff","assignee":{"login":"aicioara","id":3248682,"avatar_url":"https://avatars.githubusercontent.com/u/3248682?v=3","gravatar_id":"","url":"https://api.github.com/users/aicioara","html_url":"https://github.com/aicioara","followers_url":"https://api.github.com/users/aicioara/followers","following_url":"https://api.github.com/users/aicioara/following{/other_user}","gists_url":"https://api.github.com/users/aicioara/gists{/gist_id}","starred_url":"https://api.github.com/users/aicioara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aicioara/subscriptions","organizations_url":"https://api.github.com/users/aicioara/orgs","repos_url":"https://api.github.com/users/aicioara/repos","events_url":"https://api.github.com/users/aicioara/events{/privacy}","received_events_url":"https://api.github.com/users/aicioara/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/palantir/plottable/pulls/2243/commits","review_comments_url":"https://api.github.com/repos/palantir/plottable/pulls/2243/comments","review_comment_url":"https://api.github.com/repos/palantir/plottable/pulls/comments{/number}","comments_url":"https://api.github.com/repos/palantir/plottable/issues/2243/comments","statuses_url":"https://api.github.com/repos/palantir/plottable/statuses/1269d3b470efe3e8df8d9923ca6e8b3a7fed2995","head":{"label":"palantir:legendEntity","ref":"legendEntity","sha":"1269d3b470efe3e8df8d9923ca6e8b3a7fed2995","user":{"login":"palantir","id":303157,"avatar_url":"https://avatars.githubusercontent.com/u/303157?v=3","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"repo":{"id":16149854,"name":"plottable","full_name":"palantir/plottable","owner":{"login":"palantir","id":303157,"avatar_url":"https://avatars.githubusercontent.com/u/303157?v=3","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/palantir/plottable","description":"A library of modular chart components, built on D3","fork":false,"url":"https://api.github.com/repos/palantir/plottable","forks_url":"https://api.github.com/repos/palantir/plottable/forks","keys_url":"https://api.github.com/repos/palantir/plottable/keys{/key_id}","collaborators_url":"https://api.github.com/repos/palantir/plottable/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/palantir/plottable/teams","hooks_url":"https://api.github.com/repos/palantir/plottable/hooks","issue_events_url":"https://api.github.com/repos/palantir/plottable/issues/events{/number}","events_url":"https://api.github.com/repos/palantir/plottable/events","assignees_url":"https://api.github.com/repos/palantir/plottable/assignees{/user}","branches_url":"https://api.github.com/repos/palantir/plottable/branches{/branch}","tags_url":"https://api.github.com/repos/palantir/plottable/tags","blobs_url":"https://api.github.com/repos/palantir/plottable/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/palantir/plottable/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/palantir/plottable/git/refs{/sha}","trees_url":"https://api.github.com/repos/palantir/plottable/git/trees{/sha}","statuses_url":"https://api.github.com/repos/palantir/plottable/statuses/{sha}","languages_url":"https://api.github.com/repos/palantir/plottable/languages","stargazers_url":"https://api.github.com/repos/palantir/plottable/stargazers","contributors_url":"https://api.github.com/repos/palantir/plottable/contributors","subscribers_url":"https://api.github.com/repos/palantir/plottable/subscribers","subscription_url":"https://api.github.com/repos/palantir/plottable/subscription","commits_url":"https://api.github.com/repos/palantir/plottable/commits{/sha}","git_commits_url":"https://api.github.com/repos/palantir/plottable/git/commits{/sha}","comments_url":"https://api.github.com/repos/palantir/plottable/comments{/number}","issue_comment_url":"https://api.github.com/repos/palantir/plottable/issues/comments{/number}","contents_url":"https://api.github.com/repos/palantir/plottable/contents/{+path}","compare_url":"https://api.github.com/repos/palantir/plottable/compare/{base}...{head}","merges_url":"https://api.github.com/repos/palantir/plottable/merges","archive_url":"https://api.github.com/repos/palantir/plottable/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/palantir/plottable/downloads","issues_url":"https://api.github.com/repos/palantir/plottable/issues{/number}","pulls_url":"https://api.github.com/repos/palantir/plottable/pulls{/number}","milestones_url":"https://api.github.com/repos/palantir/plottable/milestones{/number}","notifications_url":"https://api.github.com/repos/palantir/plottable/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/palantir/plottable/labels{/name}","releases_url":"https://api.github.com/repos/palantir/plottable/releases{/id}","created_at":"2014-01-22T19:29:19Z","updated_at":"2015-06-08T08:02:49Z","pushed_at":"2015-06-08T22:42:56Z","git_url":"git://github.com/palantir/plottable.git","ssh_url":"git@github.com:palantir/plottable.git","clone_url":"https://github.com/palantir/plottable.git","svn_url":"https://github.com/palantir/plottable","homepage":"plottablejs.org","size":117685,"stargazers_count":500,"watchers_count":500,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":45,"mirror_url":null,"open_issues_count":164,"forks":45,"open_issues":164,"watchers":500,"default_branch":"develop"}},"base":{"label":"palantir:develop","ref":"develop","sha":"405c0052ed3d5296e3ac93b781a9f7c8ca3c166d","user":{"login":"palantir","id":303157,"avatar_url":"https://avatars.githubusercontent.com/u/303157?v=3","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"repo":{"id":16149854,"name":"plottable","full_name":"palantir/plottable","owner":{"login":"palantir","id":303157,"avatar_url":"https://avatars.githubusercontent.com/u/303157?v=3","gravatar_id":"","url":"https://api.github.com/users/palantir","html_url":"https://github.com/palantir","followers_url":"https://api.github.com/users/palantir/followers","following_url":"https://api.github.com/users/palantir/following{/other_user}","gists_url":"https://api.github.com/users/palantir/gists{/gist_id}","starred_url":"https://api.github.com/users/palantir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palantir/subscriptions","organizations_url":"https://api.github.com/users/palantir/orgs","repos_url":"https://api.github.com/users/palantir/repos","events_url":"https://api.github.com/users/palantir/events{/privacy}","received_events_url":"https://api.github.com/users/palantir/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/palantir/plottable","description":"A library of modular chart components, built on D3","fork":false,"url":"https://api.github.com/repos/palantir/plottable","forks_url":"https://api.github.com/repos/palantir/plottable/forks","keys_url":"https://api.github.com/repos/palantir/plottable/keys{/key_id}","collaborators_url":"https://api.github.com/repos/palantir/plottable/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/palantir/plottable/teams","hooks_url":"https://api.github.com/repos/palantir/plottable/hooks","issue_events_url":"https://api.github.com/repos/palantir/plottable/issues/events{/number}","events_url":"https://api.github.com/repos/palantir/plottable/events","assignees_url":"https://api.github.com/repos/palantir/plottable/assignees{/user}","branches_url":"https://api.github.com/repos/palantir/plottable/branches{/branch}","tags_url":"https://api.github.com/repos/palantir/plottable/tags","blobs_url":"https://api.github.com/repos/palantir/plottable/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/palantir/plottable/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/palantir/plottable/git/refs{/sha}","trees_url":"https://api.github.com/repos/palantir/plottable/git/trees{/sha}","statuses_url":"https://api.github.com/repos/palantir/plottable/statuses/{sha}","languages_url":"https://api.github.com/repos/palantir/plottable/languages","stargazers_url":"https://api.github.com/repos/palantir/plottable/stargazers","contributors_url":"https://api.github.com/repos/palantir/plottable/contributors","subscribers_url":"https://api.github.com/repos/palantir/plottable/subscribers","subscription_url":"https://api.github.com/repos/palantir/plottable/subscription","commits_url":"https://api.github.com/repos/palantir/plottable/commits{/sha}","git_commits_url":"https://api.github.com/repos/palantir/plottable/git/commits{/sha}","comments_url":"https://api.github.com/repos/palantir/plottable/comments{/number}","issue_comment_url":"https://api.github.com/repos/palantir/plottable/issues/comments{/number}","contents_url":"https://api.github.com/repos/palantir/plottable/contents/{+path}","compare_url":"https://api.github.com/repos/palantir/plottable/compare/{base}...{head}","merges_url":"https://api.github.com/repos/palantir/plottable/merges","archive_url":"https://api.github.com/repos/palantir/plottable/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/palantir/plottable/downloads","issues_url":"https://api.github.com/repos/palantir/plottable/issues{/number}","pulls_url":"https://api.github.com/repos/palantir/plottable/pulls{/number}","milestones_url":"https://api.github.com/repos/palantir/plottable/milestones{/number}","notifications_url":"https://api.github.com/repos/palantir/plottable/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/palantir/plottable/labels{/name}","releases_url":"https://api.github.com/repos/palantir/plottable/releases{/id}","created_at":"2014-01-22T19:29:19Z","updated_at":"2015-06-08T08:02:49Z","pushed_at":"2015-06-08T22:42:56Z","git_url":"git://github.com/palantir/plottable.git","ssh_url":"git@github.com:palantir/plottable.git","clone_url":"https://github.com/palantir/plottable.git","svn_url":"https://github.com/palantir/plottable","homepage":"plottablejs.org","size":117685,"stargazers_count":500,"watchers_count":500,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":45,"mirror_url":null,"open_issues_count":164,"forks":45,"open_issues":164,"watchers":500,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/palantir/plottable/pulls/2243"},"html":{"href":"https://github.com/palantir/plottable/pull/2243"},"issue":{"href":"https://api.github.com/repos/palantir/plottable/issues/2243"},"comments":{"href":"https://api.github.com/repos/palantir/plottable/issues/2243/comments"},"review_comments":{"href":"https://api.github.com/repos/palantir/plottable/pulls/2243/comments"},"review_comment":{"href":"https://api.github.com/repos/palantir/plottable/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/palantir/plottable/pulls/2243/commits"},"statuses":{"href":"https://api.github.com/repos/palantir/plottable/statuses/1269d3b470efe3e8df8d9923ca6e8b3a7fed2995"}}}}