I am looking to utilize data stored in a JavaScript array of strings to create a d3 graph that showcases a time series of timestamp (t), receive (rx), and transmit (tx) counters. Each element in the array represents one line of time, rx, tx data with comma separators. Instead of using d3.request based methods, I have already retrieved the file from the server using server-side Lua code and inserted the data into the page using jslines.push(string).
109 // Displaying current results
110 for (i=0; i < jslines.length; i++) {
111 console.log(i + ": " + jslines[i]);
112 }
The section above confirms that the data is as described. At this stage, I am focused on extracting each of the 3 data values from a 'line' and then repeating the process. I am not concerned if they remain as strings at this point, as they will be converted to numbers later.
I am using https://github.com/d3/d3-dsv/blob/master/README.md#csvParseRows as my guide, although it seems like I may be misunderstanding the necessary steps.
114 var dataArray = d3.csvParseRows(jslines, function(d, i) {
115 return {
116 time: d[0],
117 rx: d[1],
118 tx: d[2]
119 };
120 });
I would appreciate any kind suggestions or a functional example of how to parse and prepare data using d3 that is not retrieved directly from a remote or local file by d3 itself. Many examples available seem to involve pulling file content across to the client station through d3, which I aim to avoid.
Thank you, Alan