如何使用svg.js添加链接或使用标签包裹圆圈

时间:2020-02-20 12:15:00

标签: 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
          });

但是我不确定如何用标签将圆圈或文本包裹起来,以便使其可单击。我在svg.js文档中没有看到任何示例。

1 个答案:

答案 0 :(得分:0)

好的,因此只需在其元素上添加一个linkTo(url-here)

相关问题