{"action":"created","comment":{"url":"https://api.github.com/repos/plotly/plotly.js/pulls/comments/58736287","id":58736287,"diff_hunk":"@@ -115,86 +114,114 @@ shapes.add = function(gd) {\n // if opt is blank, val can be 'add' or a full options object to add a new\n //  annotation at that point in the array, or 'remove' to delete this one\n shapes.draw = function(gd, index, opt, value) {\n-    var layout = gd.layout,\n-        fullLayout = gd._fullLayout,\n-        i;\n-\n-    // TODO: abstract out these drawAll, add, and remove blocks for shapes and annotations\n     if(!isNumeric(index) || index===-1) {\n         // no index provided - we're operating on ALL shapes\n         if(!index && Array.isArray(value)) {\n-            // a whole annotation array is passed in\n-            // (as in, redo of delete all)\n-            layout.shapes = value;\n-            shapes.supplyLayoutDefaults(layout, fullLayout);\n-            shapes.drawAll(gd);\n+            replaceAllShapes(gd, value);\n             return;\n         }\n         else if(value==='remove') {\n-            // delete all\n-            delete layout.shapes;\n-            fullLayout.shapes = [];\n-            shapes.drawAll(gd);\n+            deleteAllShapes(gd);\n             return;\n         }\n         else if(opt && value!=='add') {\n-            // make the same change to all shapes\n-            for(i = 0; i < fullLayout.shapes.length; i++) {\n-                shapes.draw(gd, i, opt, value);\n-            }\n+            updateAllShapes(gd, opt, value);\n             return;\n         }\n         else {\n             // add a new empty annotation\n-            index = fullLayout.shapes.length;\n-            fullLayout.shapes.push({});\n+            index = gd._fullLayout.shapes.length;\n+            gd._fullLayout.shapes.push({});\n         }\n     }\n \n     if(!opt && value) {\n         if(value==='remove') {\n-            fullLayout._shapelayer.selectAll('[data-index=\"'+index+'\"]')\n-                .remove();\n-            fullLayout.shapes.splice(index,1);\n-            layout.shapes.splice(index,1);\n-            for(i=index; i<fullLayout.shapes.length; i++) {\n-                fullLayout._shapelayer\n-                    .selectAll('[data-index=\"'+(i+1)+'\"]')\n-                    .attr('data-index',String(i));\n-\n-                // redraw all shapes past the removed one,\n-                // so they bind to the right events\n-                shapes.draw(gd,i);\n-            }\n+            deleteShape(gd, index);\n             return;\n         }\n         else if(value==='add' || Plotly.Lib.isPlainObject(value)) {\n-            fullLayout.shapes.splice(index,0,{});\n+            insertShape(gd, index, value);\n+        }\n+    }\n \n-            var rule = Plotly.Lib.isPlainObject(value) ?\n-                    Plotly.Lib.extendFlat({}, value) :\n-                    {text: 'New text'};\n+    updateShape(gd, index, opt, value);\n+    return;","path":"src/components/shapes/index.js","position":81,"original_position":81,"commit_id":"4488fcb7b90da2640551b7b9cd697c553f3908fc","original_commit_id":"4488fcb7b90da2640551b7b9cd697c553f3908fc","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":"no need for that `return`. Save the bytes.","created_at":"2016-04-06T16:22:05Z","updated_at":"2016-04-06T16:22:05Z","html_url":"https://github.com/plotly/plotly.js/pull/378#discussion_r58736287","pull_request_url":"https://api.github.com/repos/plotly/plotly.js/pulls/378","_links":{"self":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/comments/58736287"},"html":{"href":"https://github.com/plotly/plotly.js/pull/378#discussion_r58736287"},"pull_request":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/378"}}},"pull_request":{"url":"https://api.github.com/repos/plotly/plotly.js/pulls/378","id":64880457,"html_url":"https://github.com/plotly/plotly.js/pull/378","diff_url":"https://github.com/plotly/plotly.js/pull/378.diff","patch_url":"https://github.com/plotly/plotly.js/pull/378.patch","issue_url":"https://api.github.com/repos/plotly/plotly.js/issues/378","number":378,"state":"open","locked":false,"title":"[WIP] Fix issues #359 and #148","user":{"login":"n-riesco","id":6199391,"avatar_url":"https://avatars.githubusercontent.com/u/6199391?v=3","gravatar_id":"","url":"https://api.github.com/users/n-riesco","html_url":"https://github.com/n-riesco","followers_url":"https://api.github.com/users/n-riesco/followers","following_url":"https://api.github.com/users/n-riesco/following{/other_user}","gists_url":"https://api.github.com/users/n-riesco/gists{/gist_id}","starred_url":"https://api.github.com/users/n-riesco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/n-riesco/subscriptions","organizations_url":"https://api.github.com/users/n-riesco/orgs","repos_url":"https://api.github.com/users/n-riesco/repos","events_url":"https://api.github.com/users/n-riesco/events{/privacy}","received_events_url":"https://api.github.com/users/n-riesco/received_events","type":"User","site_admin":false},"body":"Here's an outline of the plan I'm following to fix issues #359 and #148:\r\n\r\n* [x] Split method `shapes.draw` into smaller functions\r\n* [ ] Move the creation of `shapelayer` into function `plotLayers` in `makeCartesianPlotFramwork` (this fixes #359)\r\n* [ ] Split `shapelayer` into `shapeLowerLayer` and `shapeUpperLayer` (this fixes #148)\r\n\r\nI've checked refactoring `shapes.draw`hasn't introduced new bugs by running both the image and the jasmine tests.","created_at":"2016-04-01T00:32:28Z","updated_at":"2016-04-06T16:22:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"286b2edd11f1bf1e5c40b4825047281fc3a439b0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/plotly/plotly.js/pulls/378/commits","review_comments_url":"https://api.github.com/repos/plotly/plotly.js/pulls/378/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/378/comments","statuses_url":"https://api.github.com/repos/plotly/plotly.js/statuses/4488fcb7b90da2640551b7b9cd697c553f3908fc","head":{"label":"n-riesco:issue-148-and-359","ref":"issue-148-and-359","sha":"4488fcb7b90da2640551b7b9cd697c553f3908fc","user":{"login":"n-riesco","id":6199391,"avatar_url":"https://avatars.githubusercontent.com/u/6199391?v=3","gravatar_id":"","url":"https://api.github.com/users/n-riesco","html_url":"https://github.com/n-riesco","followers_url":"https://api.github.com/users/n-riesco/followers","following_url":"https://api.github.com/users/n-riesco/following{/other_user}","gists_url":"https://api.github.com/users/n-riesco/gists{/gist_id}","starred_url":"https://api.github.com/users/n-riesco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/n-riesco/subscriptions","organizations_url":"https://api.github.com/users/n-riesco/orgs","repos_url":"https://api.github.com/users/n-riesco/repos","events_url":"https://api.github.com/users/n-riesco/events{/privacy}","received_events_url":"https://api.github.com/users/n-riesco/received_events","type":"User","site_admin":false},"repo":{"id":55012447,"name":"plotly.js","full_name":"n-riesco/plotly.js","owner":{"login":"n-riesco","id":6199391,"avatar_url":"https://avatars.githubusercontent.com/u/6199391?v=3","gravatar_id":"","url":"https://api.github.com/users/n-riesco","html_url":"https://github.com/n-riesco","followers_url":"https://api.github.com/users/n-riesco/followers","following_url":"https://api.github.com/users/n-riesco/following{/other_user}","gists_url":"https://api.github.com/users/n-riesco/gists{/gist_id}","starred_url":"https://api.github.com/users/n-riesco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/n-riesco/subscriptions","organizations_url":"https://api.github.com/users/n-riesco/orgs","repos_url":"https://api.github.com/users/n-riesco/repos","events_url":"https://api.github.com/users/n-riesco/events{/privacy}","received_events_url":"https://api.github.com/users/n-riesco/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/n-riesco/plotly.js","description":"The open source javascript graphing library that powers plotly","fork":true,"url":"https://api.github.com/repos/n-riesco/plotly.js","forks_url":"https://api.github.com/repos/n-riesco/plotly.js/forks","keys_url":"https://api.github.com/repos/n-riesco/plotly.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/n-riesco/plotly.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/n-riesco/plotly.js/teams","hooks_url":"https://api.github.com/repos/n-riesco/plotly.js/hooks","issue_events_url":"https://api.github.com/repos/n-riesco/plotly.js/issues/events{/number}","events_url":"https://api.github.com/repos/n-riesco/plotly.js/events","assignees_url":"https://api.github.com/repos/n-riesco/plotly.js/assignees{/user}","branches_url":"https://api.github.com/repos/n-riesco/plotly.js/branches{/branch}","tags_url":"https://api.github.com/repos/n-riesco/plotly.js/tags","blobs_url":"https://api.github.com/repos/n-riesco/plotly.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/n-riesco/plotly.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/n-riesco/plotly.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/n-riesco/plotly.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/n-riesco/plotly.js/statuses/{sha}","languages_url":"https://api.github.com/repos/n-riesco/plotly.js/languages","stargazers_url":"https://api.github.com/repos/n-riesco/plotly.js/stargazers","contributors_url":"https://api.github.com/repos/n-riesco/plotly.js/contributors","subscribers_url":"https://api.github.com/repos/n-riesco/plotly.js/subscribers","subscription_url":"https://api.github.com/repos/n-riesco/plotly.js/subscription","commits_url":"https://api.github.com/repos/n-riesco/plotly.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/n-riesco/plotly.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/n-riesco/plotly.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/n-riesco/plotly.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/n-riesco/plotly.js/contents/{+path}","compare_url":"https://api.github.com/repos/n-riesco/plotly.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/n-riesco/plotly.js/merges","archive_url":"https://api.github.com/repos/n-riesco/plotly.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/n-riesco/plotly.js/downloads","issues_url":"https://api.github.com/repos/n-riesco/plotly.js/issues{/number}","pulls_url":"https://api.github.com/repos/n-riesco/plotly.js/pulls{/number}","milestones_url":"https://api.github.com/repos/n-riesco/plotly.js/milestones{/number}","notifications_url":"https://api.github.com/repos/n-riesco/plotly.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/n-riesco/plotly.js/labels{/name}","releases_url":"https://api.github.com/repos/n-riesco/plotly.js/releases{/id}","deployments_url":"https://api.github.com/repos/n-riesco/plotly.js/deployments","created_at":"2016-03-29T21:41:41Z","updated_at":"2016-03-29T21:41:44Z","pushed_at":"2016-04-06T16:07:17Z","git_url":"git://github.com/n-riesco/plotly.js.git","ssh_url":"git@github.com:n-riesco/plotly.js.git","clone_url":"https://github.com/n-riesco/plotly.js.git","svn_url":"https://github.com/n-riesco/plotly.js","homepage":"https://plot.ly/javascript/","size":102521,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"plotly:master","ref":"master","sha":"048f98120d4525fe7c5e4881bb5c6781778e6272","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-06T13:31:42Z","pushed_at":"2016-04-06T16:07:17Z","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":106941,"stargazers_count":4441,"watchers_count":4441,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":337,"mirror_url":null,"open_issues_count":114,"forks":337,"open_issues":114,"watchers":4441,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/378"},"html":{"href":"https://github.com/plotly/plotly.js/pull/378"},"issue":{"href":"https://api.github.com/repos/plotly/plotly.js/issues/378"},"comments":{"href":"https://api.github.com/repos/plotly/plotly.js/issues/378/comments"},"review_comments":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/378/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/378/commits"},"statuses":{"href":"https://api.github.com/repos/plotly/plotly.js/statuses/4488fcb7b90da2640551b7b9cd697c553f3908fc"}}}}