问题
I try to use jqplot for drawing an graph. So i modified this example in order to get an date based graph.
Currently my code is like this:
var plot1 = $.jqplot('chartdiv', [[["2010-12-25.14:19:47",1],
["2010-11-25.14:19:47",2],
["2010-10-25.14:19:47",3]]], {
title: 'mytitle',
series: [{
label: 'my label',
neighborThreshold: -1
}],
axes: {
xaxis: {
renderer: $.jqplot.DateAxisRenderer,
// min:'August 1, 2010 16:00:00',
tickInterval: '1 months',
tickOptions:{formatString:'%Y-%m-%d.%H:%M:%S'}
},
yaxis: {
tickOptions:{formatString:'$%.2f'}
}
},
cursor:{
show: true,
zoom:true,
showTooltip:false
}
});
But I get the following error:
this.proxy.getTime is not a function
(function(w){var l;w.fn.emptyForce=fun...))?([nAscboxXuidfegpEGP])/g})(jQuery);
It looks like, the script have problems by parsing the date format. But why?
thank you, for any kind of help.
//Update.. ups, I found the reason very quickly after writing this post (and after 1 day of try-and-error" ;-) ) So the reason I found generates a new question: is there any jqplot option, to define how to parse the input date format?
回答1:
...sorry, after reading the documentation the 3rd time, I found the error:
The date input format is wrong.
I though, that tickOptions:{formatString:'%Y-%m-%d.%H:%M:%S'}
will define "how to parse the input data". But it is only relevant for displaying the data, not for parsing the input string.
But on this "formatString" you can guess, how jqPlot will parse the input date. So i had to change the input format to something like that: 2011-09-18 02:00:00
Byt the way: is there any jqplot option, to define how to parse the input date format?
回答2:
The errors is caused when jqPlot does not recognise the date format. The string format is auto detected (probably by the standard Date method).
To fix this, correct the string format, for example: 12/25/12
for December 25th, 2012.
回答3:
Change "2010-12-25.14:19:47"
to "25-12-10"
. I don't know how to include the time :/
回答4:
I recently had exactly the same problem (convert a Timestamp Unix to use it with JQPlote).
I noticed that nobody here has found the whole date format used by JQPlot. So, for future users who will come here for the solution:
yyyy/mm/dd h:mm
Found on JQPlot's website
Notice that the hour can be displayed with only one digit or two.
来源:https://stackoverflow.com/questions/6689993/jqplot-this-proxy-gettime-is-not-a-function-date-input-parser