Skip to main content

Post Processing

Acknowledgement

We know that we cannot think of every possible wildest dream an author would have for a calculation. We've been trying for many years but just can't do it. Thus, we built our calculation engine so that it is open for hacking.

Manipulate the JSON returned from the aggregation pipeline

This is done in Javascript. The good, latest version of javascript with great language features.


let data = result?.data; // extract data from pipeline result

// find a row to hack (measure with id m7)
let row_to_hack = data.find(row => row.m.id === "m7");
row_to_hack.cell.val = 50; // hack the value

// exclude rows I don't like
data = data.filter(row => row.m.tag === "my custom tag" && row.n < 50)

// custom aggregation of the data for those javascript wizards
// (but remember to do as much aggregation on the server as possible!)
data = data.reduce((prev, row) => {
return {
...prev,
sum: (prev.sum || 0) + row.some_val,
n: (prev.n || 0) + 1
}
}, {})

return <MyChart data={data}/>;