element 'elementName': path data missing a moveto [Archive] - XML Elves

element 'elementName': path data missing a moveto

Anonymous
07-26-2005, 02:34 PM
Hi there,
I am stuck at this point since last two days :cry: :cry: . I have explicitely mentioned moveto character M with point, I still get this error. the peice of code where I get this error: element 'curve': path data missing a moveto

any variable starting with "js_" is a javascript variable.
curve is an svg path defined in another script language called DSP.

the partial related code is shown below. I can draw a graph for the first time, after I move a point, the graph just stays unchanged and I get the above mentioned error. I would really appreciate it if someone can show any error here.

<script language="JavaScript" type="text/javascript">
<!&#91;CDATA&#91;
function reDraw&#40;&#41;
trace="M"+js_X&#91;0&#93;+" "+js_Y&#91;0&#93;+"L";
for &#40;i=1;i<js_Y.length;i++&#41;
&#123;trace=trace+js_X&#91;i&#93;+"'"+js_Y&#91;i&#93;+" "&#125;;
trace="' "+trace+ "' stroke='yellow' fill='none' stroke-width='5' ";
curve.setAttribute&#40;"d",trace&#41;;
alert&#40;trace&#41;;

&#125;


function movePoint&#40;evt&#41;
&#123;
y=evt.getClientY&#40;&#41;;

js_Y&#91;i&#93;=&#40;js_min + js_size*&#40;450-y&#41;/450&#41;;

reDraw&#40;&#41;;
&#125;
&#125;

&#93;&#93;></script>


<!-- DSP
iGraph = "<path id='curve' d='M" + js_X&#91;0&#93; + "," + js_Y&#91;0&#93;;
for&#40;i=1;i<js_Y.size;i++&#41;
iGraph += "L" + js_X&#91;i&#93; + "," + js_Y&#91;i&#93;;

iGraph += "' stroke='yellow' fill='none' stroke-width='5'/>";
graph.render&#40;&#41;;
-->


<!-- DSPOBJECT name = graph
iGraph
-->

Anonymous
07-27-2005, 02:51 AM
function reDraw&#40;&#41;
trace="M"+js_X&#91;0&#93;+" "+js_Y&#91;0&#93;+"L";
for &#40;i=1;i<js_Y.length;i++&#41;
&#123;trace=trace+js_X&#91;i&#93;+"'"+js_Y&#91;i&#93;+" "&#125;;
trace="' "+trace+ "' stroke='yellow' fill='none' stroke-width='5' ";
curve.setAttribute&#40;"d",trace&#41;;
alert&#40;trace&#41;;


I see some mistakes
"'" as separator between coordinates
you cannot put stroke, fill ... in d attribute

function reDraw&#40;&#41;
trace="M"+js_X&#91;0&#93;+","+js_Y&#91;0&#93;+"L";
for &#40;i=1;i<js_Y.length;i++&#41;
&#123;trace=trace+"L" + js_X&#91;i&#93;+","+js_Y&#91;i&#93;+" "&#125;;
curve.setAttribute&#40;"d",trace&#41;;
curve.setAttribute&#40;"stroke",'yellow'&#41;;
curve.setAttribute&#40;"fill",'none'&#41;;
curve.setAttribute&#40;"stroke-width",'5'&#41;;
alert&#40;trace&#41;;


Michel

Anonymous
07-27-2005, 07:31 AM
Dear Michale,

Thank you very much for your reply. I have tried your suggestion too, and with your suggestion, I get following error: element 'curve': path data command 'L' bad or missing Parameter(s)

I have range of values in js_Y[] : 6.900000000000000e-001 thru 1.197000000000000e-001
if that matters...

Thanks a lot again
DD

Anonymous
07-27-2005, 10:02 AM
Now since I changed the code as mentioned above, it redraws graph at some wierd points, I get correct point valies for alert(curve,getAttribute("d")) . I still don't know what I'm doing wrong....

I would really appreciate it if someone would help me...

function reDraw&#40;&#41; &#123;
trace="M"+js_X&#91;0&#93;+","+js_Y&#91;0&#93;+"L";
for &#40;i=1;i<js_Y.length;i++&#41;
&#123;trace=trace+"L" + js_X&#91;i&#93;+" "+js_Y&#91;i&#93;&#125;;
curve.setAttribute&#40;"d",trace&#41;;
curve.setAttribute&#40;"stroke",'yellow'&#41;;
curve.setAttribute&#40;"fill",'none'&#41;;
curve.setAttribute&#40;"stroke-width",'5'&#41;;
alert&#40;curve.getAttribute&#40;"d"&#41;&#41;;
&#125;

Anonymous
07-28-2005, 05:36 AM
I don't see L command before for(...)
Try this


function reDraw() {
trace="M"+js_X[0]+","+js_Y[0];
for (i=1;i<js_Y.length;i++)
{trace=trace+"L" + js_X[i]+" "+js_Y[i]};
curve.setAttribute("d",trace);
curve.setAttribute("stroke",'yellow');
curve.setAttribute("fill",'none');
curve.setAttribute("stroke-width",'5');
alert(curve.getAttribute("d"));
}

Michel

Anonymous
08-03-2005, 10:06 AM
Thank u Michel,

I got a correct graph, I also needed to transform the array values to match the sacle, that was what missing!

Thanks a Lot!

 
Web mp2kmag.com
mapforums.com

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum