{"action":"created","comment":{"url":"https://api.github.com/repos/seadsystem/website/pulls/comments/53427035","id":53427035,"diff_hunk":"@@ -77,53 +150,179 @@ function fetch_graph(url) {\n     request.send();\n }\n \n-var chart1 = null;\n+function fetch_bar_graph(url) {\n+    var request = new XMLHttpRequest();\n+    request.onreadystatechange = function() {\n+        //console.log(request.readyState);\n+        if (request.readyState == XMLHttpRequest.DONE) {\n+            if (request.status == 200) { //200 OK\n+                //console.log(request.responseText);\n+                generate_bar_graph(JSON.parse(request.responseText));\n+            } else {\n+                console.log(\"it broke\");\n+            }\n+        }\n+    };\n+\n+    request.open(\"GET\", url, true);\n+    request.send();\n+}\n \n function generate_chart(data) {\n-    c3.generate({\n-\tbindto: '#chart',\n-\tdata: { \n+    var chart = c3.generate({\n+        padding: {\n+            top: 0,\n+            right: 100,\n+            bottom: 0,\n+            left: 100,\n+        },\n+        bindto: '#chart',\n+        data: {\n+            selection: {\n+                enabled: true,\n+                draggable: true,\n+                grouped: true\n+            },\n             x: 'x',\n-            xFormat: '%Y-%m-%d %H:%M:%S',   \n+            xFormat: '%Y-%m-%d %H:%M:%S',\n             columns: [\n-\t\t['x'].concat(data.data.map(\n+                ['x'].concat(data.data.map(\n                     function(x) {\n-\t\t\treturn x.time;\n+                        return x.time;\n                     }\n-\t\t)),\n-\t\t['energy'].concat(data.data.map(\n+                )), ['energy'].concat(data.data.map(\n                     function(x) {\n-\t\t\treturn x.energy;\n+                        return x.energy;\n                     }\n-\t\t))\n-            ], \n+                ))\n+            ],\n             types: {\n-\t\tenergy: 'area',\n+                energy: 'area',\n             }\n-\t},\n-\taxis: {\n+        },\n+        axis: {\n             x: {\n                 type: 'timeseries',\n                 tick: {\n-                    // this also works for non timeseries data\n                     format: '%H:%M'\n                 }\n             }\n-        }    \n+        }\n+    });\n+\n+    /*-- Deselect points when dragging on graph --*/\n+    $(\"#chart\").mousedown(function() {\n+        chart.unselect(['energy']);\n+    });\n+\n+    /*-- Invoke modal for labelling --*/\n+    $(\"#chart\").mouseup(function() {\n+        var elements = chart.selected('energy');\n+        if (elements.length === 0) return;\n+\n+        var start = new Date(elements[0].x); //.getTime() / 1000;\n+        var end = new Date(elements[elements.length - 1].x); //.getTime() / 1000;\n+\n+        $('#myModal').modal('toggle');\n+\n+        $(\"#start-date\").datetimepicker({\n+            format: 'MM/DD/YYYY HH:mm'\n+        });\n+        $(\"#end-date\").datetimepicker({\n+            format: 'MM/DD/YYYY HH:mm'\n+        });\n+\n+        $('#start-date').data('DateTimePicker').setDate(start);\n+        $('#end-date').data('DateTimePicker').setDate(end);\n     });\n }\n \n+function post_data_to_server(label) {\n+    //POST","path":"seadssite/static/js/graph.js","position":250,"original_position":250,"commit_id":"baa50ba8cbb85d0b5016d0c2dc45357b99d9d376","original_commit_id":"baa50ba8cbb85d0b5016d0c2dc45357b99d9d376","user":{"login":"iangudger","id":7056530,"avatar_url":"https://avatars.githubusercontent.com/u/7056530?v=3","gravatar_id":"","url":"https://api.github.com/users/iangudger","html_url":"https://github.com/iangudger","followers_url":"https://api.github.com/users/iangudger/followers","following_url":"https://api.github.com/users/iangudger/following{/other_user}","gists_url":"https://api.github.com/users/iangudger/gists{/gist_id}","starred_url":"https://api.github.com/users/iangudger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iangudger/subscriptions","organizations_url":"https://api.github.com/users/iangudger/orgs","repos_url":"https://api.github.com/users/iangudger/repos","events_url":"https://api.github.com/users/iangudger/events{/privacy}","received_events_url":"https://api.github.com/users/iangudger/received_events","type":"User","site_admin":false},"body":"Duplicate?","created_at":"2016-02-19T06:31:21Z","updated_at":"2016-02-19T06:31:21Z","html_url":"https://github.com/seadsystem/website/pull/10#discussion_r53427035","pull_request_url":"https://api.github.com/repos/seadsystem/website/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/seadsystem/website/pulls/comments/53427035"},"html":{"href":"https://github.com/seadsystem/website/pull/10#discussion_r53427035"},"pull_request":{"href":"https://api.github.com/repos/seadsystem/website/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/seadsystem/website/pulls/10","id":59903318,"html_url":"https://github.com/seadsystem/website/pull/10","diff_url":"https://github.com/seadsystem/website/pull/10.diff","patch_url":"https://github.com/seadsystem/website/pull/10.patch","issue_url":"https://api.github.com/repos/seadsystem/website/issues/10","number":10,"state":"open","locked":false,"title":"Labelling interface","user":{"login":"ramhound","id":1896842,"avatar_url":"https://avatars.githubusercontent.com/u/1896842?v=3","gravatar_id":"","url":"https://api.github.com/users/ramhound","html_url":"https://github.com/ramhound","followers_url":"https://api.github.com/users/ramhound/followers","following_url":"https://api.github.com/users/ramhound/following{/other_user}","gists_url":"https://api.github.com/users/ramhound/gists{/gist_id}","starred_url":"https://api.github.com/users/ramhound/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ramhound/subscriptions","organizations_url":"https://api.github.com/users/ramhound/orgs","repos_url":"https://api.github.com/users/ramhound/repos","events_url":"https://api.github.com/users/ramhound/events{/privacy}","received_events_url":"https://api.github.com/users/ramhound/received_events","type":"User","site_admin":false},"body":"Labelling UI in place for both live labelling and for historical labelling through the graph","created_at":"2016-02-19T04:28:39Z","updated_at":"2016-02-19T06:31:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d763d5061eeb6b4da854a12587e10c8efd06c216","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/seadsystem/website/pulls/10/commits","review_comments_url":"https://api.github.com/repos/seadsystem/website/pulls/10/comments","review_comment_url":"https://api.github.com/repos/seadsystem/website/pulls/comments{/number}","comments_url":"https://api.github.com/repos/seadsystem/website/issues/10/comments","statuses_url":"https://api.github.com/repos/seadsystem/website/statuses/baa50ba8cbb85d0b5016d0c2dc45357b99d9d376","head":{"label":"seadsystem:graph_testing","ref":"graph_testing","sha":"baa50ba8cbb85d0b5016d0c2dc45357b99d9d376","user":{"login":"seadsystem","id":7507257,"avatar_url":"https://avatars.githubusercontent.com/u/7507257?v=3","gravatar_id":"","url":"https://api.github.com/users/seadsystem","html_url":"https://github.com/seadsystem","followers_url":"https://api.github.com/users/seadsystem/followers","following_url":"https://api.github.com/users/seadsystem/following{/other_user}","gists_url":"https://api.github.com/users/seadsystem/gists{/gist_id}","starred_url":"https://api.github.com/users/seadsystem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seadsystem/subscriptions","organizations_url":"https://api.github.com/users/seadsystem/orgs","repos_url":"https://api.github.com/users/seadsystem/repos","events_url":"https://api.github.com/users/seadsystem/events{/privacy}","received_events_url":"https://api.github.com/users/seadsystem/received_events","type":"Organization","site_admin":false},"repo":{"id":44074043,"name":"website","full_name":"seadsystem/website","owner":{"login":"seadsystem","id":7507257,"avatar_url":"https://avatars.githubusercontent.com/u/7507257?v=3","gravatar_id":"","url":"https://api.github.com/users/seadsystem","html_url":"https://github.com/seadsystem","followers_url":"https://api.github.com/users/seadsystem/followers","following_url":"https://api.github.com/users/seadsystem/following{/other_user}","gists_url":"https://api.github.com/users/seadsystem/gists{/gist_id}","starred_url":"https://api.github.com/users/seadsystem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seadsystem/subscriptions","organizations_url":"https://api.github.com/users/seadsystem/orgs","repos_url":"https://api.github.com/users/seadsystem/repos","events_url":"https://api.github.com/users/seadsystem/events{/privacy}","received_events_url":"https://api.github.com/users/seadsystem/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/seadsystem/website","description":"","fork":false,"url":"https://api.github.com/repos/seadsystem/website","forks_url":"https://api.github.com/repos/seadsystem/website/forks","keys_url":"https://api.github.com/repos/seadsystem/website/keys{/key_id}","collaborators_url":"https://api.github.com/repos/seadsystem/website/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/seadsystem/website/teams","hooks_url":"https://api.github.com/repos/seadsystem/website/hooks","issue_events_url":"https://api.github.com/repos/seadsystem/website/issues/events{/number}","events_url":"https://api.github.com/repos/seadsystem/website/events","assignees_url":"https://api.github.com/repos/seadsystem/website/assignees{/user}","branches_url":"https://api.github.com/repos/seadsystem/website/branches{/branch}","tags_url":"https://api.github.com/repos/seadsystem/website/tags","blobs_url":"https://api.github.com/repos/seadsystem/website/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/seadsystem/website/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/seadsystem/website/git/refs{/sha}","trees_url":"https://api.github.com/repos/seadsystem/website/git/trees{/sha}","statuses_url":"https://api.github.com/repos/seadsystem/website/statuses/{sha}","languages_url":"https://api.github.com/repos/seadsystem/website/languages","stargazers_url":"https://api.github.com/repos/seadsystem/website/stargazers","contributors_url":"https://api.github.com/repos/seadsystem/website/contributors","subscribers_url":"https://api.github.com/repos/seadsystem/website/subscribers","subscription_url":"https://api.github.com/repos/seadsystem/website/subscription","commits_url":"https://api.github.com/repos/seadsystem/website/commits{/sha}","git_commits_url":"https://api.github.com/repos/seadsystem/website/git/commits{/sha}","comments_url":"https://api.github.com/repos/seadsystem/website/comments{/number}","issue_comment_url":"https://api.github.com/repos/seadsystem/website/issues/comments{/number}","contents_url":"https://api.github.com/repos/seadsystem/website/contents/{+path}","compare_url":"https://api.github.com/repos/seadsystem/website/compare/{base}...{head}","merges_url":"https://api.github.com/repos/seadsystem/website/merges","archive_url":"https://api.github.com/repos/seadsystem/website/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/seadsystem/website/downloads","issues_url":"https://api.github.com/repos/seadsystem/website/issues{/number}","pulls_url":"https://api.github.com/repos/seadsystem/website/pulls{/number}","milestones_url":"https://api.github.com/repos/seadsystem/website/milestones{/number}","notifications_url":"https://api.github.com/repos/seadsystem/website/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/seadsystem/website/labels{/name}","releases_url":"https://api.github.com/repos/seadsystem/website/releases{/id}","deployments_url":"https://api.github.com/repos/seadsystem/website/deployments","created_at":"2015-10-11T23:41:56Z","updated_at":"2016-02-02T01:50:50Z","pushed_at":"2016-02-19T04:28:39Z","git_url":"git://github.com/seadsystem/website.git","ssh_url":"git@github.com:seadsystem/website.git","clone_url":"https://github.com/seadsystem/website.git","svn_url":"https://github.com/seadsystem/website","homepage":null,"size":3796,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"seadsystem:master","ref":"master","sha":"6a83ff664f15e73328d382ca1c8552540580039f","user":{"login":"seadsystem","id":7507257,"avatar_url":"https://avatars.githubusercontent.com/u/7507257?v=3","gravatar_id":"","url":"https://api.github.com/users/seadsystem","html_url":"https://github.com/seadsystem","followers_url":"https://api.github.com/users/seadsystem/followers","following_url":"https://api.github.com/users/seadsystem/following{/other_user}","gists_url":"https://api.github.com/users/seadsystem/gists{/gist_id}","starred_url":"https://api.github.com/users/seadsystem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seadsystem/subscriptions","organizations_url":"https://api.github.com/users/seadsystem/orgs","repos_url":"https://api.github.com/users/seadsystem/repos","events_url":"https://api.github.com/users/seadsystem/events{/privacy}","received_events_url":"https://api.github.com/users/seadsystem/received_events","type":"Organization","site_admin":false},"repo":{"id":44074043,"name":"website","full_name":"seadsystem/website","owner":{"login":"seadsystem","id":7507257,"avatar_url":"https://avatars.githubusercontent.com/u/7507257?v=3","gravatar_id":"","url":"https://api.github.com/users/seadsystem","html_url":"https://github.com/seadsystem","followers_url":"https://api.github.com/users/seadsystem/followers","following_url":"https://api.github.com/users/seadsystem/following{/other_user}","gists_url":"https://api.github.com/users/seadsystem/gists{/gist_id}","starred_url":"https://api.github.com/users/seadsystem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seadsystem/subscriptions","organizations_url":"https://api.github.com/users/seadsystem/orgs","repos_url":"https://api.github.com/users/seadsystem/repos","events_url":"https://api.github.com/users/seadsystem/events{/privacy}","received_events_url":"https://api.github.com/users/seadsystem/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/seadsystem/website","description":"","fork":false,"url":"https://api.github.com/repos/seadsystem/website","forks_url":"https://api.github.com/repos/seadsystem/website/forks","keys_url":"https://api.github.com/repos/seadsystem/website/keys{/key_id}","collaborators_url":"https://api.github.com/repos/seadsystem/website/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/seadsystem/website/teams","hooks_url":"https://api.github.com/repos/seadsystem/website/hooks","issue_events_url":"https://api.github.com/repos/seadsystem/website/issues/events{/number}","events_url":"https://api.github.com/repos/seadsystem/website/events","assignees_url":"https://api.github.com/repos/seadsystem/website/assignees{/user}","branches_url":"https://api.github.com/repos/seadsystem/website/branches{/branch}","tags_url":"https://api.github.com/repos/seadsystem/website/tags","blobs_url":"https://api.github.com/repos/seadsystem/website/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/seadsystem/website/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/seadsystem/website/git/refs{/sha}","trees_url":"https://api.github.com/repos/seadsystem/website/git/trees{/sha}","statuses_url":"https://api.github.com/repos/seadsystem/website/statuses/{sha}","languages_url":"https://api.github.com/repos/seadsystem/website/languages","stargazers_url":"https://api.github.com/repos/seadsystem/website/stargazers","contributors_url":"https://api.github.com/repos/seadsystem/website/contributors","subscribers_url":"https://api.github.com/repos/seadsystem/website/subscribers","subscription_url":"https://api.github.com/repos/seadsystem/website/subscription","commits_url":"https://api.github.com/repos/seadsystem/website/commits{/sha}","git_commits_url":"https://api.github.com/repos/seadsystem/website/git/commits{/sha}","comments_url":"https://api.github.com/repos/seadsystem/website/comments{/number}","issue_comment_url":"https://api.github.com/repos/seadsystem/website/issues/comments{/number}","contents_url":"https://api.github.com/repos/seadsystem/website/contents/{+path}","compare_url":"https://api.github.com/repos/seadsystem/website/compare/{base}...{head}","merges_url":"https://api.github.com/repos/seadsystem/website/merges","archive_url":"https://api.github.com/repos/seadsystem/website/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/seadsystem/website/downloads","issues_url":"https://api.github.com/repos/seadsystem/website/issues{/number}","pulls_url":"https://api.github.com/repos/seadsystem/website/pulls{/number}","milestones_url":"https://api.github.com/repos/seadsystem/website/milestones{/number}","notifications_url":"https://api.github.com/repos/seadsystem/website/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/seadsystem/website/labels{/name}","releases_url":"https://api.github.com/repos/seadsystem/website/releases{/id}","deployments_url":"https://api.github.com/repos/seadsystem/website/deployments","created_at":"2015-10-11T23:41:56Z","updated_at":"2016-02-02T01:50:50Z","pushed_at":"2016-02-19T04:28:39Z","git_url":"git://github.com/seadsystem/website.git","ssh_url":"git@github.com:seadsystem/website.git","clone_url":"https://github.com/seadsystem/website.git","svn_url":"https://github.com/seadsystem/website","homepage":null,"size":3796,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/seadsystem/website/pulls/10"},"html":{"href":"https://github.com/seadsystem/website/pull/10"},"issue":{"href":"https://api.github.com/repos/seadsystem/website/issues/10"},"comments":{"href":"https://api.github.com/repos/seadsystem/website/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/seadsystem/website/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/seadsystem/website/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/seadsystem/website/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/seadsystem/website/statuses/baa50ba8cbb85d0b5016d0c2dc45357b99d9d376"}}}}