Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 使HTML5画布响应悬停事件_Jquery_Html_Canvas - Fatal编程技术网

Jquery 使HTML5画布响应悬停事件

Jquery 使HTML5画布响应悬停事件,jquery,html,canvas,Jquery,Html,Canvas,我正在使用以下代码绘制HTML5画布图表: <canvas id="myChart" width="400" height="400"></canvas> var ctx = $("#myChart").get(0).getContext("2d"); ctx.beginPath(); ctx.arc(200,200,scaleAnimation * doughnutRadius,cumulativeAngle,cumulativeAngle + segmentAng

我正在使用以下代码绘制HTML5画布图表:

<canvas id="myChart" width="400" height="400"></canvas>

var ctx =  $("#myChart").get(0).getContext("2d");
ctx.beginPath();
ctx.arc(200,200,scaleAnimation * doughnutRadius,cumulativeAngle,cumulativeAngle + segmentAngle,false);
ctx.arc(width/2,height/2,scaleAnimation * cutoutRadius,cumulativeAngle + segmentAngle,cumulativeAngle,true);
ctx.closePath();
ctx.fillStyle = data[i].color;
ctx.fill();
cumulativeAngle += segmentAngle;

var ctx=$(“#myChart”).get(0.getContext(“2d”);
ctx.beginPath();
ctx.arc(200200,缩放图像*圆环,累积角度,累积角度+分段角度,假);
ctx.弧(宽度/2,高度/2,缩放图像*切割半径,累积角度+分段角度,累积角度,真值);
ctx.closePath();
ctx.fillStyle=数据[i]。颜色;
ctx.fill();
累计角度+=分段角度;
我没有在这里包括所有变量声明,因为它们不是必需的。这实际上是一个甜甜圈图。我想让图表像morris.js制作的图表一样具有响应性


也就是说,将鼠标悬停在各个线段上,将显示值和标签。jsbin示例具有不同的实现。当使用HTML5画布元素时,也可以这样做吗?

canvas不提供内置功能,但您当然可以读取鼠标坐标,然后计算您在画布上绘制的光标将位于哪个“元素”上。这是否可取?在性能方面,还是我应该努力实现不同的实现?您是否尝试过CanvasEngine?