I am running python 3.12.4 dash 2.17.1 dash_ag_grid 31.2.0 on linux OpenSUSE Tumbleweed
I am using Dash AG Grid to build a table.
I am using d3.format with an inline function as follows:
columnDefs = [
{‘field’: ‘Strategy Name’, “valueFormatter”: {“function”: “params.value ? d3.format(‘,.0f’)(params.value) : ‘’”},},
]
However I need a more complicated function that has either nested ? construct or an if - elseif - else statment. So I created a custom function in dashAgGridFunctions.js as follows:
var dagfuncs = (window.dashAgGridFunctions = window.dashAgGridFunctions || {});
dagfuncs.formatUtil = function (rowname, cellvalue) {
console.log(rowname);
console.log(cellvalue);
console.log(d3.format(‘,.0f’)(cellvalue));
if (rowname !== ‘Util’ && cellvalue) {
return “broken 1” //d3.format(‘,.0f’)(cellvalue);
} else if (rowname === ‘Util’ && cellvalue) {
return “broken 2” //d3.format(‘,.2%’)(cellvalue);
}
return cellvalue;
};
The logic works, but the call to d3.format() returns an uncaught exception in the browser.
How can I call d3.format from within the custom js function in dashAgGridFunctions.js ?
I have searched extensively but not found any answer. Apologies if I missed where if this is covered elsewhere.
Any help is much appreciated.