Help with a line chart using XML and arrays

Posted by 334455 
Help with a line chart using XML and arrays
May 21, 2009 02:27PM
I cant get the line graph to work, it feels like i have tried everything, but its my first real try doing anything with javascript. Since its a school project i cant add the XML file, but i'm certain the calls for the variables are right. Heres the code, please help me.

This is all in <BODY> tag, and i have the proper code in <head> tag as well.

<div id="pulsgraf">This is just a replacement in case Javascript is not available or used for SEO purposes</div>

<script type="text/javascript">
var xmlDoc=null;
xmlDoc.async=false;
xmlDoc.load( "G3.TCX" ) ;

var x=xmlDoc.getElementsByTagName("Trackpoint" );
var pulsArray = new Array();
var metersArray = new Array();

for (i=0;i<x.length;i++){
pulsArray[ i ]=x[ i ].getElementsByTagName("Value" )[0].childNodes[0].nodeValue;
metersArray[ i ]=x[ i ].getElementsByTagName("DistanceMeters" )[0].childNodes[0].nodeValue;
}

var myData = new Array();

for(b=0;b<x.length;b++){
mydata[ b ]= pulsArray[ b ], metersArray[ b ];
}

var myChart = new JSChart('pulsgraf', 'line');
myChart.setDataArray(myData);
myChart.draw();
</script>
Re: Help with a line chart using XML and arrays
May 21, 2009 07:43PM
Hi!
I'm new to this also, but it appears that you declare the myData, but try to use mydata. Maybe this is not the problem...
var myData = new Array();
mydata[ b ]= pulsArray[ b ], metersArray[ b ];
Sorry, you do not have permission to post/reply in this forum.