如何清除HTML5画布上的图表,以防止触发悬停事件?

PHPz
PHPz 转载
2023-08-20 20:41:19 1000浏览

如何清除HTML5画布上的图表,以防止触发悬停事件?

var resetCanvas = function(){ $('#results-graph').remove(); $('#graph-container').append('<canvas id = "results-graph"><canvas>'); canvas = document.querySelector('#results-graph'); ct = canvas.getContext('2d'); ct.canvas.width = $('#graph').width(); // here we are resizing the new canvas element to parent width ct.canvas.height = $('#graph').height(); // here we are resizing the new canvas element to parent height var a = canvas.width/2; var b = canvas.height/2; ct.font = '12pt Calibri'; ct.textAlign = 'Align Left'; ct.fillText('left aligned text on the canvas', a, b); };

以上就是如何清除HTML5画布上的图表,以防止触发悬停事件?的详细内容,更多请关注php中文网其它相关文章!

声明:本文转载于:tutorialspoint,如有侵犯,请联系admin@php.cn删除