Hi,
We have time series data that we'd like to display in Highcharts. The data comes every minute. We found that Highcharts can cope with about 2 days of data (2880 points), but after that performance is unacceptable. In order to display N days worth of data we have been selecting every Nth row. That's can be easily achieved in Oracle and PHP. With Mongo the process seem to be less straightforward. The best I could do was to use the mod of the timestamp (tm). The code is to get every second minute.
db.store.aggregate([
{$match: {createdAt: {$gt: ISODate("2015-08-28T03:29:50.868Z"), $lt: ISODate("2015-09-07T03:17:50.754Z")}, station: 200}},
{$group: {_id: {$subtract: ["$tm", {$mod: ["$tm", 1200000]}]},
station: {$first: "$station"},
"t": { $first: "$t" },
"tm": { $first: "$tm" }
}
},
{$sort: {"tm": 1}},
{$group: {_id: "$station", t_series: {$push: {tm: "$tm", t: "$t"}}}}
]);
This, however, returns an array of objects ([{"tm": tm1, "t": t1}, {"tm": tm2, "t": t2}, {"tm": tm3, "t": t3}]). Highcharts do not understand this format, it needs an array of arrays ([[tm1, t1], [tm2, t2], [tm3, t3]]). We have quite a few series and looping through each to create the right format on the client side is time consuming and we'd like to avoid it. We use Meteor for the app, so not sure if we could massage the data on the server to return to the client the correct collection (that could be an option). As a preference we'd like to structure our data in Mongo that we can query and get the format that Highcharts can consume.
Can you help with a more intelligent way of solving this problem (in Mongo or Meteor), please.
Thanks a lot!!!