# Dashboard 2 multiple line from sql database

**URL:** <https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774>\
**Category:** Dashboard\
**Tags:** dashboard-2\
**Created:** [25 November 2025 11:48 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774 "2025-11-25T11:48:06Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![warnert](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/warnert/32/108132_2.png) [@warnert](https://discourse.nodered.org/u/warnert)\
**Post date:** [25 November 2025 11:48 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/1 "2025-11-25T11:48:06Z")

</div>

I am migrating from Dashboard 1 to Dashboard 2. I select temperatures from a database (mariadb) from a whole day and format those with a JSONata expression in a change-node. Dash1 gives a nice graph with the 3 temperature values from the whole day, but dash2 displays the mysql statement that was used to get the data. Both have the GRAPH node.  
Anyone any ideas how to tackle this?  
Do you need more info?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [25 November 2025 11:54 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/2 "2025-11-25T11:54:49Z")

</div>

> [@warnert](#):
>
> Do you need more info?

Yes. SQL query & output data. Picture of Dashboard 1 chart. Picture of Dashboard 2 chart displaying the sql statement.

---

<div class="post-metadata">

**Author:** ![warnert](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/warnert/32/108132_2.png) [@warnert](https://discourse.nodered.org/u/warnert)\
**Post date:** [25 November 2025 11:55 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/3 "2025-11-25T11:55:34Z")

</div>

This is the JSONata:

```auto
(
  $series := [
    { "field1": "d_waarde", "field2": "d_max", "field3": "d_min", "label": "TuinTemp" }
  ];
  $xaxis := "UNIX_TIMESTAMP(d_ts)";
  [
    {
      "series": ["Huidig","Max","Min"],
      "labels": [$series.label],
      "data": $series.[[
        (
          $yaxis := $.field1;
          $$.payload.{
            "x": $lookup($, $xaxis)*1000,
            "y": $number($lookup($, $yaxis))
          }
        )
      ],[
        (
          $yaxis := $.field2;
          $$.payload.{
            "x": $lookup($, $xaxis)*1000,
            "y": $number($lookup($, $yaxis))
          }
        )
      ],[
        (
          $yaxis := $.field3;
          $$.payload.{
            "x": $lookup($, $xaxis)*1000,
            "y": $number($lookup($, $yaxis))
          }
        )
      ]]
    }
  ]
)

```

---

<div class="post-metadata">

**Author:** ![warnert](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/warnert/32/108132_2.png) [@warnert](https://discourse.nodered.org/u/warnert)\
**Post date:** [25 November 2025 12:03 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/4 "2025-11-25T12:03:28Z")

</div>

SQL Query:

```auto
SELECT UNIX_TIMESTAMP(d_ts), d_waarde, d_max, d_min
FROM data
WHERE d_ts >= "{{payload}}:00:00:00"
    AND d_ts <= "{{payload}}:23:59:59"
ORDER BY d_ts ASC;

```

Dash1:

 ![Dash1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/9/69834c061a9a458087e0498bad3d0e9d2a942e71.jpeg)  
Dash2:  
 ![Dash2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/0/7059cd5ad1608f05d3dba3bd738e1a7ebf45313f.jpeg)

```auto
SELECT UNIX_TIMESTAMP(d_ts), d_waarde, d_max, d_min FROM data WHERE d_ts >= "2022-11-02:00:0... : msg.payload : array[1]
array[1]
0: object
series: array[3]
0: "Huidig"
1: "Max"
2: "Min"
labels: array[1]
0: "TuinTemp"
data: array[3]
0: array[915]
1: array[915]
2: array[915]

```

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [25 November 2025 12:18 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/5 "2025-11-25T12:18:10Z")

</div>

For dashboard 2 you do not need to process the SQL output to give (x,y) couplets. You should be able to wire directly from the SQL node to the chart.

I would use aliases in the query. I may have misunderstood Huidig/d\_waarde since I don't recognise the language.

```auto
SELECT UNIX_TIMESTAMP(d_ts) AS ts, d_waarde AS Huidig, d_max AS Max, d_min AS Min ,,,,

```

Then try configuring the chart like this.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/2/c2241ab1c2e4d79781f9b85953e0019360eccc49.png)

If it doesn't work, post some actual SQL output for us to experiment with.

---

<div class="post-metadata">

**Author:** ![warnert](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/warnert/32/108132_2.png) [@warnert](https://discourse.nodered.org/u/warnert)\
**Post date:** [25 November 2025 12:45 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/6 "2025-11-25T12:45:32Z")

</div>

The strange thing is, was, that although I cnaged the sql statement the statement in the graph stayed the same. So I deleted the node and created a new one and now it works.  
Thanks

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [25 November 2025 12:50 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/7 "2025-11-25T12:50:04Z")

</div>

Dashboard 2 seems to cling to previously displayed data.

If you change a widget config, always reload the dashboard and if that doesn't show the new version, force a reload (ctrl f5 or shift ctrl r or something like that) or clear the browser cache.

---

<div class="post-metadata">

**Author:** ![warnert](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/warnert/32/108132_2.png) [@warnert](https://discourse.nodered.org/u/warnert)\
**Post date:** [2 December 2025 09:36 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/8 "2025-12-02T09:36:14Z")

</div>

To continue the quest for info: I tried to use the same solution for a 1 line graph and that does not work. I get a very strange graph. The graph is supposed to show the roomtemperature for a whole day.

 ![RoomTemp](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/9/b9ae07364d75d790f004d26ce139e4b882d67d21.jpeg)

---

<div class="post-metadata">

**Author:** ![warnert](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/warnert/32/108132_2.png) [@warnert](https://discourse.nodered.org/u/warnert)\
**Post date:** [2 December 2025 09:42 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/9 "2025-12-02T09:42:07Z")

</div>

I use this sql statement:  
`SELECT UNIX_TIMESTAMP(mw_timestamp) AS ts,mw_data AS mw FROM meetwaarden WHERE mw_se_id = 1 LIMIT 10`  
And this as properties for the graph:

 ![GraphProps](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/f/cf891a007919698aca92e4c27a27a44101a30285.jpeg)  
This comes out the SQL:  
 ![SQLoutput](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/3/c36062c3634dd0086e950ebeb14bc33c0af2c1be.jpeg)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 December 2025 10:14 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/10 "2025-12-02T10:14:16Z")

</div>

Show us what is going into the chart.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 December 2025 10:16 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/11 "2025-12-02T10:16:02Z")

</div>

Or is the sql node directly wired to the chart?

---

<div class="post-metadata">

**Author:** ![warnert](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/warnert/32/108132_2.png) [@warnert](https://discourse.nodered.org/u/warnert)\
**Post date:** [2 December 2025 10:19 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/12 "2025-12-02T10:19:08Z")

</div>

it is yes at the moment

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [2 December 2025 10:22 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/13 "2025-12-02T10:22:38Z")

</div>

I can't explain why it's different but if you change Series from type Json to string, then you get to specify the source of both X and Y.  
In your case X should be key ts, Y should be key mw.

I have no idea what the string value of Series is used for here.  
In my example it does not seem to make any difference what value I give it, but neither can I get the legend to show up.

---

<div class="post-metadata">

**Author:** ![warnert](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/warnert/32/108132_2.png) [@warnert](https://discourse.nodered.org/u/warnert)\
**Post date:** [2 December 2025 10:24 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/14 "2025-12-02T10:24:02Z")

</div>

Oh and the solution to the original question is not complete, I cannot get the horizontal values to display the time correctly. This is from one day (30-11-2025):

 ![DayGraph](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/b/4b5a170d7f5b0beaec71386efd8f6df0425d6cdb.jpeg)  
It seems not to understand the Unix timestamp  
This what comes out:  
 ![SQLoutput2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/f/9f62cddfc9691d02623ac167ad7d0368f2632bd5.jpeg)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [2 December 2025 10:32 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/15 "2025-12-02T10:32:30Z")

</div>

A unix\_timestamp is seconds since god created the universe (January 1970).  
A javascript timestamp is milliseconds since the creation, and the chart assumes you are giving it a js timestamp.

If UNIX\_TIMESTAMP() is not really what you intend to select, you have to research how to select a js timestamp, or just multiply it by 1000  
SELECT UNIX\_TIMESTAMP(mw\_timestamp) \* 1000 AS ts (untested)  
What happens if you just select mw\_timestamp?

---

<div class="post-metadata">

**Author:** ![warnert](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/warnert/32/108132_2.png) [@warnert](https://discourse.nodered.org/u/warnert)\
**Post date:** [2 December 2025 10:42 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/16 "2025-12-02T10:42:23Z")

</div>

The \*1000 works...

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [2 December 2025 10:53 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/17 "2025-12-02T10:53:46Z")

</div>

Ah. But is it the right solution?

---

<div class="post-metadata">

**Author:** ![warnert](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/warnert/32/108132_2.png) [@warnert](https://discourse.nodered.org/u/warnert)\
**Post date:** [2 December 2025 11:18 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/18 "2025-12-02T11:18:56Z")

</div>

The multiple line graph works now OK but the single line doesn't yet.  
And the date picker from the TextInput returns a string...  
`2025-11-28T23:00:05.000Z`

---

<div class="post-metadata">

**Author:** ![warnert](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/warnert/32/108132_2.png) [@warnert](https://discourse.nodered.org/u/warnert)\
**Post date:** [2 December 2025 16:32 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/19 "2025-12-02T16:32:26Z")

</div>

I now have the single line working ok with series to none x to key ts and y to key mw.  
The only problem is that now the datapoints are given in succession all the colors of the series and not one color.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 December 2025 17:12 UTC](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774/20 "2025-12-02T17:12:26Z")

</div>

Can use the Copy Value button that pops up in the debug pane to copy a set of values and paste them here. Also select the Chart node and Export that and paste it here too. Then we can put the values into an Inject node and use that to simulate your data. See the canned text below on how to get the Copy Value feature.

There’s a great page in the docs ([Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)) that will explain how to use the debug panel to find the right path/value for any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

[Next page](https://discourse.nodered.org/t/dashboard-2-multiple-line-from-sql-database/99774.md?page=2)
