首页 > 代码库 > easy-pie-chart和excanvas的兼容性问题
easy-pie-chart和excanvas的兼容性问题
之前多次调节IE的canvas兼容性,总结如下:
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"/> <title>jQuery</title> <meta name="viewport" content="width=device-width"/> <link rel="stylesheet" href="http://www.mamicode.com/style.css"/> <script src="http://www.mamicode.com/excanvas.compiled.js"></script> <script> // IE function.bind polyfill if (!Function.prototype.bind) { Function.prototype.bind = function (oThis) { if (typeof this !== "function") { // closest thing possible to the ECMAScript 5 internal IsCallable function throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); } var aArgs = Array.prototype.slice.call(arguments, 1), fToBind = this, fNOP = function () {}, fBound = function () { return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments))); }; fNOP.prototype = this.prototype; fBound.prototype = new fNOP(); return fBound; }; } </script> </head> <body> <ul> <li><a href="http://www.mamicode.com/index.html">Vanilla JS</a></li> <li><a href="http://www.mamicode.com/jquery.html">jQuery plugin</a></li> <li><a href="http://www.mamicode.com/angular.html">Angular module</a></li> </ul> <p>Demo for old Internet Explorer Versions 7 and 8 with <a href="http://excanvas.sourceforge.net" target="_blank">excanvas</a> and a Function.bind polyfill.</p> <span class="chart" data-percent="86"> <span class="percent"></span> </span> <span class="btn js_update">Update chart</span> <script src="http://www.91liren.com:80/js/jquery.min.js"></script> <script src="http://www.mamicode.com/dist/jquery.easypiechart.min.js"></script> <script> $(function() { var $chart = $(‘.chart‘); $chart.easyPieChart({ onStep: function(from, to, percent) { $(this.el).find(‘.percent‘).text(Math.round(percent)); } }); var chart = window.chart = $chart.data(‘easyPieChart‘); chart.update($chart.data(‘percent‘)); $(‘.js_update‘).on(‘click‘, function() { chart.update(Math.random()*200-100); }); }); </script> </body> </html>
easy-pie-chart和excanvas的兼容性问题
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。