agregar funcion de aplicar formato se se encuentra en la definicion de la columna
This commit is contained in:
parent
be6785152b
commit
43e3abb8c7
@ -212,13 +212,65 @@ function makeRenderer() {
|
|||||||
};
|
};
|
||||||
} : null;
|
} : null;
|
||||||
|
|
||||||
|
var getFinalFormat = function getFinalFormat(objCol) {
|
||||||
|
if (objCol.type !== 'number' || objCol.format != null && objCol.format.includes('Q')) {
|
||||||
|
return objCol.format;
|
||||||
|
}
|
||||||
|
if (objCol.format.includes('.')) {
|
||||||
|
if (objCol.number_decimals != null) {
|
||||||
|
var numberDecimals = parseInt(objCol.number_decimals);
|
||||||
|
var resultDecimals = '';
|
||||||
|
if (numberDecimals && !isNaN(numberDecimals) && numberDecimals > 0) {
|
||||||
|
var counter = 0;
|
||||||
|
resultDecimals = '.';
|
||||||
|
while (counter < numberDecimals) {
|
||||||
|
resultDecimals = resultDecimals + '0';
|
||||||
|
counter += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return objCol.format.replace('.00', resultDecimals);
|
||||||
|
}
|
||||||
|
return objCol.format;
|
||||||
|
}
|
||||||
|
return objCol.format;
|
||||||
|
};
|
||||||
|
|
||||||
|
var getLocaleConfig = function getLocaleConfig(objCol) {
|
||||||
|
if (objCol.type !== 'number' || objCol.format != null && objCol.format.includes('Q')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
delimiters: {
|
||||||
|
thousands: objCol.delimiter_thousands != null ? objCol.delimiter_thousands : ',',
|
||||||
|
decimal: objCol.delimiter_decimal != null ? objCol.delimiter_decimal : '.'
|
||||||
|
},
|
||||||
|
abbreviations: {
|
||||||
|
thousand: 'k',
|
||||||
|
million: 'm',
|
||||||
|
billion: 'b',
|
||||||
|
trillion: 't'
|
||||||
|
},
|
||||||
|
currency: {
|
||||||
|
symbol: objCol.currency_symbol != null ? objCol.currency_symbol : '$'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
var getFormatedValue = function getFormatedValue(aggregator, rowKey, colKey) {
|
var getFormatedValue = function getFormatedValue(aggregator, rowKey, colKey) {
|
||||||
console.log('aggregator', aggregator);
|
var valToFormat = aggregator.value();
|
||||||
console.log('rowKey', rowKey);
|
var resultValue = aggregator.format(valToFormat);
|
||||||
console.log('colKey', colKey);
|
var keyColumnaCalculo = _this2.props.vals != null && _this2.props.vals.length ? _this2.props.vals[0] : null;
|
||||||
console.log('props.headersDefinitions', _this2.props.headersDefinitions);
|
if (keyColumnaCalculo != null && _this2.props.headersDefinitions != null && _this2.props.headersDefinitions.length) {
|
||||||
console.log('props', _this2.props);
|
var _definition = _this2.props.headersDefinitions[keyColumnaCalculo];
|
||||||
return '';
|
if (_definition != null && _definition.value != null) {
|
||||||
|
if (_definition.value.startsWith('count_') || _definition.value.startsWith('countd_')) {
|
||||||
|
resultValue = _this2.props.functions != null ? _this2.props.functions.formatedValue(valToFormat, '0,0', 'number', true, '') : resultValue;
|
||||||
|
} else if (_definition.format != null && _definition.format !== '') {
|
||||||
|
resultValue = _this2.props.chartFunctions != null ? _this2.props.chartFunctions.formatedValue(valToFormat, getFinalFormat(_definition), _definition.type, true, '', getLocaleConfig(_definition)) : resultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
return _react2.default.createElement(
|
return _react2.default.createElement(
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "v-react-pivottable",
|
"name": "v-react-pivottable",
|
||||||
"version": "0.11.23",
|
"version": "0.11.24",
|
||||||
"description": "A React-based pivot table",
|
"description": "A React-based pivot table",
|
||||||
"main": "PivotTableUI.js",
|
"main": "PivotTableUI.js",
|
||||||
"files": [
|
"files": [
|
||||||
|
Loading…
Reference in New Issue
Block a user