vendredi 13 février 2015

Adding an Image to svg


I am trying to add an image to a certain element within a svg in Javascript. I am trying



$( 'g.nv-label' ).each(function(i, obj){
$( obj ).append('<image x="20" class="klasse" y="20" width="100"
height="100" xlink:href="http://goo.gl/IkKMb5" />');
});


... which does not show my element.


If i try



$( 'g.nv-label' ).each(function(i, obj){
$( obj ).append("svg:image")
.attr("xlink:href", "http://goo.gl/IkKMb5")
.attr("height", 100)
.attr("width", 100)
.attr("class", "klasse");
});


it adds the element, but not as a <img>, but as <g> (which does not show my image defined in the href).


Can anyone tell me how to do it right?





Aucun commentaire:

Enregistrer un commentaire