Last active
September 25, 2023 12:47
-
-
Save woolfg/50b1ee17c8e4aa4c8a92 to your computer and use it in GitHub Desktop.
d3.js german locale - create time scale axis with german locale
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var germanFormatters = d3.locale({ | |
"decimal": ",", | |
"thousands": ".", | |
"grouping": [3], | |
"currency": ["€", ""], | |
"dateTime": "%a %b %e %X %Y", | |
"date": "%d.%m.%Y", | |
"time": "%H:%M:%S", | |
"periods": ["AM", "PM"], | |
"days": ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"], | |
"shortDays": ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"], | |
"months": ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"], | |
"shortMonths": ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"] | |
}); | |
var customTimeFormat = germanFormatters.timeFormat.multi([ | |
[".%L", function(d) { return d.getMilliseconds(); }], | |
[":%S", function(d) { return d.getSeconds(); }], | |
["%I:%M", function(d) { return d.getMinutes(); }], | |
["%Hh", function(d) { return d.getHours(); }], | |
["%a %d", function(d) { return d.getDay() && d.getDate() != 1; }], | |
["%b %d", function(d) { return d.getDate() != 1; }], | |
["%B", function(d) { return d.getMonth(); }], | |
["%Y", function() { return true; }] | |
]); | |
var xAxis = d3.svg.axis() | |
.scale(x) | |
.orient("bottom") | |
.tickFormat(customTimeFormat); |
it is not
Agu but Aug
thanks a lot!
changed to real DE locale and fixed typo ;) - thanks
Januar only takes one n
.
Januar only takes one
n
.
thanks @i-am-the-slime ... changed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note, this is Austrian German (de_at).