基於Canvas的Char.js庫使用,canvaschar.js庫
Chart.js是基於Html5 Canvas的圖表庫。
官網:http://www.chartjs.org/
參考文檔:http://www.chartjs.org/docs/
支援六種圖表,對應源碼相對目錄如下。
bar
doughnut
line
pie
polar-area
radar
js 對於canvas 哪位給看一下下面的代碼 為何canvasonmousemove不可以響應
var canvas=document.getElementById('canvas');var oDiv = document.getElementById('div1')var polygons=[];// ctx聲明在外面var ctx;function renderVessels(){var canvas=document.getElementById('canvas'); //var ctx = canvas.getContext('2d'); // 不要varctx = canvas.getContext('2d'); for (var i = 0; i < 10; i++) {a= Math.random()*canvas.widthb= Math.random()*canvas.heightvar polygon =new Polygon(a, b, ctx.strokeStyle, ctx.fillstyle) ctx.beginPath();ctx.fillStyle = "#00FF00";polygon.createPath(ctx);polygon.fill(ctx);ctx.closePath(); polygons.push(polygon);} }//多邊形建立var Point = function(x,y){this.x= x;this.y=y;}var Polygon = function (centerX, centerY, strokeStyle, fillStyle) { this.x = centerX; this.y = centerY; //this.vesselnum = vesselnum; this.strokeStyle = strokeStyle; this.fillStyle = fillStyle; }Polygon.prototype={getPoints: function(){var points=[];for (var i=0; i < 10; ++i) { points.push(new Point(this.x,this.y)); } return points;},createPath: function(ctx){var points=this.getPoints();ctx.beginPath();for (var i=0; i < 10; ++i) {ctx.arc(points[i].x,points[i].y,15,0,Math.PI*2,true);}ctx.closePath();},fill: function(ctx) { ctx.save(); this.createPath(ctx); ctx.fillStyle = this.fillStyle; ctx.fill(); ctx.restore();}} function windowToCanvas(x, y) { return { x: x , ......餘下全文>>
怎用js獲得html5中用canvas畫出來的對象?急
畫出來的圖形不是DOM對象,是沒法擷取的。向量圖的才行