我正在使用JCanvas用于绘制一些弧线。但我无法为弧定义标签。 请建议如何在 Jcanvas 中定义 arc 的标签。
这是我的弧代码。
$('canvas').drawArc({
strokeStyle: 'red',
strokeWidth: 4,
rounded: true,
endArrow: true,
arrowRadius: 15,
arrowAngle: 90,
x: 175, y: 175,
start: 90,
end: 160,
radius: 150
});
最佳答案
如果您希望创建一个文本标签来伴随弧线,则需要使用 drawText()
方法 ( documented here ) 将所需的文本放置在弧线旁边。
例如:
$('canvas')
.drawArc({
strokeStyle: 'red',
strokeWidth: 4,
rounded: true,
endArrow: true,
arrowRadius: 15,
arrowAngle: 90,
x: 175, y: 175,
start: 90,
end: 160,
radius: 150
})
.drawText({
fillStyle: 'red',
fontFamily: 'sans-serif',
fontSize: 24,
text: 'My arc label',
x: 140, y: 320
});
上面的代码呈现如下:
关于javascript - 无法使用 JCanvas 定义 Arc 的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25994733/