Project

General

Profile

Plotting multiple database-queries in one WCartesianChart

Added by Jörn M over 8 years ago

Hi everybody!

After fiddling around with Dbo::QueryModel and many different SQL-queries for days I'm finally out of inspiration. Essentially I need to figure out a way to use multiple SQL-queries or QueryModels to represent data as graphs or tables to my users in responsive timescales.

But let me explain the problem first:


Scenario:

We have a long, ever-growing SQL-db-table with following columns which is continuously filled by measurements taken by sensors:

id, timestamp, sensor_id, value

Our sensors have different rates of acquisition, so we have different amounts of data taken by every sensor in a given timespan. The backend is using Wt::Dbo so we have easy access to the tables and the representations of the datasets.

-

Goal:

The measurements of a chosen subset of sensors shall be extracted from this table and represented to the user in a time-diagram with on graph per sensor representing the taken values in this interval. And the diagram shall be able to refresh its underlying dataset regularly to allow for quick representation of currently the incoming data.


So far one can smoothly solve all this with Dbo::QueryModel and a WCartesianChart as long as only one sensor is concerned. The multiple sensor part is trickier. Because of the different counts of measurements per time-interval its not trivial to create columns for the different sensors in SQL. All solutions with subqueries, unions and joins I have tried so far lead to gaps in the graphs and/or an exponential increase in processing time of the SQL-Server scaling with the amount of measurements in our table. As the table quickly fills with several hundred values, this leads in minutes to the demise of my poor MySQL-Server.

To come around this, a solution would be to use multiple, independent queries - one for each sensor. My problem now is, that I don't know how this could be achieved efficiently in current Wt / Wt::Dbo. Is there a way to "overlay" graphs with different QueryModels? Did I miss an option which allows to use several QueryModel at once in my WCartesianChart? Or is it possible to combine multiple active QueryModel in one meta-model which I can feed to my WCartesianChart?

Kind regards

Jörn


Replies (1)

RE: Plotting multiple database-queries in one WCartesianChart - Added by Koen Deforche over 8 years ago

Hey,

One WCartesianChart will indeed want data from a single model.

The way I would solve your problem is indeed by creating a 'ProxyModel' (meta model) that takes it's data from multiple source models. As long as they are read-only and tabular, proxy models are simple.

Koen

    (1-1/1)