Posted 30 January 2018, 8:52 pm EST
Hello,
I tried to create a sample to describe the issue, you can find a spreadsheet associated with the sample, containing a arbitrary customFunc, I created it as follow in my code:
var ab = function () { }
ab.prototype = new GC.Spread.CalcEngine.Functions.AsyncFunction("AB", 1, 1);
//Set default value to "Loading..."
ab.prototype.defaultValue = function () { return "Loading..."; };
//Override the evaluateAsync function
ab.prototype.evaluateAsync = function (context, arg1) {
//Use a timeout to simulate the server side evaluate or use an ajax post
setTimeout(function () {
var data = fakeData(arg1, 1)
var result = data.results.map(function (val, key) { return [key == 0 ? val.TimeStamp : JSON.parse(val.TimeStamp), val.Value] });
//context.setAsyncResult(result);
console.log(result);
context.setAsyncResult(new MyArray(result));
}, 2000);
}
GC.Spread.CalcEngine.Functions.defineGlobalCustomFunction("AB", new ab());
this is the fakeData helper func to generate some data :
function fakeData(val, n){
var data = {results : []}
for(i = 1; i <= n; i++) data.results.push({TimeStamp: i*val.length, Value: 2*i*val.length});
return data;
}
I have catched three abnormal behaviors:
1-We can not refer to a sheet with spaces in name.
2-In the Array formula when only one value is returned, the value is populated over all the cells in the array formula (which should not)
3-this is A big issue you have to look after or explain how to do it otherwise. The custom async function is running for each cell in the formula that’s affect the performance when we have a bigger Array, (remark: the data is already fetched for the first time why we ar doing it again and again …)
https://www.dropbox.com/s/ei7qo26viscvzo7/AsyncFuncErrors.zip
Best regards,
Ismail Bougnouch