基於Canvas的Char.js庫使用,canvaschar.js庫

來源:互聯網
上載者:User

基於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對象,是沒法擷取的。向量圖的才行
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.