You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I provide all the dates as day.month.year, e.g. 16.08.2018. The thing is that it shows points on x axis correctly only if they cannot be treated as American date format. For example, when I have 1.08.2018, the point on the plot is incorrectly selected for 8.1.2018. And when I have 16.08.2018, it is correctly treated as 16.8.2018. This error happens in Chrome but not in Firefox.
What could be the reason of this strange behavior and what is the solution to it? Thanks!
PS There is this line
d[j][0] = new $.jsDate(d[j][0]).getTime();
in jqplot.dateAxisRenderer.js
I have checked that the values are different in Firefox and Chrome. I've saved values of d[j][0] before and after the call to this line of code, with the use of console.log.
For Chrome: before 31.07.2018, after 1532988000000, before 31.07.2018, after 1532988000000, before 01.08.2018, after 1515366000000, before 31.07.2018, after 1533031200000
For Firefox: before 31.07.2018, after 1532988000000, before 31.07.2018, after 1532988000000, before 01.08.2018, after 1533074400000, before 31.07.2018, after 1533031200000
This value is different by browser for 1/08. So it looks like getTime() works in different way in Chrome and Firefox.
PS2 Further it is set in the line 10684 in jquery.jqplot.js:
ms = Date.parse(current);
where current is "01.08.2018" and ms is 1515366000000. As far as I know, Date.parse uses MM/DD/YYYY by default.
Changing this line to
ms = moment(current, "DD.MM.YYYY")
seems to solve the issue. Unfortunately, it breaks something else, i.e. when this line of code
var nmonths = mend.diff(mstart, 'month');
is executed from DateAxisRenderer, it then reaches jsDate.diff, jsDate and jsDate.createDate and ends with "d2.getFullYear is not a function" in this place:
var diffYears = d1.getFullYear() - d2.getFullYear();
PS3 The same problem is present if I use original version of jqPlot and have only renderer specified, without options:
xaxis: {
renderer: $.jqplot.DateAxisRenderer,
}
PS4 The following code worked for me but I would be happier if I could receive the real fix:
// Original code: ms = Date.parse(current);
// Workaround:
if (current.indexOf('/') !== -1 || current.indexOf('GMT') !== -1) {
ms = Date.parse(current);
} else {
if (current.indexOf(':') !== -1) {
ms = moment(current, "DD.MM.YYYY HH:mm");
} else {
ms = moment(current, "DD.MM.YYYY");
}
}
The text was updated successfully, but these errors were encountered:
Hi, first of all thanks for your library.
I'm using jqPlot 1.0.9 to create line chart as follows:
I provide all the dates as day.month.year, e.g. 16.08.2018. The thing is that it shows points on x axis correctly only if they cannot be treated as American date format. For example, when I have 1.08.2018, the point on the plot is incorrectly selected for 8.1.2018. And when I have 16.08.2018, it is correctly treated as 16.8.2018. This error happens in Chrome but not in Firefox.
What could be the reason of this strange behavior and what is the solution to it? Thanks!
PS There is this line
d[j][0] = new $.jsDate(d[j][0]).getTime();
in jqplot.dateAxisRenderer.js
I have checked that the values are different in Firefox and Chrome. I've saved values of d[j][0] before and after the call to this line of code, with the use of console.log.
For Chrome: before 31.07.2018, after 1532988000000, before 31.07.2018, after 1532988000000, before 01.08.2018, after 1515366000000, before 31.07.2018, after 1533031200000
For Firefox: before 31.07.2018, after 1532988000000, before 31.07.2018, after 1532988000000, before 01.08.2018, after 1533074400000, before 31.07.2018, after 1533031200000
This value is different by browser for 1/08. So it looks like getTime() works in different way in Chrome and Firefox.
PS2 Further it is set in the line 10684 in jquery.jqplot.js:
ms = Date.parse(current);
where current is "01.08.2018" and ms is 1515366000000. As far as I know, Date.parse uses MM/DD/YYYY by default.
Changing this line to
ms = moment(current, "DD.MM.YYYY")
seems to solve the issue. Unfortunately, it breaks something else, i.e. when this line of code
var nmonths = mend.diff(mstart, 'month');
is executed from DateAxisRenderer, it then reaches jsDate.diff, jsDate and jsDate.createDate and ends with "d2.getFullYear is not a function" in this place:
var diffYears = d1.getFullYear() - d2.getFullYear();
PS3 The same problem is present if I use original version of jqPlot and have only renderer specified, without options:
PS4 The following code worked for me but I would be happier if I could receive the real fix:
The text was updated successfully, but these errors were encountered: