My flot graph is not displaying any lines, problem multiplying epoch by 1000 using Integer in Java?
This is my raw data, stored in a .txt
file
epoch,value
1383229104,55559
1383229121,55559
1383229787,55565
which is parsed by a Servlet and stored inside:
Vector<Integer> points = new Vector<Integer>();
e.g
points.add(Integer.parseInt(strLine.split(",")[0]) * 1000);
points.add(Integer.parseInt(strLine.split(",")[1]));
There are multiple files, each one containing a separate series (line) to be plotted on graph.
For each Vector<Integer> points
object, they are added to ..
Vector<Dataset> datasets = new Vector<Dataset>();
Dataset has following definition:
public class Dataset {
private String name;
private Vector<Vector<Integer>> points;
Once all the files have been parsed and added to Vector<Dataset> datasets
, this object is sent client side using response.getWriter().write(new Gson().toJson(datasets));
And 'graphed' using
var datasets = JSON.parse(xmlhttp.responseText);
var plotarea = $("#placeholder");
$.plot(plotarea, [datasets[0].points, datasets[1].points, datasets[2].points, datasets[3].points, datasets[4].points], {
xaxis: {
mode: "time",
min: (new Date(2012, 0, 1)).getTime(),
max: (new Date(2015, 0, 1)).getTime()
}
});
Update: --------------------------------------------------------------------------
Debugging output within javascript.
There are 5 files being loaded into Vector<Dataset> datasets = new Vector<Dataset>();
alert(datasets) .. [object Object],[object Object],[object Object],[object Object],[object Object]
console.log(datasets) .. [object Array]
I can access values using:
alert(datasets[0].points[0][0]);
alert(datasets[0].points[0][1]);
Output will be two alert dialogs, one containing 249634688
, the second 55559
Note: 1383229104 * 1000
should not be 249634688