使HTML5画布响应悬停事件

时间:2013-10-23 08:12:45

标签: jquery html5 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 + 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;

我没有在这里包含所有变量声明,因为它们不是必需的。这基本上是一个圆环图。我想让图表响应,就像用morris.js here制作的图表一样。

即将鼠标悬停在各个段上,显示值和标签。 jsbin示例具有不同的实现。使用HTML5 canvas元素时可以做同样的事吗?

0 个答案:

没有答案
相关问题