{"action":"created","comment":{"url":"https://api.github.com/repos/tdhock/animint/pulls/comments/33294211","id":33294211,"diff_hunk":"@@ -22,11 +22,76 @@ parsePlot <- function(meta){\n       plot.meta$scales[[sc$aesthetics]] <- makeScale(sc)\n     }\n   }\n+  \n+  ## Export axis specification as a combination of breaks and\n+  ## labels, on the relevant axis scale (i.e. so that it can\n+  ## be passed into d3 on the x axis scale instead of on the\n+  ## grid 0-1 scale). This allows transformations to be used\n+  ## out of the box, with no additional d3 coding.\n+  theme.pars <- ggplot2:::plot_theme(meta$plot)\n+  \n+  ## No legend if theme(legend.postion=\"none\").\n+  plot.meta$legend <- if(theme.pars$legend.position != \"none\"){\n+    getLegendList(meta$built)\n+  }\n+  \n+  ## save each layer\n   for(layer.i in seq_along(meta$plot$layers)){\n     ##cat(sprintf(\"%4d / %4d layers\\n\", layer.i, length(meta$plot$layers)))\n \n     ## This is the layer from the original ggplot object.\n     L <- meta$plot$layers[[layer.i]]\n+    \n+    ## If any legends are specified, add showSelected aesthetic\n+    for(legend.i in seq_along(plot.meta$legend)) {\n+      # the type of legend: colour, fill, etc\n+      legend_type <- plot.meta$legend[[legend.i]]$legend_type\n+      # the name of the variable used in this legend\n+      var_name <- plot.meta$legend[[legend.i]]$vars\n+      # the actual values for that variable\n+      var <- L$data[[var_name]]\n+      ## checking if it is a discrete variable.\n+      if(plyr::is.discrete(var)) {\n+        is.interactive.aes <-\n+          grepl(\"showSelected|clickSelects\", names(L$mapping))\n+        is.legend.var <- L$mapping == var_name\n+        ## If var_name is used with another interactive aes, then do\n+        ## not add any showSelected aesthetic for it.\n+        var.is.interactive <- any(is.interactive.aes & is.legend.var)\n+        if(!var.is.interactive){\n+          for(i in legend_type) {\n+            temp_name <- paste0(\"showSelectedlegend\", i)\n+            L$mapping[[temp_name]] <- as.symbol(var_name)\n+          }\n+        }\n+        # if selector.types is not specified, set it to multiple\n+        if(is.null(meta$selector.types[[var_name]])) {\n+          meta$selector.types[[var_name]] <- \"multiple\"\n+        }","path":"R/animint.R","position":49,"original_position":49,"commit_id":"21647b4796a5548f26dc0d4ed36b9b0182013c54","original_commit_id":"21647b4796a5548f26dc0d4ed36b9b0182013c54","user":{"login":"kferris10","id":6612411,"avatar_url":"https://avatars.githubusercontent.com/u/6612411?v=3","gravatar_id":"","url":"https://api.github.com/users/kferris10","html_url":"https://github.com/kferris10","followers_url":"https://api.github.com/users/kferris10/followers","following_url":"https://api.github.com/users/kferris10/following{/other_user}","gists_url":"https://api.github.com/users/kferris10/gists{/gist_id}","starred_url":"https://api.github.com/users/kferris10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kferris10/subscriptions","organizations_url":"https://api.github.com/users/kferris10/orgs","repos_url":"https://api.github.com/users/kferris10/repos","events_url":"https://api.github.com/users/kferris10/events{/privacy}","received_events_url":"https://api.github.com/users/kferris10/received_events","type":"User","site_admin":false},"body":"@tdhock Would it make sense to coerce `meta$selector.types` to a list?  I'm getting an error when trying to run this example.\r\n\r\n```\r\nmtcars$cyl <- factor(mtcars$cyl)\r\nmtcars$vs <- factor(mtcars$vs)\r\np1 <- ggplot() + \r\n  geom_point(aes(wt, mpg, colour = cyl, size = vs), \r\n             data = mtcars)\r\np2 <- ggplot() + \r\n  geom_point(aes(wt, drat, colour = cyl, size = vs, clickSelects = vs), \r\n             data = mtcars)\r\nanimint2dir(list(p1 = p2, p2 = p2))\r\n```","created_at":"2015-06-25T19:20:58Z","updated_at":"2015-06-25T19:20:58Z","html_url":"https://github.com/tdhock/animint/pull/74#discussion_r33294211","pull_request_url":"https://api.github.com/repos/tdhock/animint/pulls/74","_links":{"self":{"href":"https://api.github.com/repos/tdhock/animint/pulls/comments/33294211"},"html":{"href":"https://github.com/tdhock/animint/pull/74#discussion_r33294211"},"pull_request":{"href":"https://api.github.com/repos/tdhock/animint/pulls/74"}}},"pull_request":{"url":"https://api.github.com/repos/tdhock/animint/pulls/74","id":35978250,"html_url":"https://github.com/tdhock/animint/pull/74","diff_url":"https://github.com/tdhock/animint/pull/74.diff","patch_url":"https://github.com/tdhock/animint/pull/74.patch","issue_url":"https://api.github.com/repos/tdhock/animint/issues/74","number":74,"state":"open","locked":false,"title":"Getting started with interactive legends","user":{"login":"kferris10","id":6612411,"avatar_url":"https://avatars.githubusercontent.com/u/6612411?v=3","gravatar_id":"","url":"https://api.github.com/users/kferris10","html_url":"https://github.com/kferris10","followers_url":"https://api.github.com/users/kferris10/followers","following_url":"https://api.github.com/users/kferris10/following{/other_user}","gists_url":"https://api.github.com/users/kferris10/gists{/gist_id}","starred_url":"https://api.github.com/users/kferris10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kferris10/subscriptions","organizations_url":"https://api.github.com/users/kferris10/orgs","repos_url":"https://api.github.com/users/kferris10/repos","events_url":"https://api.github.com/users/kferris10/events{/privacy}","received_events_url":"https://api.github.com/users/kferris10/received_events","type":"User","site_admin":false},"body":"This is just a rough start to implementing interactive legends.  @cpsievert thought it would be good to discuss where exactly we want this to go.  He has a couple ideas which are slightly over my head so I'll let him explain.\r\n\r\nI've [put together a working example](http://kferris10.github.io/animint_dev/) so you can see the general idea.  I also explain the changes I've made there.  I'm pretty sure that this is the only example for which this will work. \r\n\r\nI'd also love any suggestions for tests that might be useful here.  Thanks!","created_at":"2015-05-21T21:13:12Z","updated_at":"2015-06-25T19:20:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7c39711504785f23a40751734a3c1a9adaaf8d6e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tdhock/animint/pulls/74/commits","review_comments_url":"https://api.github.com/repos/tdhock/animint/pulls/74/comments","review_comment_url":"https://api.github.com/repos/tdhock/animint/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tdhock/animint/issues/74/comments","statuses_url":"https://api.github.com/repos/tdhock/animint/statuses/21647b4796a5548f26dc0d4ed36b9b0182013c54","head":{"label":"tdhock:interactive_legends","ref":"interactive_legends","sha":"21647b4796a5548f26dc0d4ed36b9b0182013c54","user":{"login":"tdhock","id":932850,"avatar_url":"https://avatars.githubusercontent.com/u/932850?v=3","gravatar_id":"","url":"https://api.github.com/users/tdhock","html_url":"https://github.com/tdhock","followers_url":"https://api.github.com/users/tdhock/followers","following_url":"https://api.github.com/users/tdhock/following{/other_user}","gists_url":"https://api.github.com/users/tdhock/gists{/gist_id}","starred_url":"https://api.github.com/users/tdhock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdhock/subscriptions","organizations_url":"https://api.github.com/users/tdhock/orgs","repos_url":"https://api.github.com/users/tdhock/repos","events_url":"https://api.github.com/users/tdhock/events{/privacy}","received_events_url":"https://api.github.com/users/tdhock/received_events","type":"User","site_admin":false},"repo":{"id":8399379,"name":"animint","full_name":"tdhock/animint","owner":{"login":"tdhock","id":932850,"avatar_url":"https://avatars.githubusercontent.com/u/932850?v=3","gravatar_id":"","url":"https://api.github.com/users/tdhock","html_url":"https://github.com/tdhock","followers_url":"https://api.github.com/users/tdhock/followers","following_url":"https://api.github.com/users/tdhock/following{/other_user}","gists_url":"https://api.github.com/users/tdhock/gists{/gist_id}","starred_url":"https://api.github.com/users/tdhock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdhock/subscriptions","organizations_url":"https://api.github.com/users/tdhock/orgs","repos_url":"https://api.github.com/users/tdhock/repos","events_url":"https://api.github.com/users/tdhock/events{/privacy}","received_events_url":"https://api.github.com/users/tdhock/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tdhock/animint","description":"animated and interactive web graphics","fork":false,"url":"https://api.github.com/repos/tdhock/animint","forks_url":"https://api.github.com/repos/tdhock/animint/forks","keys_url":"https://api.github.com/repos/tdhock/animint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tdhock/animint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tdhock/animint/teams","hooks_url":"https://api.github.com/repos/tdhock/animint/hooks","issue_events_url":"https://api.github.com/repos/tdhock/animint/issues/events{/number}","events_url":"https://api.github.com/repos/tdhock/animint/events","assignees_url":"https://api.github.com/repos/tdhock/animint/assignees{/user}","branches_url":"https://api.github.com/repos/tdhock/animint/branches{/branch}","tags_url":"https://api.github.com/repos/tdhock/animint/tags","blobs_url":"https://api.github.com/repos/tdhock/animint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tdhock/animint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tdhock/animint/git/refs{/sha}","trees_url":"https://api.github.com/repos/tdhock/animint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tdhock/animint/statuses/{sha}","languages_url":"https://api.github.com/repos/tdhock/animint/languages","stargazers_url":"https://api.github.com/repos/tdhock/animint/stargazers","contributors_url":"https://api.github.com/repos/tdhock/animint/contributors","subscribers_url":"https://api.github.com/repos/tdhock/animint/subscribers","subscription_url":"https://api.github.com/repos/tdhock/animint/subscription","commits_url":"https://api.github.com/repos/tdhock/animint/commits{/sha}","git_commits_url":"https://api.github.com/repos/tdhock/animint/git/commits{/sha}","comments_url":"https://api.github.com/repos/tdhock/animint/comments{/number}","issue_comment_url":"https://api.github.com/repos/tdhock/animint/issues/comments{/number}","contents_url":"https://api.github.com/repos/tdhock/animint/contents/{+path}","compare_url":"https://api.github.com/repos/tdhock/animint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tdhock/animint/merges","archive_url":"https://api.github.com/repos/tdhock/animint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tdhock/animint/downloads","issues_url":"https://api.github.com/repos/tdhock/animint/issues{/number}","pulls_url":"https://api.github.com/repos/tdhock/animint/pulls{/number}","milestones_url":"https://api.github.com/repos/tdhock/animint/milestones{/number}","notifications_url":"https://api.github.com/repos/tdhock/animint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tdhock/animint/labels{/name}","releases_url":"https://api.github.com/repos/tdhock/animint/releases{/id}","created_at":"2013-02-25T00:27:47Z","updated_at":"2015-06-02T19:36:52Z","pushed_at":"2015-06-25T17:11:21Z","git_url":"git://github.com/tdhock/animint.git","ssh_url":"git@github.com:tdhock/animint.git","clone_url":"https://github.com/tdhock/animint.git","svn_url":"https://github.com/tdhock/animint","homepage":"","size":137121,"stargazers_count":58,"watchers_count":58,"language":"R","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":22,"mirror_url":null,"open_issues_count":12,"forks":22,"open_issues":12,"watchers":58,"default_branch":"master"}},"base":{"label":"tdhock:master","ref":"master","sha":"4910d0f87ad01b30b76e1b61c8fb5213ec7e502f","user":{"login":"tdhock","id":932850,"avatar_url":"https://avatars.githubusercontent.com/u/932850?v=3","gravatar_id":"","url":"https://api.github.com/users/tdhock","html_url":"https://github.com/tdhock","followers_url":"https://api.github.com/users/tdhock/followers","following_url":"https://api.github.com/users/tdhock/following{/other_user}","gists_url":"https://api.github.com/users/tdhock/gists{/gist_id}","starred_url":"https://api.github.com/users/tdhock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdhock/subscriptions","organizations_url":"https://api.github.com/users/tdhock/orgs","repos_url":"https://api.github.com/users/tdhock/repos","events_url":"https://api.github.com/users/tdhock/events{/privacy}","received_events_url":"https://api.github.com/users/tdhock/received_events","type":"User","site_admin":false},"repo":{"id":8399379,"name":"animint","full_name":"tdhock/animint","owner":{"login":"tdhock","id":932850,"avatar_url":"https://avatars.githubusercontent.com/u/932850?v=3","gravatar_id":"","url":"https://api.github.com/users/tdhock","html_url":"https://github.com/tdhock","followers_url":"https://api.github.com/users/tdhock/followers","following_url":"https://api.github.com/users/tdhock/following{/other_user}","gists_url":"https://api.github.com/users/tdhock/gists{/gist_id}","starred_url":"https://api.github.com/users/tdhock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdhock/subscriptions","organizations_url":"https://api.github.com/users/tdhock/orgs","repos_url":"https://api.github.com/users/tdhock/repos","events_url":"https://api.github.com/users/tdhock/events{/privacy}","received_events_url":"https://api.github.com/users/tdhock/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tdhock/animint","description":"animated and interactive web graphics","fork":false,"url":"https://api.github.com/repos/tdhock/animint","forks_url":"https://api.github.com/repos/tdhock/animint/forks","keys_url":"https://api.github.com/repos/tdhock/animint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tdhock/animint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tdhock/animint/teams","hooks_url":"https://api.github.com/repos/tdhock/animint/hooks","issue_events_url":"https://api.github.com/repos/tdhock/animint/issues/events{/number}","events_url":"https://api.github.com/repos/tdhock/animint/events","assignees_url":"https://api.github.com/repos/tdhock/animint/assignees{/user}","branches_url":"https://api.github.com/repos/tdhock/animint/branches{/branch}","tags_url":"https://api.github.com/repos/tdhock/animint/tags","blobs_url":"https://api.github.com/repos/tdhock/animint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tdhock/animint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tdhock/animint/git/refs{/sha}","trees_url":"https://api.github.com/repos/tdhock/animint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tdhock/animint/statuses/{sha}","languages_url":"https://api.github.com/repos/tdhock/animint/languages","stargazers_url":"https://api.github.com/repos/tdhock/animint/stargazers","contributors_url":"https://api.github.com/repos/tdhock/animint/contributors","subscribers_url":"https://api.github.com/repos/tdhock/animint/subscribers","subscription_url":"https://api.github.com/repos/tdhock/animint/subscription","commits_url":"https://api.github.com/repos/tdhock/animint/commits{/sha}","git_commits_url":"https://api.github.com/repos/tdhock/animint/git/commits{/sha}","comments_url":"https://api.github.com/repos/tdhock/animint/comments{/number}","issue_comment_url":"https://api.github.com/repos/tdhock/animint/issues/comments{/number}","contents_url":"https://api.github.com/repos/tdhock/animint/contents/{+path}","compare_url":"https://api.github.com/repos/tdhock/animint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tdhock/animint/merges","archive_url":"https://api.github.com/repos/tdhock/animint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tdhock/animint/downloads","issues_url":"https://api.github.com/repos/tdhock/animint/issues{/number}","pulls_url":"https://api.github.com/repos/tdhock/animint/pulls{/number}","milestones_url":"https://api.github.com/repos/tdhock/animint/milestones{/number}","notifications_url":"https://api.github.com/repos/tdhock/animint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tdhock/animint/labels{/name}","releases_url":"https://api.github.com/repos/tdhock/animint/releases{/id}","created_at":"2013-02-25T00:27:47Z","updated_at":"2015-06-02T19:36:52Z","pushed_at":"2015-06-25T17:11:21Z","git_url":"git://github.com/tdhock/animint.git","ssh_url":"git@github.com:tdhock/animint.git","clone_url":"https://github.com/tdhock/animint.git","svn_url":"https://github.com/tdhock/animint","homepage":"","size":137121,"stargazers_count":58,"watchers_count":58,"language":"R","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":22,"mirror_url":null,"open_issues_count":12,"forks":22,"open_issues":12,"watchers":58,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tdhock/animint/pulls/74"},"html":{"href":"https://github.com/tdhock/animint/pull/74"},"issue":{"href":"https://api.github.com/repos/tdhock/animint/issues/74"},"comments":{"href":"https://api.github.com/repos/tdhock/animint/issues/74/comments"},"review_comments":{"href":"https://api.github.com/repos/tdhock/animint/pulls/74/comments"},"review_comment":{"href":"https://api.github.com/repos/tdhock/animint/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tdhock/animint/pulls/74/commits"},"statuses":{"href":"https://api.github.com/repos/tdhock/animint/statuses/21647b4796a5548f26dc0d4ed36b9b0182013c54"}}}}