Stack Exchange
TypeError: rawData[row] is undefined
I am creating a bar chart that loads in XML data with jquery. But for some reason I get TypeError: rawData[row] is undefined. This code here works and what happens at row is it gets an date and it splits the day month and year and parses it to an int. So 21/04/2016 it will get 04 and parses it to an int.
rawData= [
  ['Month', 'Identified transaction', 'Identified counterparty, verification needed', 'Unidentified transaction'],     
  ['Jan', 0, 0, 0],
  ['Feb', 0, 0, 0],
  ['Mar', 0, 0, 0],
  ['Apr', 0, 0, 0],
  ['May', 0, 0, 0],
  ['Jun', 0, 0, 0],
  ['Jul', 0, 0, 0],
  ['Aug', 0, 0, 0],
  ['Sept', 0, 0, 0],
  ['Oct', 0, 0, 0],
  ['Nov', 0, 0, 0],
  ['Dec', 0, 0, 0]
];

<!-- loop for each row -->
xmlData.find('item').each(function(){
    var col;
    var row;

    /* loop for each column */
    $j(this).find('column').each(function(){
        var colID = $j(this).attr("columnid"); 

        /* Get value and store in variable */
        var value = $j(this).find('displayData').text();

        /* Selecting specific column */
        if(colID == columns["Category"]){
          /* Compare value to String element and store the information in the template */
          if(value === "Identified transaction"){
            col = rawData[0].indexOf("Identified transaction");
          }else if(value === "Identified transaction above threshold"){ 
            col = rawData[0].indexOf("Identified transaction");
          }else if(value === "Identified transaction, unidentified type"){
            col = rawData[0].indexOf("Identified transaction");
          }else if(value === "Identified transaction, above cumulative threshold"){ 
            col = rawData[0].indexOf("Identified transaction");
          }else if(value === "Identified transaction, frequency limit"){
            col = rawData[0].indexOf("Identified transaction");
          }else if(value === "Identified transaction, unidentified currency"){
            col = rawData[0].indexOf("Identified transaction");
          }else if(value === "Identified counterparty frequency limit"){ 
             col = rawData[0].indexOf("Identified counterparty, verification needed");
          }else if(value === "Identified counterparty unidentified type"){ 
             col = rawData[0].indexOf("Identified counterparty, verification needed");
          }else if(value === "Identified counterparty unidentified amount"){ 
             col = rawData[0].indexOf("Identified counterparty, verification needed");
          }else if(value === "Identified counterparty, unidentified transaction, above overall threshold"){
             col = rawData[0].indexOf("Identified counterparty, verification needed");
          }else if(value === "Identified counterparty, unidentified transaction, within overall threshold"){
             col = rawData[0].indexOf("Identified counterparty, verification needed");
          }else if(value === "Identified counterparty, unidentified amount, above overall threshold"){
             col = rawData[0].indexOf("Identified counterparty, verification needed");
          }else if(value === "Identified counterparty, unidentified amount, within overall threshold"){
             col = rawData[0].indexOf("Identified counterparty, verification needed");
          }else if(value === "Identified counterparty, unidentified amount, above overall threshold"){
             col = rawData[0].indexOf("Identified counterparty, verification needed");
          }else if(value === "Identified counterparty, unidentified amount, within overall threshold"){
             col = rawData[0].indexOf("Identified counterparty, verification needed");
          }else if(value === "Unidentified transaction"){
            col = rawData[0].indexOf("Unidentified transaction");
          }else if(value === "Unidentified counterparty"){
            col = rawData[0].indexOf("Unidentified transaction");
          }else if(value === "Unidentified transaction, within overall threshold"){
            col = rawData[0].indexOf("Unidentified transaction");
          }
        }
        <!-- dividing the data so it does not end up all in 1 bar. The divider here is the date of when an transaction was created -->
        else{
          var date = $j(this).find('displayData').text();
          var res = date.split("/");
          row = parseInt(res[1]);
        }
    })

    rawData[row][col]++;
})

drawStacked(rawData);

But now I'm trying based on an other column with words as strings. This is an example of how I approach it:
else{
var ID;
if(value == "Jan"){
  ID = 1;
} if(value == "Feb"){
              ID = 2; 
} if(value == "Mar"){
  ID = 3;
} if(value == "Apr"){
  ID = 4;
} if(value == "May"){
  ID = 5;
} if(value == "Jun"){
  ID = 6;
} if(value == "Jul"){
  ID = 7;
} if(value == "Aug"){
  ID = 8;
} if(value == "Sept"){
  ID = 9;
} if(value == "Oct"){
  ID = 10;
}
row = ID;
}

What am I doing wrong here?

row is only ever defined if you go into the else block

@kylestephens this is inside an else block. i shall update it

did that fix it?

@kylestephens Well like i said it was already in an else block. So this is not what caused the error...
