In order to remedy this problem, we need the closing price to be the first y
value in our data array. We can accomplish this by modifying our dataPull
function. We save the previous code as a new file and start making our changes executing the following steps:
We create a new array called
stocks
, and then loop through theremoteData
array. We add the date, which is the first element, and then we add the closing price, which is the last element in theremoteData
array:... function dataPull(remoteData,options) { var stocks = new Array; for(var x=0;x<remoteData.length;x++){ stocks[x] = new Array; stocks[x].push(remoteData[x][0],remoteData[x][4]);
We now have our
x
andy
values, so we loop through the rest of the prices in the child array. Once we finish working throughremoteData
, we return our new array to jqPlot:for(var y=1;y<remoteData[x].length;y++){ stocks[x].push(remoteData[x][y]); } } return...