{"action":"created","comment":{"url":"https://api.github.com/repos/plotly/plotly.js/pulls/comments/47288423","id":47288423,"diff_hunk":"@@ -0,0 +1,94 @@\n+/**\n+* Copyright 2012-2015, 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+\n+'use strict';\n+\n+\n+/**\n+ * Error bar computing function generator\n+ *\n+ * N.B. The generated function does not clean the dataPt entries. Non-numeric\n+ * entries result in undefined error magnitudes.\n+ *\n+ * @param {object} opts error bar attributes\n+ *\n+ * @return {function} :\n+ *      @param {numeric} dataPt data point from where to compute the error magnitude\n+ *      @param {number} index index of dataPt in its corresponding data array\n+ *      @return {array}\n+ *        - error[0] : error magnitude in the negative direction\n+ *        - error[1] : \" \" \" \" positive \"\n+ */\n+module.exports = function makeComputeError(opts) {\n+    var type = opts.type,\n+        symmetric = opts.symmetric;\n+\n+    if(type === 'data') {\n+        var array = opts.array,\n+            arrayminus = opts.arrayminus;\n+\n+        if(symmetric || arrayminus === undefined) {\n+            return function computeError(dataPt, index) {\n+                var val = +(array[index]);\n+                return [val, val];\n+            };\n+        }\n+        else {\n+            return function computeError(dataPt, index) {\n+                return [+arrayminus[index], +array[index]];\n+            };\n+        }\n+    }\n+    else {\n+        var computeErrorValue = makeComputeErrorValue(type, opts.value),\n+            computeErrorValueMinus = makeComputeErrorValue(type, opts.valueminus);\n+\n+        if(symmetric || opts.valueminus === undefined) {\n+            return function computeError(dataPt) {\n+                var val = computeErrorValue(dataPt);\n+                return [val, val];\n+            };\n+        }\n+        else {\n+            return function computeError(dataPt) {\n+                return [\n+                    computeErrorValueMinus(dataPt),\n+                    computeErrorValue(dataPt)\n+                ];\n+            };\n+        }\n+    }\n+};\n+\n+/**\n+ * Compute error bar magnitude (for all types except data)\n+ *\n+ * @param {string} type error bar type\n+ * @param {numeric} value error bar value\n+ *\n+ * @return {function} :\n+ *      @param {numeric} dataPt\n+ */\n+function makeComputeErrorValue(type, value) {\n+    if(type === 'percent') {\n+        return function(dataPt) {\n+            return Math.abs(dataPt * value / 100);\n+        };\n+    }\n+    if(type === 'constant') {\n+        return function() {\n+            return Math.abs(value);\n+        };\n+    }\n+    if(type === 'sqrt') {\n+        return function(dataPt) {\n+            return Math.sqrt(Math.abs(dataPt));","path":"src/components/errorbars/compute_error.js","position":91,"original_position":91,"commit_id":"66ce3fa2d42584585f257a31863d3623209af1c7","original_commit_id":"66ce3fa2d42584585f257a31863d3623209af1c7","user":{"login":"mdtusz","id":6494463,"avatar_url":"https://avatars.githubusercontent.com/u/6494463?v=3","gravatar_id":"","url":"https://api.github.com/users/mdtusz","html_url":"https://github.com/mdtusz","followers_url":"https://api.github.com/users/mdtusz/followers","following_url":"https://api.github.com/users/mdtusz/following{/other_user}","gists_url":"https://api.github.com/users/mdtusz/gists{/gist_id}","starred_url":"https://api.github.com/users/mdtusz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdtusz/subscriptions","organizations_url":"https://api.github.com/users/mdtusz/orgs","repos_url":"https://api.github.com/users/mdtusz/repos","events_url":"https://api.github.com/users/mdtusz/events{/privacy}","received_events_url":"https://api.github.com/users/mdtusz/received_events","type":"User","site_admin":false},"body":"Seems like an ideal place to use a `switch` statement. ","created_at":"2015-12-10T21:27:14Z","updated_at":"2015-12-10T21:27:14Z","html_url":"https://github.com/plotly/plotly.js/pull/91#discussion_r47288423","pull_request_url":"https://api.github.com/repos/plotly/plotly.js/pulls/91","_links":{"self":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/comments/47288423"},"html":{"href":"https://github.com/plotly/plotly.js/pull/91#discussion_r47288423"},"pull_request":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/91"}}},"pull_request":{"url":"https://api.github.com/repos/plotly/plotly.js/pulls/91","id":53032261,"html_url":"https://github.com/plotly/plotly.js/pull/91","diff_url":"https://github.com/plotly/plotly.js/pull/91.diff","patch_url":"https://github.com/plotly/plotly.js/pull/91.patch","issue_url":"https://api.github.com/repos/plotly/plotly.js/issues/91","number":91,"state":"open","locked":false,"title":"Some error bar clean ups","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":"@alexcjohnson @mdtusz @cldougl @bpostlethwaite \r\n\r\nThis PR:\r\n\r\n- fixes default logic for error bar `type: 'sqrt'` \r\n- adds test for error bar `type: 'sqrt'` (about time)\r\n- reuse svg error bar logic in 3d convert step\r\n- split error bar `default`, `calc` and reusable compute-error-magnitude routine into separate files\r\n- remove an used function","created_at":"2015-12-08T20:15:41Z","updated_at":"2015-12-10T21:27:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6ea006fa8e8430b1a3af7ee0802b2e724c04d659","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/plotly/plotly.js/pulls/91/commits","review_comments_url":"https://api.github.com/repos/plotly/plotly.js/pulls/91/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/91/comments","statuses_url":"https://api.github.com/repos/plotly/plotly.js/statuses/66ce3fa2d42584585f257a31863d3623209af1c7","head":{"label":"plotly:better-errorbars","ref":"better-errorbars","sha":"66ce3fa2d42584585f257a31863d3623209af1c7","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}","created_at":"2015-11-05T23:27:17Z","updated_at":"2015-12-10T21:24:24Z","pushed_at":"2015-12-10T21:17:37Z","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":93361,"stargazers_count":3553,"watchers_count":3553,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":176,"mirror_url":null,"open_issues_count":39,"forks":176,"open_issues":39,"watchers":3553,"default_branch":"master"}},"base":{"label":"plotly:master","ref":"master","sha":"4f0f1f7b8888b8fbd9c77b3091ac61b1fc1e8850","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}","created_at":"2015-11-05T23:27:17Z","updated_at":"2015-12-10T21:24:24Z","pushed_at":"2015-12-10T21:17:37Z","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":93361,"stargazers_count":3553,"watchers_count":3553,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":176,"mirror_url":null,"open_issues_count":39,"forks":176,"open_issues":39,"watchers":3553,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/91"},"html":{"href":"https://github.com/plotly/plotly.js/pull/91"},"issue":{"href":"https://api.github.com/repos/plotly/plotly.js/issues/91"},"comments":{"href":"https://api.github.com/repos/plotly/plotly.js/issues/91/comments"},"review_comments":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/91/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/91/commits"},"statuses":{"href":"https://api.github.com/repos/plotly/plotly.js/statuses/66ce3fa2d42584585f257a31863d3623209af1c7"}}}}