svg - 如何使用 svg.js 添加链接或用标签包裹圆圈
问题描述
我正在使用 svg.js 创建内部带有文本并居中的圆圈 我能够做到这一点
let draw = SVG('main');
// this is for the text
draw.plain(ele.ticket_id).attr({
x: posX,
y: posY,
fill: '#fff',
'alignment-baseline': 'central',
'text-anchor': 'middle'
})
.font({
size: Number((radius/2) * .5).toFixed(2)
});
// and this creates the circle
circle.animate(500, 'quadIn').attr({
fill: '#f06',
id: element.ticket_id,
class: element.status,
cx: posX,
cy: posY
});
但我不确定如何用 a 标签包裹圆圈或文本,所以它应该是可点击的。我在 svg.js 文档中没有看到任何示例。
解决方案
好的,它只是向元素添加一个 linkTo(url-here)
推荐阅读
- android - Android SDK - 您是否需要下载带有 Android API 版本的源代码?
- oracle - 如何在 Oracle Apex 4.2 中上传多个文件
- c# - CefSharp - 是否可以将 IFrame.ViewSource() 保存到特定文件名中?
- asp.net-mvc - 将Web API数据加载到.NET Core App中“查看”页面上的“Slug”?
- html - 使用 css 更改悬停时的 src 图像
- wpf - 如何更改 ComboBox 的皮肤?
- centos - 在 KVM 主机上使用 iptables 设置 nat 时,无法路由到设置为在主机启动时自动启动的 VM
- javascript - 分组条形图下的对齐标签
- sql - SQL - 使用两个表中的属性进行选择
- c++ - g++ 编译器没有为未定义的方法生成错误/警告