1

I am using svg.js to create circles with text inside and centered I was able to do that

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
          });

But I am unsure how to wrap the circle or the text with an a tag so it should be clickable. I don't see any examples in the svg.js documentation.

dashred
  • 131
  • 1
  • 12

1 Answers1

1

Okay so its just adding a linkTo(url-here) to the element

dashred
  • 131
  • 1
  • 12
  • mandatory link to the corresponding docs: https://svgjs.com/docs/2.7/parents/#link-constructor or for 3.0: https://svgjs.com/docs/3.0/container-elements/#link-constructor – Fuzzyma Feb 21 '20 at 06:31
  • Updated link to docs: https://svgjs.dev/docs/3.0/container-elements/#link-constructor – neurino Nov 10 '22 at 11:39