{"action":"created","comment":{"url":"https://api.github.com/repos/plotly/plotly.js/pulls/comments/61485318","id":61485318,"diff_hunk":"@@ -461,24 +468,28 @@ plots.supplyDefaults = function(gd) {\n \n     // then do the data\n     for(i = 0; i < newData.length; i++) {\n-        trace = newData[i];\n-\n-        fullTrace = plots.supplyDataDefaults(trace, i, newFullLayout);\n+        var fullTrace = plots.supplyDataDefaults(newData[i], i, newFullLayout);\n         newFullData.push(fullTrace);\n \n-        // detect plot type\n-        if(plots.traceIs(fullTrace, 'cartesian')) newFullLayout._hasCartesian = true;\n-        else if(plots.traceIs(fullTrace, 'gl3d')) newFullLayout._hasGL3D = true;\n-        else if(plots.traceIs(fullTrace, 'geo')) newFullLayout._hasGeo = true;\n-        else if(plots.traceIs(fullTrace, 'pie')) newFullLayout._hasPie = true;\n-        else if(plots.traceIs(fullTrace, 'gl2d')) newFullLayout._hasGL2D = true;\n-        else if(plots.traceIs(fullTrace, 'ternary')) newFullLayout._hasTernary = true;\n-        else if('r' in fullTrace) newFullLayout._hasPolar = true;\n+        // detect polar\n+        if('r' in fullTrace) newFullLayout._hasPolar = true;\n \n+        // fill in modules list\n         _module = fullTrace._module;\n-        if(_module && modules.indexOf(_module)===-1) modules.push(_module);\n+        if(_module && modules.indexOf(_module) === -1) modules.push(_module);\n     }\n \n+    // attach helper method\n+    newFullLayout._has = hasPlotType.bind(newFullLayout);","path":"src/plots/plots.js","position":77,"original_position":77,"commit_id":"e63ba4ae59f022435f8cc6d5221f6ee748391896","original_commit_id":"e63ba4ae59f022435f8cc6d5221f6ee748391896","user":{"login":"etpinard","id":6675409,"avatar_url":"https://avatars.githubusercontent.com/u/6675409?v=3","gravatar_id":"","url":"https://api.github.com/users/etpinard","html_url":"https://github.com/etpinard","followers_url":"https://api.github.com/users/etpinard/followers","following_url":"https://api.github.com/users/etpinard/following{/other_user}","gists_url":"https://api.github.com/users/etpinard/gists{/gist_id}","starred_url":"https://api.github.com/users/etpinard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/etpinard/subscriptions","organizations_url":"https://api.github.com/users/etpinard/orgs","repos_url":"https://api.github.com/users/etpinard/repos","events_url":"https://api.github.com/users/etpinard/events{/privacy}","received_events_url":"https://api.github.com/users/etpinard/received_events","type":"User","site_admin":false},"body":"@mdtusz I know this could be more verbose, but I really like the look of e.g. `fullLayout._has('geo')`","created_at":"2016-04-28T19:08:21Z","updated_at":"2016-04-28T19:08:21Z","html_url":"https://github.com/plotly/plotly.js/pull/491#discussion_r61485318","pull_request_url":"https://api.github.com/repos/plotly/plotly.js/pulls/491","_links":{"self":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/comments/61485318"},"html":{"href":"https://github.com/plotly/plotly.js/pull/491#discussion_r61485318"},"pull_request":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/491"}}},"pull_request":{"url":"https://api.github.com/repos/plotly/plotly.js/pulls/491","id":68272580,"html_url":"https://github.com/plotly/plotly.js/pull/491","diff_url":"https://github.com/plotly/plotly.js/pull/491.diff","patch_url":"https://github.com/plotly/plotly.js/pull/491.patch","issue_url":"https://api.github.com/repos/plotly/plotly.js/issues/491","number":491,"state":"open","locked":false,"title":"Replace _has<PlotType> variables with '_has()' fullLayout method ","user":{"login":"etpinard","id":6675409,"avatar_url":"https://avatars.githubusercontent.com/u/6675409?v=3","gravatar_id":"","url":"https://api.github.com/users/etpinard","html_url":"https://github.com/etpinard","followers_url":"https://api.github.com/users/etpinard/followers","following_url":"https://api.github.com/users/etpinard/following{/other_user}","gists_url":"https://api.github.com/users/etpinard/gists{/gist_id}","starred_url":"https://api.github.com/users/etpinard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/etpinard/subscriptions","organizations_url":"https://api.github.com/users/etpinard/orgs","repos_url":"https://api.github.com/users/etpinard/repos","events_url":"https://api.github.com/users/etpinard/events{/privacy}","received_events_url":"https://api.github.com/users/etpinard/received_events","type":"User","site_admin":false},"body":"@mdtusz @alexcjohnson \r\n\r\nOur set of hidden plot type variables `_hasCartesian`,  `_hasGL3D`, `_hasGeo`, `_hasGL2D`, `_hasPie` and most recently `_hasTernary` has grown of-out-control.\r\n\r\nWe need a better way to keep track of the plot types present on a graph.\r\n\r\nThe _easiest way_ of doing so would have been to keep track of all the plot types in an array of strings e.g.\r\n\r\n```js\r\nfullLayout._plotTypes = ['cartesian', 'geo', /* ... */];\r\n\r\n// and then\r\nvar hasGeo = (fullLayout._plotTypes.indexOf('geo') !== -1);\r\n```\r\n \r\nBut, in an effort to keep as little hidden variable as possible, I propose to move the list in `gd._modules` \r\nwhich contains the list of all trace modules present on a graph to `fullLayout._modules` and then, using trace module [`basePlotModule`](https://github.com/plotly/plotly.js/blob/4a9243eb578fb385878f85c960f9def1d1c76cff/src/traces/scatter/index.js#L35) property, write a look-up method to determine what plot types are present on the graph by comparing the [`basePlotModule.name`](https://github.com/plotly/plotly.js/blob/4a9243eb578fb385878f85c960f9def1d1c76cff/src/plots/cartesian/index.js#L17) property.","created_at":"2016-04-28T18:59:44Z","updated_at":"2016-04-28T19:08:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e3d8f871fa2c34d581b391fd96dcb585b121dd35","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/plotly/plotly.js/pulls/491/commits","review_comments_url":"https://api.github.com/repos/plotly/plotly.js/pulls/491/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/491/comments","statuses_url":"https://api.github.com/repos/plotly/plotly.js/statuses/e63ba4ae59f022435f8cc6d5221f6ee748391896","head":{"label":"plotly:has-plot-type","ref":"has-plot-type","sha":"e63ba4ae59f022435f8cc6d5221f6ee748391896","user":{"login":"plotly","id":5997976,"avatar_url":"https://avatars.githubusercontent.com/u/5997976?v=3","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://avatars.githubusercontent.com/u/5997976?v=3","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":"2016-04-28T18:50:41Z","pushed_at":"2016-04-28T18:59:45Z","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":110386,"stargazers_count":4580,"watchers_count":4580,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":347,"mirror_url":null,"open_issues_count":123,"forks":347,"open_issues":123,"watchers":4580,"default_branch":"master"}},"base":{"label":"plotly:master","ref":"master","sha":"4a9243eb578fb385878f85c960f9def1d1c76cff","user":{"login":"plotly","id":5997976,"avatar_url":"https://avatars.githubusercontent.com/u/5997976?v=3","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://avatars.githubusercontent.com/u/5997976?v=3","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":"2016-04-28T18:50:41Z","pushed_at":"2016-04-28T18:59:45Z","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":110386,"stargazers_count":4580,"watchers_count":4580,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":347,"mirror_url":null,"open_issues_count":123,"forks":347,"open_issues":123,"watchers":4580,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/491"},"html":{"href":"https://github.com/plotly/plotly.js/pull/491"},"issue":{"href":"https://api.github.com/repos/plotly/plotly.js/issues/491"},"comments":{"href":"https://api.github.com/repos/plotly/plotly.js/issues/491/comments"},"review_comments":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/491/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/491/commits"},"statuses":{"href":"https://api.github.com/repos/plotly/plotly.js/statuses/e63ba4ae59f022435f8cc6d5221f6ee748391896"}}}}