I designed a simple bar/line graph combination using d3.js:
https://i.stack.imgur.com/coJI9.jpg
That screenshot is from Firefox. However, when I open the same page with Chrome, it looks like this:
https://i.stack.imgur.com/L7H2o.jpg
And in Safari even worse:
https://i.stack.imgur.com/KTks5.jpg
I didn't bother to test IE.
Is this a known issue with d3.js? Because weirdly enough I could not find anything on google, so I am hoping there is indeed a mistake in my code.
EDIT:
Following up on meetamit's answer, I could narrow the problem to the sorting of the dates. Here is what it looks like:
// sort on key values
function keysrt(key, desc) {
return function (a, b) {
return desc ? ~~(a[key] < b[key]) : ~~(a[key] > b[key]);
};
}
[...]
var parseDate = d3.time.format("%Y-%m-%d").parse;
allDates = JSON.parse(allDates);
data = JSON.parse(data);
data.forEach(function (d, i) {
d.Datum = parseDate(d.Datum);
});
allDates.forEach(function (d, i) {
d.Datum = parseDate(d.Datum);
});
allDates.sort(keysrt('Datum'));
data.sort(keysrt('Datum'));
Order of array in Chrome:
Sat Jul 20 2013 00:00:00 GMT+0200 (Mitteleuropäische Sommerzeit)
einAusVis.js:57
Sat Jan 05 2013 00:00:00 GMT+0100 (Mitteleuropäische Zeit)
einAusVis.js:57
Sat Sep 15 2012 00:00:00 GMT+0200 (Mitteleuropäische Sommerzeit)
einAusVis.js:57
Sat Aug 18 2012 00:00:00 GMT+0200 (Mitteleuropäische Sommerzeit)
einAusVis.js:57
Sat Oct 13 2012 00:00:00 GMT+0200 (Mitteleuropäische Sommerzeit)
einAusVis.js:57
Sat Dec 08 2012 00:00:00 GMT+0100 (Mitteleuropäische Zeit)
einAusVis.js:57
Sat Oct 15 2011 00:00:00 GMT+0200 (Mitteleuropäische Sommerzeit)
einAusVis.js:57
And in Firefox:
Date {Sat Sep 17 2011 00:00:00 GMT+0200}
einAusVis.js (Zeile 57)
Date {Sat Oct 15 2011 00:00:00 GMT+0200}
einAusVis.js (Zeile 57)
Date {Sat Dec 10 2011 00:00:00 GMT+0100}
einAusVis.js (Zeile 57)
Date {Sat Jan 07 2012 00:00:00 GMT+0100}
einAusVis.js (Zeile 57)
Date {Sat Feb 04 2012 00:00:00 GMT+0100}
einAusVis.js (Zeile 57)
Date {Sat Mar 03 2012 00:00:00 GMT+0100}
einAusVis.js (Zeile 57)
Date {Sat Mar 31 2012 00:00:00 GMT+0200}
einAusVis.js (Zeile 57)