用D3中的轴上的逗号替换小数点?

cal*_*ula 2 javascript localization decimal-point d3.js

这是关于D3中轴的刻度:有没有办法用数字中的逗号替换小数点?我希望数字显示如下(在德国这是正常的,这么大的数字只是为了演示)

1.000.000,1 // This is one million and a tenth
Run Code Online (Sandbox Code Playgroud)

而不是这样的:

1,000,000.1
Run Code Online (Sandbox Code Playgroud)

我已经阅读了有关该主题的文档,但似乎没有可能!?到目前为止,这是我的相关代码:

localeFormatter = d3.locale({
                "decimal": ".",
                "thousands": ",",
                "grouping": [3],
                "currency": ["", "€"],
                "dateTime": "%a, %e %b %Y, %X",
                "date": "%d.%m.%Y",
                "time": "%H:%M:%S",
                "periods": ["", ""],
                "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", "Dec"]
            });


numberFormat = localeFormatter.numberFormat("04.,"); // The setting is applied, but has not the desired effect...

yAxis = d3.svg.axis()
                .scale(y)
                .orient("left")
                .tickFormat(numberFormat);
Run Code Online (Sandbox Code Playgroud)

Jan*_*aan 5

使用以下设置d3.locale:

var localeFormatter = d3.locale({
      "decimal": ",",
      "thousands": ".",
      ...
    });
Run Code Online (Sandbox Code Playgroud)

请注意,我已经改变了.in ,,反之亦然.与:

var numberFormat = localeFormatter.numberFormat(",.2f"); 
Run Code Online (Sandbox Code Playgroud)

我使用千位分隔符,(它使用.区域设置中定义的)和逗号后的两位数来打印数字.2f:

console.log(numberFormat(1000000.1)); // "1.000.000,10"
Run Code Online (Sandbox Code Playgroud)