I am trying to add a custom thousand separator and decimal character in D3.js I followed below link but that solution is for version 3.4.11 but I am looking to make it for version 5.7.0: How to add a (custom) thousand separator in D3?
Below is the code:
// custom localization options
var myLocale = {
"decimal": ",",
"thousands": ".",
"grouping": [3],
"currency": ["$", ""]
}
// create custom locale formatter from the given locale options
const localeFormatter = d3.locale(myLocale);
const formater = ",.2f";
// create a formatter for the number (grouped thousands with two significant digits). By default ',' means 'thousands' but we switched that into a '.' in our custom localization
const numberFormat = localeFormatter.numberFormat(formater);
// test
//alert(numberFormat(10235.6789)); // "1.000.000"
//$("#number").html(numberFormat(10235.6789))
document.getElementById('number').innerHTML = numberFormat(10235.6789)
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>
<p id="number">
</p>