D3.locale () in d3.js v4, localization

I am using d3.js for diagrams and now I want to upgrade it to version v4.

It was discovered that it d3.locale()no longer works from the moment all date formats are translated into another language.

How can i fix this? I dig a forum, but for v4 I really did not find it.

+4
source share
2 answers

You must use d3.timeFormatDefaultLocale(definition)in d3 V4.

Here is an example of German days and months:

 d3.timeFormatDefaultLocale({
        "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"]
    })
+5
source

It looks like you want d3-time-formathere

https://github.com/d3/d3/blob/master/API.md

-1
source

Source: https://habr.com/ru/post/1655378/


All Articles