@d3plus/format 3.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -0
- package/es/index.js +4 -0
- package/es/src/format.js +14 -0
- package/es/src/formatAbbreviate.js +77 -0
- package/es/src/formatDate.js +108 -0
- package/es/src/formatDefaultLocale.js +12 -0
- package/package.json +42 -0
- package/umd/d3plus-format.full.js +1745 -0
- package/umd/d3plus-format.full.js.map +1 -0
- package/umd/d3plus-format.full.min.js +126 -0
- package/umd/d3plus-format.js +260 -0
- package/umd/d3plus-format.js.map +1 -0
- package/umd/d3plus-format.min.js +53 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/*
|
|
2
|
+
@d3plus/format v3.0.0
|
|
3
|
+
JavaScript formatters for localized numbers and dates.
|
|
4
|
+
Copyright (c) 2025 D3plus - https://d3plus.org
|
|
5
|
+
@license MIT
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
(function (factory) {
|
|
9
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
10
|
+
factory();
|
|
11
|
+
})((function () { 'use strict';
|
|
12
|
+
|
|
13
|
+
if (typeof window !== "undefined") {
|
|
14
|
+
(function () {
|
|
15
|
+
try {
|
|
16
|
+
if (typeof SVGElement === 'undefined' || Boolean(SVGElement.prototype.innerHTML)) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
} catch (e) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function serializeNode (node) {
|
|
24
|
+
switch (node.nodeType) {
|
|
25
|
+
case 1:
|
|
26
|
+
return serializeElementNode(node);
|
|
27
|
+
case 3:
|
|
28
|
+
return serializeTextNode(node);
|
|
29
|
+
case 8:
|
|
30
|
+
return serializeCommentNode(node);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function serializeTextNode (node) {
|
|
35
|
+
return node.textContent.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function serializeCommentNode (node) {
|
|
39
|
+
return '<!--' + node.nodeValue + '-->'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function serializeElementNode (node) {
|
|
43
|
+
var output = '';
|
|
44
|
+
|
|
45
|
+
output += '<' + node.tagName;
|
|
46
|
+
|
|
47
|
+
if (node.hasAttributes()) {
|
|
48
|
+
[].forEach.call(node.attributes, function(attrNode) {
|
|
49
|
+
output += ' ' + attrNode.name + '="' + attrNode.value + '"';
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
output += '>';
|
|
54
|
+
|
|
55
|
+
if (node.hasChildNodes()) {
|
|
56
|
+
[].forEach.call(node.childNodes, function(childNode) {
|
|
57
|
+
output += serializeNode(childNode);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
output += '</' + node.tagName + '>';
|
|
62
|
+
|
|
63
|
+
return output;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
Object.defineProperty(SVGElement.prototype, 'innerHTML', {
|
|
67
|
+
get: function () {
|
|
68
|
+
var output = '';
|
|
69
|
+
|
|
70
|
+
[].forEach.call(this.childNodes, function(childNode) {
|
|
71
|
+
output += serializeNode(childNode);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return output;
|
|
75
|
+
},
|
|
76
|
+
set: function (markup) {
|
|
77
|
+
while (this.firstChild) {
|
|
78
|
+
this.removeChild(this.firstChild);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
var dXML = new DOMParser();
|
|
83
|
+
dXML.async = false;
|
|
84
|
+
|
|
85
|
+
var sXML = '<svg xmlns=\'http://www.w3.org/2000/svg\' xmlns:xlink=\'http://www.w3.org/1999/xlink\'>' + markup + '</svg>';
|
|
86
|
+
var svgDocElement = dXML.parseFromString(sXML, 'text/xml').documentElement;
|
|
87
|
+
|
|
88
|
+
[].forEach.call(svgDocElement.childNodes, function(childNode) {
|
|
89
|
+
this.appendChild(this.ownerDocument.importNode(childNode, true));
|
|
90
|
+
}.bind(this));
|
|
91
|
+
} catch (e) {
|
|
92
|
+
throw new Error('Error parsing markup string');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
Object.defineProperty(SVGElement.prototype, 'innerSVG', {
|
|
98
|
+
get: function () {
|
|
99
|
+
return this.innerHTML;
|
|
100
|
+
},
|
|
101
|
+
set: function (markup) {
|
|
102
|
+
this.innerHTML = markup;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
})();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
}));
|
|
110
|
+
|
|
111
|
+
(function (global, factory) {
|
|
112
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-format'), require('@d3plus/locales'), require('d3-time'), require('d3-time-format')) :
|
|
113
|
+
typeof define === 'function' && define.amd ? define('@d3plus/format', ['exports', 'd3-format', '@d3plus/locales', 'd3-time', 'd3-time-format'], factory) :
|
|
114
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3plus = {}, global.d3Format, global.locales, global.d3Time, global.d3TimeFormat));
|
|
115
|
+
})(this, (function (exports, d3Format, locales, d3Time, d3TimeFormat) { 'use strict';
|
|
116
|
+
|
|
117
|
+
const round = (x, n)=>parseFloat(Math.round(x * Math.pow(10, n)) / Math.pow(10, n)).toFixed(n);
|
|
118
|
+
/**
|
|
119
|
+
* @private
|
|
120
|
+
*/ function formatSuffix(str, precision, suffixes) {
|
|
121
|
+
let i = 0;
|
|
122
|
+
let value = parseFloat(str.replace("−", "-"), 10);
|
|
123
|
+
if (value) {
|
|
124
|
+
if (value < 0) value *= -1;
|
|
125
|
+
i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10);
|
|
126
|
+
i = Math.max(-24, Math.min(24, Math.floor((i - 1) / 3) * 3));
|
|
127
|
+
}
|
|
128
|
+
const d = suffixes[8 + i / 3];
|
|
129
|
+
return {
|
|
130
|
+
number: round(d.scale(value), precision),
|
|
131
|
+
symbol: d.symbol
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* @private
|
|
136
|
+
*/ function parseSuffixes(d, i) {
|
|
137
|
+
const k = Math.pow(10, Math.abs(8 - i) * 3);
|
|
138
|
+
return {
|
|
139
|
+
scale: i > 8 ? (d)=>d / k : (d)=>d * k,
|
|
140
|
+
symbol: d
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
@function formatAbbreviate
|
|
145
|
+
@desc Formats a number to an appropriate number of decimal places and rounding, adding suffixes if applicable (ie. `1200000` to `"1.2M"`).
|
|
146
|
+
@param {Number|String} n The number to be formatted.
|
|
147
|
+
@param {Object|String} locale The locale config to be used. If *value* is an object, the function will format the numbers according the object. The object must include `suffixes`, `delimiter` and `currency` properties.
|
|
148
|
+
@returns {String}
|
|
149
|
+
*/ function abbreviate(n, locale = "en-US", precision = undefined) {
|
|
150
|
+
if (isFinite(n)) n *= 1;
|
|
151
|
+
else return "N/A";
|
|
152
|
+
const negative = n < 0;
|
|
153
|
+
const length = n.toString().split(".")[0].replace("-", "").length, localeConfig = typeof locale === "object" ? locale : locales.formatLocale[locale] || locales.formatLocale["en-US"], suffixes = localeConfig.suffixes.map(parseSuffixes);
|
|
154
|
+
const decimal = localeConfig.delimiters.decimal || ".", separator = localeConfig.separator || "", thousands = localeConfig.delimiters.thousands || ",";
|
|
155
|
+
const d3plusFormatLocale = d3Format.formatLocale({
|
|
156
|
+
currency: localeConfig.currency || [
|
|
157
|
+
"$",
|
|
158
|
+
""
|
|
159
|
+
],
|
|
160
|
+
decimal,
|
|
161
|
+
grouping: localeConfig.grouping || [
|
|
162
|
+
3
|
|
163
|
+
],
|
|
164
|
+
thousands
|
|
165
|
+
});
|
|
166
|
+
let val;
|
|
167
|
+
if (precision) val = d3plusFormatLocale.format(precision)(n);
|
|
168
|
+
else if (n === 0) val = "0";
|
|
169
|
+
else if (length >= 3) {
|
|
170
|
+
const f = formatSuffix(d3plusFormatLocale.format(".3r")(n), 2, suffixes);
|
|
171
|
+
const num = parseFloat(f.number).toString().replace(".", decimal);
|
|
172
|
+
const char = f.symbol;
|
|
173
|
+
val = `${num}${separator}${char}`;
|
|
174
|
+
} else if (length === 3) val = d3plusFormatLocale.format(",f")(n);
|
|
175
|
+
else if (n < 1 && n > -1) val = d3plusFormatLocale.format(".2g")(n);
|
|
176
|
+
else val = d3plusFormatLocale.format(".3g")(n);
|
|
177
|
+
return `${negative && val.charAt(0) !== "−" ? "−" : ""}${val}`.replace(/−/g, "-") // replace new d3 default minus sign (−) to hyphen-minus (-)
|
|
178
|
+
.replace(/(\.[0]*[1-9]*)[0]*$/g, "$1") // removes any trailing zeros
|
|
179
|
+
.replace(/\.[0]*$/g, ""); // removes any trailing decimal point
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
@function format
|
|
184
|
+
@desc An extension to d3's [format](https://github.com/d3/d3-format#api-reference) function that adds more string formatting types and localizations.
|
|
185
|
+
|
|
186
|
+
The new specifier strings added by d3plus-format are:
|
|
187
|
+
- `.3~a` - abbreviated decimal notation with a numeric suffix (ie. "k", "M", "B", etc). This is an alias of the `formatAbbreviate` function.
|
|
188
|
+
@param {String} specifier The string specifier used by the format function.
|
|
189
|
+
@returns {Function}
|
|
190
|
+
*/ var format = ((specifier)=>{
|
|
191
|
+
if (specifier === ".3~a") return abbreviate;
|
|
192
|
+
return d3Format.format(specifier);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
@function formatDefaultLocale
|
|
197
|
+
@desc An extension to d3's [formatDefaultLocale](https://github.com/d3/d3-format#api-reference) function that allows setting the locale globally for formatters.
|
|
198
|
+
@param {Object} definition The localization definition.
|
|
199
|
+
@returns {Object}
|
|
200
|
+
*/ var formatDefaultLocale = ((definition)=>{
|
|
201
|
+
const locale = d3Format.formatDefaultLocale(definition);
|
|
202
|
+
locale.format = format;
|
|
203
|
+
return locale;
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
@function formatDate
|
|
208
|
+
@desc A default set of date formatters, which takes into account both the interval in between in each data point but also the start/end data points.
|
|
209
|
+
@param {Date} d The date string to be formatted.
|
|
210
|
+
@param {Array} dataArray The full array of ordered Date Objects.
|
|
211
|
+
@param {Function} [formatter = d3.timeFormat] An optional instance of d3.timeFormat to be used for localization.
|
|
212
|
+
@returns {String}
|
|
213
|
+
*/ function formatDate(d, dataArray, formatter = d3TimeFormat.timeFormat) {
|
|
214
|
+
const formatHour = formatter("%I %p"), formatMillisecond = formatter(".%L"), formatMinute = formatter("%I:%M"), formatMonth = formatter("%b"), formatMonthDay = formatter("%b %-d"), formatMonthDayYear = formatter("%b %-d, %Y"), formatMonthYear = formatter("%b %Y"), formatQuarter = formatter("Q%q"), formatQuarterYear = formatter("Q%q %Y"), formatSecond = formatter(":%S"), formatYear = formatter("%Y");
|
|
215
|
+
const labelIndex = dataArray.findIndex((a)=>+a === +d);
|
|
216
|
+
const firstOrLast = labelIndex === 0 || labelIndex === dataArray.length - 1;
|
|
217
|
+
const smallArray = dataArray.length <= 5;
|
|
218
|
+
const [yearlySteps, monthlySteps, dailySteps, hourlySteps] = dataArray.reduce((arr, d, i)=>{
|
|
219
|
+
if (i) {
|
|
220
|
+
arr[0].push(d.getFullYear() - dataArray[i - 1].getFullYear());
|
|
221
|
+
arr[1].push(monthDiff(dataArray[i - 1], d));
|
|
222
|
+
arr[2].push(Math.round((d - dataArray[i - 1]) / (1000 * 60 * 60 * 24)));
|
|
223
|
+
arr[3].push(Math.round((d - dataArray[i - 1]) / (1000 * 60 * 60)));
|
|
224
|
+
}
|
|
225
|
+
return arr;
|
|
226
|
+
}, [
|
|
227
|
+
[],
|
|
228
|
+
[],
|
|
229
|
+
[],
|
|
230
|
+
[]
|
|
231
|
+
]);
|
|
232
|
+
return (yearlySteps.every((s)=>s >= 1 && !(s % 1)) // Yearly Data
|
|
233
|
+
? formatYear : monthlySteps.every((s)=>s >= 3 && !(s % 3)) // Quarterly Data
|
|
234
|
+
? +d3Time.timeYear(d) === d || firstOrLast || smallArray ? formatQuarterYear : formatQuarter : monthlySteps.every((s)=>s >= 1 && !(s % 1)) // Monthly Data
|
|
235
|
+
? +d3Time.timeYear(d) === d || firstOrLast || smallArray ? formatMonthYear : formatMonth : dailySteps.every((s)=>s >= 1 && !(s % 1)) // Daily Data
|
|
236
|
+
? +d3Time.timeYear(d) === d || firstOrLast || smallArray ? formatMonthDayYear : formatMonthDay : hourlySteps.every((s)=>s >= 1 && !(s % 1)) // Hourly Data
|
|
237
|
+
? firstOrLast || smallArray ? formatMonthDayYear : +d3Time.timeMonth(d) === d ? formatMonthDay : formatHour : d3Time.timeSecond(d) < d ? formatMillisecond : d3Time.timeMinute(d) < d ? formatSecond : d3Time.timeHour(d) < d ? formatMinute : d)(d);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
@function monthDiff
|
|
241
|
+
@desc Returns the number of months between two Date objects
|
|
242
|
+
@param {*} d1
|
|
243
|
+
@param {*} d2
|
|
244
|
+
@returns {Number} the number of months between the two Date objects
|
|
245
|
+
@private
|
|
246
|
+
*/ function monthDiff(d1, d2) {
|
|
247
|
+
let months;
|
|
248
|
+
months = (d2.getFullYear() - d1.getFullYear()) * 12;
|
|
249
|
+
months -= d1.getMonth();
|
|
250
|
+
months += d2.getMonth();
|
|
251
|
+
return months <= 0 ? 0 : months;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
exports.format = format;
|
|
255
|
+
exports.formatAbbreviate = abbreviate;
|
|
256
|
+
exports.formatDate = formatDate;
|
|
257
|
+
exports.formatDefaultLocale = formatDefaultLocale;
|
|
258
|
+
|
|
259
|
+
}));
|
|
260
|
+
//# sourceMappingURL=d3plus-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"d3plus-format.js","sources":["../src/formatAbbreviate.js","../src/format.js","../src/formatDefaultLocale.js","../src/formatDate.js"],"sourcesContent":["import {formatLocale} from \"d3-format\";\nimport {formatLocale as defaultLocale} from \"@d3plus/locales\";\n\nconst round = (x, n) =>\n parseFloat(Math.round(x * Math.pow(10, n)) / Math.pow(10, n)).toFixed(n);\n\n/**\n * @private\n*/\nfunction formatSuffix(str, precision, suffixes) {\n let i = 0;\n let value = parseFloat(str.replace(\"−\", \"-\"), 10);\n if (value) {\n if (value < 0) value *= -1;\n i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10);\n i = Math.max(-24, Math.min(24, Math.floor((i - 1) / 3) * 3));\n }\n const d = suffixes[8 + i / 3];\n\n return {\n number: round(d.scale(value), precision),\n symbol: d.symbol\n };\n}\n\n/**\n * @private\n*/\nfunction parseSuffixes(d, i) {\n const k = Math.pow(10, Math.abs(8 - i) * 3);\n return {\n scale: i > 8 ? d => d / k : d => d * k,\n symbol: d\n };\n}\n\n\n/**\n @function formatAbbreviate\n @desc Formats a number to an appropriate number of decimal places and rounding, adding suffixes if applicable (ie. `1200000` to `\"1.2M\"`).\n @param {Number|String} n The number to be formatted.\n @param {Object|String} locale The locale config to be used. If *value* is an object, the function will format the numbers according the object. The object must include `suffixes`, `delimiter` and `currency` properties.\n @returns {String}\n*/\nexport default function(n, locale = \"en-US\", precision = undefined) {\n if (isFinite(n)) n *= 1;\n else return \"N/A\";\n\n const negative = n < 0;\n\n const length = n.toString().split(\".\")[0].replace(\"-\", \"\").length,\n localeConfig = typeof locale === \"object\" ? locale : defaultLocale[locale] || defaultLocale[\"en-US\"],\n suffixes = localeConfig.suffixes.map(parseSuffixes);\n\n const decimal = localeConfig.delimiters.decimal || \".\",\n separator = localeConfig.separator || \"\",\n thousands = localeConfig.delimiters.thousands || \",\";\n\n const d3plusFormatLocale = formatLocale({\n currency: localeConfig.currency || [\"$\", \"\"],\n decimal,\n grouping: localeConfig.grouping || [3],\n thousands\n });\n\n let val;\n if (precision) val = d3plusFormatLocale.format(precision)(n);\n else if (n === 0) val = \"0\";\n else if (length >= 3) {\n const f = formatSuffix(d3plusFormatLocale.format(\".3r\")(n), 2, suffixes);\n const num = parseFloat(f.number).toString().replace(\".\", decimal);\n const char = f.symbol;\n val = `${num}${separator}${char}`;\n }\n else if (length === 3) val = d3plusFormatLocale.format(\",f\")(n);\n else if (n < 1 && n > -1) val = d3plusFormatLocale.format(\".2g\")(n);\n else val = d3plusFormatLocale.format(\".3g\")(n);\n\n return `${negative && val.charAt(0) !== \"−\" ? \"−\" : \"\"}${val}`\n .replace(/−/g, \"-\") // replace new d3 default minus sign (−) to hyphen-minus (-)\n .replace(/(\\.[0]*[1-9]*)[0]*$/g, \"$1\") // removes any trailing zeros\n .replace(/\\.[0]*$/g, \"\"); // removes any trailing decimal point\n\n}\n","import abbreviate from \"./formatAbbreviate.js\";\nimport {format} from \"d3-format\";\n\n/**\n @function format\n @desc An extension to d3's [format](https://github.com/d3/d3-format#api-reference) function that adds more string formatting types and localizations.\n\nThe new specifier strings added by d3plus-format are:\n - `.3~a` - abbreviated decimal notation with a numeric suffix (ie. \"k\", \"M\", \"B\", etc). This is an alias of the `formatAbbreviate` function.\n @param {String} specifier The string specifier used by the format function.\n @returns {Function}\n*/\nexport default specifier => {\n if (specifier === \".3~a\") return abbreviate;\n return format(specifier);\n};\n","import format from \"./format.js\";\nimport {formatDefaultLocale} from \"d3-format\";\n\n/**\n @function formatDefaultLocale\n @desc An extension to d3's [formatDefaultLocale](https://github.com/d3/d3-format#api-reference) function that allows setting the locale globally for formatters.\n @param {Object} definition The localization definition.\n @returns {Object}\n*/\nexport default definition => {\n const locale = formatDefaultLocale(definition);\n locale.format = format;\n return locale;\n};\n","import {timeYear, timeMonth, timeHour, timeMinute, timeSecond} from \"d3-time\";\nimport {timeFormat} from \"d3-time-format\";\n\n/**\n @function formatDate\n @desc A default set of date formatters, which takes into account both the interval in between in each data point but also the start/end data points.\n @param {Date} d The date string to be formatted.\n @param {Array} dataArray The full array of ordered Date Objects.\n @param {Function} [formatter = d3.timeFormat] An optional instance of d3.timeFormat to be used for localization.\n @returns {String}\n*/\nexport default function(d, dataArray, formatter = timeFormat) {\n\n const formatHour = formatter(\"%I %p\"),\n formatMillisecond = formatter(\".%L\"),\n formatMinute = formatter(\"%I:%M\"),\n formatMonth = formatter(\"%b\"),\n formatMonthDay = formatter(\"%b %-d\"),\n formatMonthDayYear = formatter(\"%b %-d, %Y\"),\n formatMonthYear = formatter(\"%b %Y\"),\n formatQuarter = formatter(\"Q%q\"),\n formatQuarterYear = formatter(\"Q%q %Y\"),\n formatSecond = formatter(\":%S\"),\n formatYear = formatter(\"%Y\");\n\n const labelIndex = dataArray.findIndex(a => +a === +d);\n const firstOrLast = labelIndex === 0 || labelIndex === dataArray.length - 1;\n const smallArray = dataArray.length <= 5;\n\n const [yearlySteps, monthlySteps, dailySteps, hourlySteps] = dataArray.reduce((arr, d, i) => {\n if (i) {\n arr[0].push(d.getFullYear() - dataArray[i - 1].getFullYear());\n arr[1].push(monthDiff(dataArray[i - 1], d));\n arr[2].push(Math.round((d - dataArray[i - 1]) / (1000 * 60 * 60 * 24)));\n arr[3].push(Math.round((d - dataArray[i - 1]) / (1000 * 60 * 60)));\n }\n return arr;\n }, [[], [], [], []]);\n\n return (\n yearlySteps.every(s => s >= 1 && !(s % 1)) // Yearly Data \n ? formatYear\n : monthlySteps.every(s => s >= 3 && !(s % 3)) // Quarterly Data\n ? +timeYear(d) === d || firstOrLast || smallArray ? formatQuarterYear : formatQuarter\n : monthlySteps.every(s => s >= 1 && !(s % 1)) // Monthly Data\n ? +timeYear(d) === d || firstOrLast || smallArray ? formatMonthYear : formatMonth \n : dailySteps.every(s => s >= 1 && !(s % 1)) // Daily Data\n ? +timeYear(d) === d || firstOrLast || smallArray ? formatMonthDayYear : formatMonthDay \n : hourlySteps.every(s => s >= 1 && !(s % 1)) // Hourly Data\n ? firstOrLast || smallArray ? formatMonthDayYear : +timeMonth(d) === d ? formatMonthDay : formatHour\n : timeSecond(d) < d ? formatMillisecond\n : timeMinute(d) < d ? formatSecond\n : timeHour(d) < d ? formatMinute : d\n )(d);\n\n}\n\n/**\n @function monthDiff\n @desc Returns the number of months between two Date objects\n @param {*} d1\n @param {*} d2\n @returns {Number} the number of months between the two Date objects\n @private\n*/\nfunction monthDiff(d1, d2) {\n let months;\n months = (d2.getFullYear() - d1.getFullYear()) * 12;\n months -= d1.getMonth();\n months += d2.getMonth();\n return months <= 0 ? 0 : months;\n}\n"],"names":["round","x","n","parseFloat","Math","pow","toFixed","formatSuffix","str","precision","suffixes","i","value","replace","floor","log","LN10","max","min","d","number","scale","symbol","parseSuffixes","k","abs","locale","undefined","isFinite","negative","length","toString","split","localeConfig","defaultLocale","map","decimal","delimiters","separator","thousands","d3plusFormatLocale","formatLocale","currency","grouping","val","format","f","num","char","charAt","specifier","abbreviate","definition","formatDefaultLocale","dataArray","formatter","timeFormat","formatHour","formatMillisecond","formatMinute","formatMonth","formatMonthDay","formatMonthDayYear","formatMonthYear","formatQuarter","formatQuarterYear","formatSecond","formatYear","labelIndex","findIndex","a","firstOrLast","smallArray","yearlySteps","monthlySteps","dailySteps","hourlySteps","reduce","arr","push","getFullYear","monthDiff","every","s","timeYear","timeMonth","timeSecond","timeMinute","timeHour","d1","d2","months","getMonth"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGA,MAAMA,KAAAA,GAAQ,CAACC,CAAGC,EAAAA,CAAAA,GAChBC,WAAWC,IAAKJ,CAAAA,KAAK,CAACC,CAAIG,GAAAA,IAAAA,CAAKC,GAAG,CAAC,EAAA,EAAIH,MAAME,IAAKC,CAAAA,GAAG,CAAC,EAAIH,EAAAA,CAAAA,CAAAA,CAAAA,CAAII,OAAO,CAAC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.0
|
|
3
|
+
JavaScript formatters for localized numbers and dates.
|
|
4
|
+
Copyright (c) 2025 D3plus - https://d3plus.org
|
|
5
|
+
@license MIT
|
|
6
|
+
*/
|
|
7
|
+
(e=>{"function"==typeof define&&define.amd?define(e):e()})(function(){if("undefined"!=typeof window){try{if("undefined"==typeof SVGElement||Boolean(SVGElement.prototype.innerHTML))return}catch(e){return}function o(e){switch(e.nodeType){case 1:var t=e,r="";return r+="<"+t.tagName,t.hasAttributes()&&[].forEach.call(t.attributes,function(e){r+=" "+e.name+'="'+e.value+'"'}),r+=">",t.hasChildNodes()&&[].forEach.call(t.childNodes,function(e){r+=o(e)}),r+="</"+t.tagName+">";case 3:return e.textContent.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");case 8:return"\x3c!--"+e.nodeValue+"--\x3e"}}Object.defineProperty(SVGElement.prototype,"innerHTML",{get:function(){var t="";return[].forEach.call(this.childNodes,function(e){t+=o(e)}),t},set:function(e){for(;this.firstChild;)this.removeChild(this.firstChild);try{var t=new DOMParser,r=(t.async=!1,"<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>"+e+"</svg>"),o=t.parseFromString(r,"text/xml").documentElement;[].forEach.call(o.childNodes,function(e){this.appendChild(this.ownerDocument.importNode(e,!0))}.bind(this))}catch(e){throw new Error("Error parsing markup string")}}}),Object.defineProperty(SVGElement.prototype,"innerSVG",{get:function(){return this.innerHTML},set:function(e){this.innerHTML=e}})}}),((e,t)=>{"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-format"),require("@d3plus/locales"),require("d3-time"),require("d3-time-format")):"function"==typeof define&&define.amd?define("@d3plus/format",["exports","d3-format","@d3plus/locales","d3-time","d3-time-format"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).d3plus={},e.d3Format,e.locales,e.d3Time,e.d3TimeFormat)})(this,function(e,s,m,b,v){let c=(e,t)=>parseFloat(Math.round(e*Math.pow(10,t))/Math.pow(10,t)).toFixed(t);
|
|
8
|
+
/**
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* @private
|
|
13
|
+
*/function d(e,t){let r=Math.pow(10,3*Math.abs(8-t));return{scale:8<t?e=>e/r:e=>e*r,symbol:e}}
|
|
14
|
+
/**
|
|
15
|
+
@function formatAbbreviate
|
|
16
|
+
@desc Formats a number to an appropriate number of decimal places and rounding, adding suffixes if applicable (ie. `1200000` to `"1.2M"`).
|
|
17
|
+
@param {Number|String} n The number to be formatted.
|
|
18
|
+
@param {Object|String} locale The locale config to be used. If *value* is an object, the function will format the numbers according the object. The object must include `suffixes`, `delimiter` and `currency` properties.
|
|
19
|
+
@returns {String}
|
|
20
|
+
*/function t(e,t="en-US",r=void 0){if(!isFinite(e))return"N/A";var o=(e*=1)<0,n=e.toString().split(".")[0].replace("-","").length,t="object"==typeof t?t:m.formatLocale[t]||m.formatLocale["en-US"],a=t.suffixes.map(d),i=t.delimiters.decimal||".",l=t.separator||"",f=t.delimiters.thousands||",",t=s.formatLocale({currency:t.currency||["$",""],decimal:i,grouping:t.grouping||[3],thousands:f});let u;return u=r?t.format(r)(e):0===e?"0":3<=n?(f=((e,t,r)=>{let o=0,n=parseFloat(e.replace("−","-"),10);return n&&(n<0&&(n*=-1),o=1+Math.floor(1e-12+Math.log(n)/Math.LN10),o=Math.max(-24,Math.min(24,3*Math.floor((o-1)/3)))),e=r[8+o/3],{number:c(e.scale(n),t),symbol:e.symbol}})(t.format(".3r")(e),2,a),""+parseFloat(f.number).toString().replace(".",i)+l+f.symbol):(3===n?t.format(",f"):e<1&&-1<e?t.format(".2g"):t.format(".3g"))(e),((o&&"−"!==u.charAt(0)?"−":"")+u).replace(/−/g,"-").replace(/(\.[0]*[1-9]*)[0]*$/g,"$1").replace(/\.[0]*$/g,"");// removes any trailing decimal point
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
@function format
|
|
24
|
+
@desc An extension to d3's [format](https://github.com/d3/d3-format#api-reference) function that adds more string formatting types and localizations.
|
|
25
|
+
|
|
26
|
+
The new specifier strings added by d3plus-format are:
|
|
27
|
+
- `.3~a` - abbreviated decimal notation with a numeric suffix (ie. "k", "M", "B", etc). This is an alias of the `formatAbbreviate` function.
|
|
28
|
+
@param {String} specifier The string specifier used by the format function.
|
|
29
|
+
@returns {Function}
|
|
30
|
+
*/var r=e=>".3~a"===e?t:s.format(e);
|
|
31
|
+
/**
|
|
32
|
+
@function formatDefaultLocale
|
|
33
|
+
@desc An extension to d3's [formatDefaultLocale](https://github.com/d3/d3-format#api-reference) function that allows setting the locale globally for formatters.
|
|
34
|
+
@param {Object} definition The localization definition.
|
|
35
|
+
@returns {Object}
|
|
36
|
+
*/e.format=r,e.formatAbbreviate=t,e.formatDate=
|
|
37
|
+
/**
|
|
38
|
+
@function formatDate
|
|
39
|
+
@desc A default set of date formatters, which takes into account both the interval in between in each data point but also the start/end data points.
|
|
40
|
+
@param {Date} d The date string to be formatted.
|
|
41
|
+
@param {Array} dataArray The full array of ordered Date Objects.
|
|
42
|
+
@param {Function} [formatter = d3.timeFormat] An optional instance of d3.timeFormat to be used for localization.
|
|
43
|
+
@returns {String}
|
|
44
|
+
*/function(t,i,e=v.timeFormat){var r=e("%I %p"),o=e(".%L"),n=e("%I:%M"),a=e("%b"),l=e("%b %-d"),f=e("%b %-d, %Y"),u=e("%b %Y"),s=e("Q%q"),m=e("Q%q %Y"),c=e(":%S"),e=e("%Y"),d=0===(d=i.findIndex(e=>+e==+t))||d===i.length-1,h=i.length<=5,[p,g,y,M]=i.reduce((e,t,r)=>{
|
|
45
|
+
/**
|
|
46
|
+
@function monthDiff
|
|
47
|
+
@desc Returns the number of months between two Date objects
|
|
48
|
+
@param {*} d1
|
|
49
|
+
@param {*} d2
|
|
50
|
+
@returns {Number} the number of months between the two Date objects
|
|
51
|
+
@private
|
|
52
|
+
*/var o,n,a;return r&&(e[0].push(t.getFullYear()-i[r-1].getFullYear()),e[1].push((o=i[r-1],a=12*((n=t).getFullYear()-o.getFullYear()),(a=(a-=o.getMonth())+n.getMonth())<=0?0:a)),e[2].push(Math.round((t-i[r-1])/864e5)),e[3].push(Math.round((t-i[r-1])/36e5))),e},[[],[],[],[]]);return(p.every(e=>1<=e&&!(e%1))?e:g.every(e=>3<=e&&!(e%3))?+b.timeYear(t)===t||d||h?m:s:g.every(e=>1<=e&&!(e%1))?+b.timeYear(t)===t||d||h?u:a:y.every(e=>1<=e&&!(e%1))?+b.timeYear(t)===t||d||h?f:l:M.every(e=>1<=e&&!(e%1))?d||h?f:+b.timeMonth(t)===t?l:r:b.timeSecond(t)<t?o:b.timeMinute(t)<t?c:b.timeHour(t)<t?n:t)(t)},e.formatDefaultLocale=e=>{e=s.formatDefaultLocale(e);return e.format=r,e}});
|
|
53
|
+
//# sourceMappingURL=d3plus-format.js.map
|