I’m creating some data as a string in a webservice and returning that string for use with jqPlot. My problem is that the jqPlot is expecting an object and im struggling to get my string into the correct format.
This working example is fine as the line1 variable is constructed as an object
var line1 = [['2007-02-18 00:00:00',4980],['2007-02-24 09:50:00',4230],['2007-05-20 00:00:00',5060]]
var plot1 = $.jqplot('chart1', [line1], {
title: 'Test Plot',
title: 'Data with Dates',
axes: { xaxis: { renderer: $.jqplot.DateAxisRenderer} },
});
In my scenario a webservice is returning line one as a string:
line1 = "[['2007-02-18 00:00:00',4980],['2007-02-24 09:50:00',4230],['2007-05-20 00:00:00',5060]]"
How do I manipulate this string so I can use it as an array for jqPlot, as in the working example?
Since you’re using jQuery already anyway, why not throw it into the utility function made especially for dealing with this problem?