{"action":"created","issue":{"url":"https://api.github.com/repos/nnnick/Chart.js/issues/604","labels_url":"https://api.github.com/repos/nnnick/Chart.js/issues/604/labels{/name}","comments_url":"https://api.github.com/repos/nnnick/Chart.js/issues/604/comments","events_url":"https://api.github.com/repos/nnnick/Chart.js/issues/604/events","html_url":"https://github.com/nnnick/Chart.js/issues/604","id":41906677,"number":604,"title":"Extension: Bar with Bar value written inside it","user":{"login":"guykatz","id":2852437,"avatar_url":"https://avatars.githubusercontent.com/u/2852437?v=3","gravatar_id":"","url":"https://api.github.com/users/guykatz","html_url":"https://github.com/guykatz","followers_url":"https://api.github.com/users/guykatz/followers","following_url":"https://api.github.com/users/guykatz/following{/other_user}","gists_url":"https://api.github.com/users/guykatz/gists{/gist_id}","starred_url":"https://api.github.com/users/guykatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guykatz/subscriptions","organizations_url":"https://api.github.com/users/guykatz/orgs","repos_url":"https://api.github.com/users/guykatz/repos","events_url":"https://api.github.com/users/guykatz/events{/privacy}","received_events_url":"https://api.github.com/users/guykatz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nnnick/Chart.js/labels/Needs%20test%20case","name":"Needs test case","color":"006b75"},{"url":"https://api.github.com/repos/nnnick/Chart.js/labels/New%20chart%20types","name":"New chart types","color":"fef2c0"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2014-09-04T08:08:32Z","updated_at":"2015-12-21T21:13:36Z","closed_at":"2015-12-21T21:13:36Z","body":"needed something lime this so I have written it. I am not even sure if it did not exists :)\r\nthe outcome is this: http://oi58.tinypic.com/11m87bb.jpg\r\nthe extension code is this (note that its tested only for my specific purposes. I am not sure I did it right):\r\n\r\n````\r\nChart.types.Bar.extend({\r\n    name: \"Bar2\",\r\n\t//override draw only to draw the bar value inside the bar when ease is 1 (the last call to draw) or when its undefined which is when drawing tooltips\r\n\tdraw : function(ease){\r\n\t\tvar ctx = this.chart.ctx;\r\n\t\t\t\t\tif(ease===1 || ease === undefined){\r\n\t\t\t\t\t\tChart.helpers.each(this.datasets,function(dataset,datasetIndex){\r\n\t\t\t\t\t\t\tChart.helpers.each(dataset.bars,function(bar,index){\r\n\t\t\t\t\t\t\t\tvar origFill = ctx.fillStyle;\r\n\t\t\t\t\t\t\t\tvar origFont = ctx.font;\r\n\t\t\t\t\t\t\t\tvar origAlign = ctx.textAlign;\r\n\t\t\t\t\t\t\t\tctx.fillStyle=\"rgba(0,0,0,0.5);\";//bar.fillColor;//\"rgba(255, 0, 0, 0.5)\";\r\n\t\t\t\t\t\t\t\tctx.font=Math.round(bar.width/7)+\"px Arial\";\r\n\t\t\t\t\t\t\t\tctx.textAlign=\"center\"; \r\n\t\t\t\t\t\t\t\tctx.fillText(bar.value,bar.x,((bar.value/this.scale.max)*bar.base)/2+bar.y);\r\n\t\t\t\t\t\t\t\tctx.fillStyle=origFill;\r\n\t\t\t\t\t\t\t\tctx.font=origFont;\r\n\t\t\t\t\t\t\t\tctx.textAlign=origAlign; \r\n\t\t\t\t\t\t\t},this);\r\n\t\t\t\t\t\t},this);\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tChart.types.Bar.prototype.draw.apply(this, arguments);\r\n\t\t\t\t\t}\r\n\t}\r\n});"},"comment":{"url":"https://api.github.com/repos/nnnick/Chart.js/issues/comments/166424432","html_url":"https://github.com/nnnick/Chart.js/issues/604#issuecomment-166424432","issue_url":"https://api.github.com/repos/nnnick/Chart.js/issues/604","id":166424432,"user":{"login":"fulldecent","id":382183,"avatar_url":"https://avatars.githubusercontent.com/u/382183?v=3","gravatar_id":"","url":"https://api.github.com/users/fulldecent","html_url":"https://github.com/fulldecent","followers_url":"https://api.github.com/users/fulldecent/followers","following_url":"https://api.github.com/users/fulldecent/following{/other_user}","gists_url":"https://api.github.com/users/fulldecent/gists{/gist_id}","starred_url":"https://api.github.com/users/fulldecent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fulldecent/subscriptions","organizations_url":"https://api.github.com/users/fulldecent/orgs","repos_url":"https://api.github.com/users/fulldecent/repos","events_url":"https://api.github.com/users/fulldecent/events{/privacy}","received_events_url":"https://api.github.com/users/fulldecent/received_events","type":"User","site_admin":false},"created_at":"2015-12-21T21:13:36Z","updated_at":"2015-12-21T21:13:36Z","body":"Closing as needs test case, please reopen if test case is available."}}