In my Workshop application, I would like to have a bar chart with a changeable x-axis. A dropdown widget would be used to select the desired x-axis.
For this I am writing a TypeScript function, that will return the data that will feed the chart widget.
I have wrote the following function:
@Function()
public async flexibleCounter2DimensionTest(
objects: ObjectSet<Data>,
xaxis : string ): Promise<TwoDimensionalAggregation<string>> {
return objects
.groupBy(val => val[xaxis].topValues())
.count()
}
The xaxis
parameter would define the column name, on which to perform the grouping.
I am struggling to do this in Foundry Functions, I am always receiving the following error on compilation:
{ "stdout": "src/hospital_provider_analysis.ts(170,9): error TS2322: Type 'TwoDimensionalAggregation<BucketKey, number>' is not assignable to type 'TwoDimensionalAggregation<string, number>'.\n Type 'BucketKey' is not assignable to type 'string'.\n Type 'false' is not assignable to type 'string'.\nsrc/hospital_provider_analysis.ts(171,33): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'BucketableProperties'.\n No index signature with a parameter of type 'string' was found on type 'BucketableProperties'.\n", "stderr": "" }
Any ideas how to fix this issue?