I need to be able to create visualizations that display the difference between consecutive measurements.
I have MongoDB Charts connected to a MongoDB instance for visualizing data. The problem is AFAIK MongoDB Charts can only display data from queries or aggregation pipelines. So far I have no luck getting the below task done in aggregation pipelines. I'm starting to wonder if I've chosen the wrong tools for this job.
My data looks something like this after filtering and sorting it:
{
"run_id": "run_x",
"measurements": {
"true_positives": 5,
"false_positives": 1
}
},
{
"run_id": "run_y",
"measurements": {
"true_positives": 6,
"false_positives": 0
}
}
And I need to calculate deltas between runs so that I end up with:
{
"run_id": "run_x",
"measurements": {
"true_positives": 5,
"tp_delta": 0
"false_positives": 1,
"fp_delta": 0
}
},
{
"run_id": "run_y",
"measurements": {
"true_positives": 6,
"tp_delta": 1
"false_positives": 0,
"fp_delta": -1
}
}
I have been able to calculate the deltas to the first or last measurement, but that's not enough. I specifically need consecutive deltas. Calculating deltas with a programming language would, of course, be trivial, but I'd need a way to feed the results to MongoDB Charts. MapReduce would work, except I don't think it works with MongoDB Charts. Saving intermediate results with deltas to the database isn't feasible either since the filtering conditions change.
Is there a way to achieve what I need with aggregation pipelines or should I look at other options? I'm pretty close to ditching MongoDB Charts at this point.