svgdotjs / svg.js

The lightweight library for manipulating and animating SVG
https://svgjs.dev
Other
11.04k stars 1.07k forks source link

wrap circle with a tag #1084

Closed necrojan closed 4 years ago

necrojan commented 4 years ago

Hi guys, this library is amazing, just a question, on how to wrap a circle with a tag? basically add a link on it.

I created the circle like this

let circle = draw.circle(radius);

// for the text
draw.plain(ele.ticket_id).attr({
                x: posX,
                y: posY,
                fill: '#fff',
                'alignment-baseline': 'central',
                'text-anchor': 'middle'
              })
// and the circle
draw.plain(ele.ticket_id).attr({
                x: posX,
                y: posY,
                fill: '#fff',
                'alignment-baseline': 'central',
                'text-anchor': 'middle'
              })

I am just wondering how can I wrap the circle with a tag so it's clickable. Thanks

Fuzzyma commented 4 years ago

There is a linkTo method on every element which basically does that. Just do circle.linkTo(url) and you are done

necrojan commented 4 years ago

awesome @Fuzzyma I missed that one. Thanks!