Jump to content

Soggy

Members
  • Posts

    2
  • Joined

  • Last visited

About Soggy

  • Birthday 11/06/1979

Profile Information

  • Location
    Doncaster, UK

Soggy's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Cheers for the help, not quite got it working yet but will need to mess around a little I think.
  2. Hi, I am fairly new to javascript and still finding my feet so if i am not been clear in my question let me know. I am using the chart.js to build graphs in my docuemnts and it works great, I am now trying to expand this by linking to an xml file I have set up. If I use the following code I can retrieve the data fine: xmlDoc=loadXMLDoc("rego.xml");var nSubOrg = xmlDoc.getElementsByTagName('SubOrg');var nRev = xmlDoc.getElementsByTagName('Revenue');var nCol = xmlDoc.getElementsByTagName('Colour');var nHL = xmlDoc.getElementsByTagName('HLight'); //chart data for Chart.JS var dData = [ { value: (nRev[0].childNodes[0].nodeValue), color: (nCol[0].childNodes[0].nodeValue), highlight: (nHL[0].childNodes[0].nodeValue), label: (nSubOrg[0].childNodes[0].nodeValue) }, { value: (nRev[1].childNodes[0].nodeValue), color: (nCol[1].childNodes[0].nodeValue), highlight: (nHL[1].childNodes[0].nodeValue), label: (nSubOrg[1].childNodes[0].nodeValue) }, { value: (nRev[2].childNodes[0].nodeValue), color: (nCol[2].childNodes[0].nodeValue), highlight: (nHL[2].childNodes[0].nodeValue), label: (nSubOrg[2].childNodes[0].nodeValue) }]; However I am trying to make this a bit more functional so want to loop through to create the multidimension array. I have found other snippets which gve me an idea about how to do this but I just can't get it work. I think something like this should but can't get my head round the exact syntax: xmlDoc=loadXMLDoc("rego.xml");var nSubOrg = xmlDoc.getElementsByTagName('SubOrg');var nRev = xmlDoc.getElementsByTagName('Revenue');var nCol = xmlDoc.getElementsByTagName('Colour');var nHL = xmlDoc.getElementsByTagName('HLight');//try and build arrayvar dData=new array[()]for (i=0; i<nRev.length; i++) { dData[i].push( value: (nRev[i].childNodes[0].nodeValue), color: (nCol[i].childNodes[0].nodeValue), highlight: (nHL[i].childNodes[0].nodeValue), label: (nSubOrg[i].childNodes[0].nodeValue) ); }; Any help would be appreciated. Cheers Soggy
×
×
  • Create New...