.bars div {\r\n height:0%;\r\n -webkit-transition: 0.4s ease;\r\n -moz-transition: 0.4s ease;\r\n -ms-transition: 0.4s ease;\r\n -o-transition: 0.4s ease;\r\n transition: 0.4s ease;\r\n -webkit-transition: height 0.5s;\r\n -moz-transition: height 0.5s;\r\n -ms-transition: height 0.5s;\r\n -o-transition: height 0.5s;\r\n transition: height 0.5s;\r\n}<\/pre>\nThe javascript used to set the values on the bar.<\/p>\n
chart.appendChild(barchart);\r\n\/\/our chart is rendered\r\ndocument.getElementById('chart').innerHTML = chart.outerHTML;\r\n\r\n\/\/now we set the bar heights\r\nsetTimeout(function(){ \r\n for (var i = 0; i < chartjson.data.length; i++) {\r\n var bar = document.getElementById('bar'+i);\r\n bar.style.height = chartjson.data[i][chartjson.ykey] + prefix;\r\n }\r\n}, 300);<\/pre>\nI have used setTimeout<\/code> to get our desired animation. You may\u00a0use jquery animate\u00a0to achieve the same\u00a0effect but for a simple animation, I guess you don’t want to\u00a0include a massive jquery library. In my\u00a0next post we\u00a0will try to make a directive for our chart\u00a0which we will\u00a0reuse to show multiple bar charts on the same page.<\/p>\n <\/p>\n
<\/p>\n","protected":false},"excerpt":{"rendered":"
This is in continuation of my\u00a0previous post\u00a0about creating Bar chart, we will try to add some more features to our chart to make it look more\u00a0appealing with minimal changes. List of things we will add in this version of chart. x-axis and y-axis labels. y-axis line Animate the bars We will work on the same […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,2],"tags":[52,48],"_links":{"self":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts\/245"}],"collection":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/comments?post=245"}],"version-history":[{"count":1,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts\/245\/revisions"}],"predecessor-version":[{"id":1647,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts\/245\/revisions\/1647"}],"wp:attachment":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/media?parent=245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/categories?post=245"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/tags?post=245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}