Pregunta

I have SVG line in HTML and want to change the end coordinate.

 <svg  xmlns="http://www.w3.org/2000/svg" version="1.1" >   
   <line id="myline" x1="0" y1="0" x2="200" y2="200"
        style="stroke:rgb(255,0,0);stroke-width:2"/>  
 </svg>

In Dart code I have the following:

LineElement line = query("#myline");

I need to change x2 from 200 to 220 but I don't see x2 attribute for line. Is it possible to do that?

¿Fue útil?

Solución

LineElement does have the x2 attribute as you can see in the docs http://api.dartlang.org/docs/releases/latest/dart_svg/LineElement.html#x2.

You can set x2 through either of the following methods:

line.attributes["x2"] = "220";
line.$dom_setAttribute("x2", "220");

Otros consejos

I need to change x2 from 200 to 220 but I don't see x2 attribute for line. Is it possible to do that?

Yes and it's simple:

LineElement line = query("#myline");
line.attributes['x2'] = '220';

The attributes property can be found in every Element, including LineElement.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top