Lines sometimes wrong connected

Hi,
I use the Graph Panel with the MySQL Datasource Plugin.
My Table consists of two values: a Unix Timestamp and a Numeric Value (Double).
for Example:

time data
| 1500826850 | 1.4795 |
| 1500827131 | 1.185 |
| 1500827432 | 1.127 |
| 1500827733 | 1.104714 |
| 1500828034 | 1.882556 |
| 1500828335 | 2.391 |
| 1500828635 | 1.9 |
| 1500828936 | 1.358 |
| 1500829238 | 0.811 |

The data arrives every 5 minutes, but not exaclty in 5 minutes steps.
The SQL Statement is:

SELECT $__time(time_sec), value, metric FROM (SELECT from_unixtime(feed_1591.time) AS time_sec, data AS value, feeds.name AS metric FROM feed_1591, feeds where feeds.id like 1591) feed_1591 where $__timeFilter(time_sec)

When I use:
select feed_1787.time as time_sec, feed_1591.data as value FROM feed_1591
the result is the same.

Somtimes the Graph connects the Line wrong:

Any Idea why? Thanks!

I can’t tell for sure, but I’ve seen this before. I suspect adding an ORDER BY clause to your SQL statement might make the difference (while SQL usually returns data in record order, I don’t think there is any guarantee)

e.g.
SELECT $__time(time_sec), value, metric FROM (SELECT from_unixtime(feed_1591.time) AS time_sec, data AS value, feeds.name AS metric FROM feed_1591, feeds where feeds.id like 1591) feed_1591 where $__timeFilter(time_sec)
ORDER BY time_sec

It would help to post the dataset too, as returned by the query rather than just the screen shots of the result.

2 Likes

Wow, thanks!, that did the Trick:

Just found this post to the particular problem. Thanks a lot!

I really didn’t know how to handle the problem when the lines of the winforms c# chart were connected wrong. Those weird lines really made no sense because it only happened when I loaded the data form the database (msacess)…

Yes, add a SORT BY DATE clause to your SELECT query

“Select * from [MeasurementDataTables] WHERE Object_ID= " + objectID + " ORDER by [MeasurementDataTables_ID]”;

I used the unique identifier to avoid further issues