Pivot custom method problem


#1

there is a javascript error when add custom method to pivot when any fields not initialized at default:

Uncaught TypeError: Cannot read property ‘addMathMethod’ of undefined
Pivot fields:

... fields= { rows: [], columns: [], values: [], } ...


#2

Unfortunately the problem cannot be reconstructed locally.
Could you please, provide a complete demo or share a demo link, where the problem can be reproduced.


#3

edited sample \03_customization\04_custom_methods :[code]

Custom methods
<script type="text/javascript" src="../../codebase/pivot.js"></script>
<script type="text/javascript" src="../common/dataset.js"></script>

<link rel="stylesheet" href="../../codebase/pivot.css">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,500" rel="stylesheet">
var pivot = new dhx.Pivot(document.body, { data: dataset, fields: { rows: [], columns: [], values: [], }, fieldList: [ { id: "name", label: "Name" }, { id: "year", label: "Year" }, { id: "continent", label: "Continent" }, { id: "form", label: "Form" }, { id: "gdp", label: "GDP" }, { id: "oil", label: "Oil" }, { id: "balance", label: "Balance" }, { id: "when", label: "When", type: "date", format: "%d/%m/%Y" } ] });
	pivot.addMathMethod("avr", 'AVR', (cellData) => {
		var sum = cellData.reduce((el, all) => all += el);
		return (sum / cellData.length).toFixed(3);
	});
</script>
[/code]

#4

Unfortunately the described problem still cannot be reconstructed locally.
Your provided code works well for me locally with no errors.
Could you please, provide a complete demo or share a demo link, where the problem can be reconstructed locally.


#5

please check sample 03/04 in attached archive. avg method not worked and error available in console. thanks.
pivot.zip (62.6 KB)


#6

thanks. problem solved in version 1.3 .