@antv/g2plot
Version:
G2 Plot, a market of plots built with the Grammar of Graphics'
21 lines • 933 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var util_1 = require("@antv/util");
exports.combineFormatter = function () {
var formatters = [];
for (var _i = 0; _i < arguments.length; _i++) {
formatters[_i] = arguments[_i];
}
return function (text, item, idx) {
return formatters.reduce(function (curText, formatter) { return formatter(curText, item, idx); }, text);
};
};
exports.getNoopFormatter = function () { return function (text, item, idx) { return text; }; };
exports.getPrecisionFormatter = function (precision) { return function (text, item, idx) {
var num = Number(text);
return isNaN(num) || util_1.isNil(precision) ? text : num.toFixed(precision);
}; };
exports.getSuffixFormatter = function (suffix) { return function (text, item, idx) {
return util_1.isNil(suffix) ? text : text + " " + suffix;
}; };
//# sourceMappingURL=formatter.js.map