{"action":"created","comment":{"url":"https://api.github.com/repos/chartjs/Chart.js/pulls/comments/208939720","pull_request_review_id":144853325,"id":208939720,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwODkzOTcyMA==","diff_hunk":"@@ -361,27 +361,54 @@ function generate(min, max, capacity, options) {\n  * Returns the right and left offsets from edges in the form of {left, right}.\n  * Offsets are added when the `offset` option is true.\n  */\n-function computeOffsets(table, ticks, min, max, options) {\n+function computeOffsets(table, ticks, data, min, max, options) {\n+\tvar pos = [];\n+\tvar minInterval = 1;\n+\tvar timeOpts = options.time;\n+\tvar barThickness = options.barThickness;\n \tvar left = 0;\n \tvar right = 0;\n-\tvar upper, lower;\n-\n-\tif (options.offset && ticks.length) {\n-\t\tif (!options.time.min) {\n-\t\t\tupper = ticks.length > 1 ? ticks[1] : max;\n-\t\t\tlower = ticks[0];\n-\t\t\tleft = (\n-\t\t\t\tinterpolate(table, 'time', upper, 'pos') -\n-\t\t\t\tinterpolate(table, 'time', lower, 'pos')\n-\t\t\t) / 2;\n+\tvar i, ilen, curr, prev, length, width;\n+\n+\tif (options.offset) {\n+\t\tdata.forEach(function(timestamp) {\n+\t\t\tif (timestamp >= min && timestamp <= max) {\n+\t\t\t\tpos.push(interpolate(table, 'time', timestamp, 'pos'));\n+\t\t\t}\n+\t\t});\n+\n+\t\tif (!barThickness) {\n+\t\t\t[data, ticks].forEach(function(timestamps) {","path":"src/scales/scale.time.js","position":32,"original_position":32,"commit_id":"adaeffa935d3ef99f8337e11d319d1ebe3c13416","original_commit_id":"adaeffa935d3ef99f8337e11d319d1ebe3c13416","user":{"login":"nagix","id":723188,"node_id":"MDQ6VXNlcjcyMzE4OA==","avatar_url":"https://avatars3.githubusercontent.com/u/723188?v=4","gravatar_id":"","url":"https://api.github.com/users/nagix","html_url":"https://github.com/nagix","followers_url":"https://api.github.com/users/nagix/followers","following_url":"https://api.github.com/users/nagix/following{/other_user}","gists_url":"https://api.github.com/users/nagix/gists{/gist_id}","starred_url":"https://api.github.com/users/nagix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nagix/subscriptions","organizations_url":"https://api.github.com/users/nagix/orgs","repos_url":"https://api.github.com/users/nagix/repos","events_url":"https://api.github.com/users/nagix/events{/privacy}","received_events_url":"https://api.github.com/users/nagix/received_events","type":"User","site_admin":false},"body":"Yes, I will add this.","created_at":"2018-08-09T13:59:51Z","updated_at":"2018-08-09T13:59:51Z","html_url":"https://github.com/chartjs/Chart.js/pull/4658#discussion_r208939720","pull_request_url":"https://api.github.com/repos/chartjs/Chart.js/pulls/4658","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/chartjs/Chart.js/pulls/comments/208939720"},"html":{"href":"https://github.com/chartjs/Chart.js/pull/4658#discussion_r208939720"},"pull_request":{"href":"https://api.github.com/repos/chartjs/Chart.js/pulls/4658"}},"in_reply_to_id":207714705},"pull_request":{"url":"https://api.github.com/repos/chartjs/Chart.js/pulls/4658","id":135731204,"node_id":"MDExOlB1bGxSZXF1ZXN0MTM1NzMxMjA0","html_url":"https://github.com/chartjs/Chart.js/pull/4658","diff_url":"https://github.com/chartjs/Chart.js/pull/4658.diff","patch_url":"https://github.com/chartjs/Chart.js/pull/4658.patch","issue_url":"https://api.github.com/repos/chartjs/Chart.js/issues/4658","number":4658,"state":"open","locked":false,"title":"Improve offset calculation for scale.offset option","user":{"login":"nagix","id":723188,"node_id":"MDQ6VXNlcjcyMzE4OA==","avatar_url":"https://avatars3.githubusercontent.com/u/723188?v=4","gravatar_id":"","url":"https://api.github.com/users/nagix","html_url":"https://github.com/nagix","followers_url":"https://api.github.com/users/nagix/followers","following_url":"https://api.github.com/users/nagix/following{/other_user}","gists_url":"https://api.github.com/users/nagix/gists{/gist_id}","starred_url":"https://api.github.com/users/nagix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nagix/subscriptions","organizations_url":"https://api.github.com/users/nagix/orgs","repos_url":"https://api.github.com/users/nagix/repos","events_url":"https://api.github.com/users/nagix/events{/privacy}","received_events_url":"https://api.github.com/users/nagix/received_events","type":"User","site_admin":false},"body":"The offsets of time scales are currently calculated based on tick intervals, but it causes too much margin or short of margin depending on scale configuration or datasets. The proposed code calculates the offsets based on timestamps of labels and data. It also fixes offset calculation in case that a chart has a single data point.\r\n\r\nCurrent version: https://jsfiddle.net/q4fo65aa/\r\nProposed version: https://jsfiddle.net/sfhwd1by/\r\n\r\nFixes #5312","created_at":"2017-08-15T03:59:18Z","updated_at":"2018-08-09T13:59:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6d337df1d6b0b022a4f62becdc1d8548fb87cca8","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":816781021,"node_id":"MDU6TGFiZWw4MTY3ODEwMjE=","url":"https://api.github.com/repos/chartjs/Chart.js/labels/status:%20stale","name":"status: stale","color":"dddddd","default":false},{"id":32309886,"node_id":"MDU6TGFiZWwzMjMwOTg4Ng==","url":"https://api.github.com/repos/chartjs/Chart.js/labels/type:%20enhancement","name":"type: enhancement","color":"1d76db","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/chartjs/Chart.js/pulls/4658/commits","review_comments_url":"https://api.github.com/repos/chartjs/Chart.js/pulls/4658/comments","review_comment_url":"https://api.github.com/repos/chartjs/Chart.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/chartjs/Chart.js/issues/4658/comments","statuses_url":"https://api.github.com/repos/chartjs/Chart.js/statuses/adaeffa935d3ef99f8337e11d319d1ebe3c13416","head":{"label":"nagix:offset-calc","ref":"offset-calc","sha":"adaeffa935d3ef99f8337e11d319d1ebe3c13416","user":{"login":"nagix","id":723188,"node_id":"MDQ6VXNlcjcyMzE4OA==","avatar_url":"https://avatars3.githubusercontent.com/u/723188?v=4","gravatar_id":"","url":"https://api.github.com/users/nagix","html_url":"https://github.com/nagix","followers_url":"https://api.github.com/users/nagix/followers","following_url":"https://api.github.com/users/nagix/following{/other_user}","gists_url":"https://api.github.com/users/nagix/gists{/gist_id}","starred_url":"https://api.github.com/users/nagix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nagix/subscriptions","organizations_url":"https://api.github.com/users/nagix/orgs","repos_url":"https://api.github.com/users/nagix/repos","events_url":"https://api.github.com/users/nagix/events{/privacy}","received_events_url":"https://api.github.com/users/nagix/received_events","type":"User","site_admin":false},"repo":{"id":95035064,"node_id":"MDEwOlJlcG9zaXRvcnk5NTAzNTA2NA==","name":"Chart.js","full_name":"nagix/Chart.js","owner":{"login":"nagix","id":723188,"node_id":"MDQ6VXNlcjcyMzE4OA==","avatar_url":"https://avatars3.githubusercontent.com/u/723188?v=4","gravatar_id":"","url":"https://api.github.com/users/nagix","html_url":"https://github.com/nagix","followers_url":"https://api.github.com/users/nagix/followers","following_url":"https://api.github.com/users/nagix/following{/other_user}","gists_url":"https://api.github.com/users/nagix/gists{/gist_id}","starred_url":"https://api.github.com/users/nagix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nagix/subscriptions","organizations_url":"https://api.github.com/users/nagix/orgs","repos_url":"https://api.github.com/users/nagix/repos","events_url":"https://api.github.com/users/nagix/events{/privacy}","received_events_url":"https://api.github.com/users/nagix/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nagix/Chart.js","description":"Simple HTML5 Charts using the <canvas> tag","fork":true,"url":"https://api.github.com/repos/nagix/Chart.js","forks_url":"https://api.github.com/repos/nagix/Chart.js/forks","keys_url":"https://api.github.com/repos/nagix/Chart.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nagix/Chart.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nagix/Chart.js/teams","hooks_url":"https://api.github.com/repos/nagix/Chart.js/hooks","issue_events_url":"https://api.github.com/repos/nagix/Chart.js/issues/events{/number}","events_url":"https://api.github.com/repos/nagix/Chart.js/events","assignees_url":"https://api.github.com/repos/nagix/Chart.js/assignees{/user}","branches_url":"https://api.github.com/repos/nagix/Chart.js/branches{/branch}","tags_url":"https://api.github.com/repos/nagix/Chart.js/tags","blobs_url":"https://api.github.com/repos/nagix/Chart.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nagix/Chart.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nagix/Chart.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/nagix/Chart.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nagix/Chart.js/statuses/{sha}","languages_url":"https://api.github.com/repos/nagix/Chart.js/languages","stargazers_url":"https://api.github.com/repos/nagix/Chart.js/stargazers","contributors_url":"https://api.github.com/repos/nagix/Chart.js/contributors","subscribers_url":"https://api.github.com/repos/nagix/Chart.js/subscribers","subscription_url":"https://api.github.com/repos/nagix/Chart.js/subscription","commits_url":"https://api.github.com/repos/nagix/Chart.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/nagix/Chart.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/nagix/Chart.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/nagix/Chart.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/nagix/Chart.js/contents/{+path}","compare_url":"https://api.github.com/repos/nagix/Chart.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nagix/Chart.js/merges","archive_url":"https://api.github.com/repos/nagix/Chart.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nagix/Chart.js/downloads","issues_url":"https://api.github.com/repos/nagix/Chart.js/issues{/number}","pulls_url":"https://api.github.com/repos/nagix/Chart.js/pulls{/number}","milestones_url":"https://api.github.com/repos/nagix/Chart.js/milestones{/number}","notifications_url":"https://api.github.com/repos/nagix/Chart.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nagix/Chart.js/labels{/name}","releases_url":"https://api.github.com/repos/nagix/Chart.js/releases{/id}","deployments_url":"https://api.github.com/repos/nagix/Chart.js/deployments","created_at":"2017-06-21T18:39:42Z","updated_at":"2018-08-08T14:54:11Z","pushed_at":"2018-08-08T14:53:59Z","git_url":"git://github.com/nagix/Chart.js.git","ssh_url":"git@github.com:nagix/Chart.js.git","clone_url":"https://github.com/nagix/Chart.js.git","svn_url":"https://github.com/nagix/Chart.js","homepage":"http://www.chartjs.org/","size":9616,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"chartjs:master","ref":"master","sha":"88308c600cbbd38458bc94549ca6139698508c58","user":{"login":"chartjs","id":10342521,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwMzQyNTIx","avatar_url":"https://avatars1.githubusercontent.com/u/10342521?v=4","gravatar_id":"","url":"https://api.github.com/users/chartjs","html_url":"https://github.com/chartjs","followers_url":"https://api.github.com/users/chartjs/followers","following_url":"https://api.github.com/users/chartjs/following{/other_user}","gists_url":"https://api.github.com/users/chartjs/gists{/gist_id}","starred_url":"https://api.github.com/users/chartjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chartjs/subscriptions","organizations_url":"https://api.github.com/users/chartjs/orgs","repos_url":"https://api.github.com/users/chartjs/repos","events_url":"https://api.github.com/users/chartjs/events{/privacy}","received_events_url":"https://api.github.com/users/chartjs/received_events","type":"Organization","site_admin":false},"repo":{"id":8843683,"node_id":"MDEwOlJlcG9zaXRvcnk4ODQzNjgz","name":"Chart.js","full_name":"chartjs/Chart.js","owner":{"login":"chartjs","id":10342521,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwMzQyNTIx","avatar_url":"https://avatars1.githubusercontent.com/u/10342521?v=4","gravatar_id":"","url":"https://api.github.com/users/chartjs","html_url":"https://github.com/chartjs","followers_url":"https://api.github.com/users/chartjs/followers","following_url":"https://api.github.com/users/chartjs/following{/other_user}","gists_url":"https://api.github.com/users/chartjs/gists{/gist_id}","starred_url":"https://api.github.com/users/chartjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chartjs/subscriptions","organizations_url":"https://api.github.com/users/chartjs/orgs","repos_url":"https://api.github.com/users/chartjs/repos","events_url":"https://api.github.com/users/chartjs/events{/privacy}","received_events_url":"https://api.github.com/users/chartjs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chartjs/Chart.js","description":"Simple HTML5 Charts using the <canvas> tag","fork":false,"url":"https://api.github.com/repos/chartjs/Chart.js","forks_url":"https://api.github.com/repos/chartjs/Chart.js/forks","keys_url":"https://api.github.com/repos/chartjs/Chart.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chartjs/Chart.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chartjs/Chart.js/teams","hooks_url":"https://api.github.com/repos/chartjs/Chart.js/hooks","issue_events_url":"https://api.github.com/repos/chartjs/Chart.js/issues/events{/number}","events_url":"https://api.github.com/repos/chartjs/Chart.js/events","assignees_url":"https://api.github.com/repos/chartjs/Chart.js/assignees{/user}","branches_url":"https://api.github.com/repos/chartjs/Chart.js/branches{/branch}","tags_url":"https://api.github.com/repos/chartjs/Chart.js/tags","blobs_url":"https://api.github.com/repos/chartjs/Chart.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chartjs/Chart.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chartjs/Chart.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/chartjs/Chart.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chartjs/Chart.js/statuses/{sha}","languages_url":"https://api.github.com/repos/chartjs/Chart.js/languages","stargazers_url":"https://api.github.com/repos/chartjs/Chart.js/stargazers","contributors_url":"https://api.github.com/repos/chartjs/Chart.js/contributors","subscribers_url":"https://api.github.com/repos/chartjs/Chart.js/subscribers","subscription_url":"https://api.github.com/repos/chartjs/Chart.js/subscription","commits_url":"https://api.github.com/repos/chartjs/Chart.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/chartjs/Chart.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/chartjs/Chart.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/chartjs/Chart.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/chartjs/Chart.js/contents/{+path}","compare_url":"https://api.github.com/repos/chartjs/Chart.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chartjs/Chart.js/merges","archive_url":"https://api.github.com/repos/chartjs/Chart.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chartjs/Chart.js/downloads","issues_url":"https://api.github.com/repos/chartjs/Chart.js/issues{/number}","pulls_url":"https://api.github.com/repos/chartjs/Chart.js/pulls{/number}","milestones_url":"https://api.github.com/repos/chartjs/Chart.js/milestones{/number}","notifications_url":"https://api.github.com/repos/chartjs/Chart.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chartjs/Chart.js/labels{/name}","releases_url":"https://api.github.com/repos/chartjs/Chart.js/releases{/id}","deployments_url":"https://api.github.com/repos/chartjs/Chart.js/deployments","created_at":"2013-03-17T23:56:36Z","updated_at":"2018-08-09T13:55:57Z","pushed_at":"2018-08-08T16:52:58Z","git_url":"git://github.com/chartjs/Chart.js.git","ssh_url":"git@github.com:chartjs/Chart.js.git","clone_url":"https://github.com/chartjs/Chart.js.git","svn_url":"https://github.com/chartjs/Chart.js","homepage":"http://www.chartjs.org/","size":10116,"stargazers_count":38717,"watchers_count":38717,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8948,"mirror_url":null,"archived":false,"open_issues_count":473,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":8948,"open_issues":473,"watchers":38717,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chartjs/Chart.js/pulls/4658"},"html":{"href":"https://github.com/chartjs/Chart.js/pull/4658"},"issue":{"href":"https://api.github.com/repos/chartjs/Chart.js/issues/4658"},"comments":{"href":"https://api.github.com/repos/chartjs/Chart.js/issues/4658/comments"},"review_comments":{"href":"https://api.github.com/repos/chartjs/Chart.js/pulls/4658/comments"},"review_comment":{"href":"https://api.github.com/repos/chartjs/Chart.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/chartjs/Chart.js/pulls/4658/commits"},"statuses":{"href":"https://api.github.com/repos/chartjs/Chart.js/statuses/adaeffa935d3ef99f8337e11d319d1ebe3c13416"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"nagix"}}