mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 14:45:35 +00:00
Fix up formats for d3 v4
This commit is contained in:
@@ -31,7 +31,8 @@ export function getLanguage(langCode) {
|
||||
|
||||
let currentTerms = lang.terms;
|
||||
let d3Locale = d3.formatLocale(lang.formats);
|
||||
let gen = d3Locale.format('n');
|
||||
let gen = d3Locale.format('');
|
||||
const round = function(x, n) { var ten_n = Math.pow(10,n); return Math.round(x * ten_n) / ten_n; }
|
||||
|
||||
if(lang === EN) {
|
||||
translate = (t, x) => { return currentTerms[t + '_' + x] || currentTerms[t] || t; };
|
||||
@@ -41,7 +42,7 @@ export function getLanguage(langCode) {
|
||||
|
||||
return {
|
||||
formats: {
|
||||
gen, // General number format (.e.g 1,001,001.1234)
|
||||
gen, // General number format (.e.g 1,001,001.1234)
|
||||
int: d3Locale.format(',.0f'), // Fixed to 0 decimal places (.e.g 1,001)
|
||||
f1: d3Locale.format(',.1f'), // Fixed to 1 decimal place (.e.g 1,001.1)
|
||||
f2: d3Locale.format(',.2f'), // Fixed to 2 decimal places (.e.g 1,001.10)
|
||||
@@ -51,10 +52,8 @@ export function getLanguage(langCode) {
|
||||
r1: d3Locale.format('.1r'), // Rounded to 1 significant number (.e.g 512 => 500, 4.122 => 4)
|
||||
r2: d3Locale.format('.2r'), // Rounded to 2 significant numbers (.e.g 512 => 510, 4.122 => 4.1)
|
||||
rPct: d3Locale.format('.0%'), // % to 0 decimal places (.e.g 5%)
|
||||
round1: d3Locale.format('.1r'), // Rounded to 0-1 decimal places (.e.g 5.1, 4)
|
||||
round: d3Locale.format('.2r'), // Rounded to 0-2 decimal places (.e.g 5.12, 4.1)
|
||||
//round1: (d) => gen(d3.round(d, 1)), // Rounded to 0-1 decimal places (.e.g 5.1, 4)
|
||||
//round: (d) => gen(d3.round(d, 2)), // Rounded to 0-2 decimal places (.e.g 5.12, 4.1)
|
||||
round1: (d) => gen(round(d, 1)), // Round to 0-1 decimal places (e.g. 5.1, 4)
|
||||
round: (d) => gen(round(d, 2)), // Rounded to 0-2 decimal places (.e.g 5.12, 4.1)
|
||||
time: (d) => (d < 0 ? '-' : '') + Math.floor(Math.abs(d) / 60) + ':' + ('00' + Math.floor(Math.abs(d) % 60)).substr(-2, 2)
|
||||
},
|
||||
translate,
|
||||
|
||||
Reference in New Issue
Block a user