I'm new to jQuery and jQplot.
I have a web application that needs to plot an array of points onto a graph. The graph is just showing up blank and the problem is that I don't know where it's running into trouble...
The body of code that is responsible for executing the plot is very simple, see below:
function graphData(priceData){
var options =
{
series:[{showMarker:false}],
axes:
{
xaxis:
{
renderer:$.jqplot.DateAxisRenderer,
tickOptions:{ formatString:'%H:%M:%S' },
tickInterval:'15 second'
},
yaxis:
{
numberTicks: 6,
tickOptions:{formatString:'%.2f'}
}
}
}
var plot = $.jqplot('chartContainer',[[data]], options);
}
And all I'm seeing is a blank canvas. Just to be clear I went and checked what my data array was made of, and sure enough it's a 2D array where each nested array looks like [X-Coord, Y-Coord], here's a sample
["08:11:15", "29.21"] ["08:12:35", "29.21"] ["08:13:44", "29.25"] ["08:14:58", "29.24"] ["08:16:12", "29.25"] ["08:17:22", "29.21"]
To my knowledge, this type of array (that contains arrays of coordinate pairs) is the recomended default for jQplot, no? From the documentation I've looked at it seems to me that the input data is perfect for the plot. I can't see where I am messing up.
If it helps, the array comes from a CSV file, when the CSV is read it triggers a callback to the plotting function from above ^^^ the CSV fetch function is shown below:
$(document).ready(function(){
$.jqplot.config.enablePlugins = true;
$.ajax({
url: "data/sample.csv",
async: true,
success: function (csvd) {
data = $.csv.toArrays(csvd);
},
dataType: "text",
complete: function (data) { graphData(data); }
});
});