Loading an interactive SVG object | XM Community
Skip to main content
Question

Loading an interactive SVG object

  • August 8, 2022
  • 1 reply
  • 98 views

Forum|alt.badge.img+1

Hi, I am trying to insert an SVG object and have the id of that SVG element be published on the window. I have a working prototype where I have loaded an SVG element in HTML and then have some JS using D3.js to change the color and make the SVG clickable, however I am not about to get the ID printed on the side. Is there something to how variables, data structures are accessed/handled inside the Qualtrics engine?

1 reply

bgooldfed
Level 4 ●●●●
Forum|alt.badge.img+25
  • Level 4 ●●●●
  • 179 replies
  • August 10, 2022

Hi tri,
My D3 is a little rusty, but could you not add it to the canvas of your SVG object before drawing it?
Otherwise you should be able to print it using something like jQuery:
var id = getId(); //replace w/ however you get the ID
var myId = "

" + id + "
"; //wrap the ID in some HTML
jQuery("#someElement").append(myId) //append it to whatever element you want
You may need to add additional CSS to position or style it however you want.
Good luck!


Leave a Reply