# Display mysql with two lines in one graph

**URL:** <https://discourse.nodered.org/t/display-mysql-with-two-lines-in-one-graph/37729>\
**Category:** Dashboard\
**Created:** [18 December 2020 21:47 UTC](https://discourse.nodered.org/t/display-mysql-with-two-lines-in-one-graph/37729 "2020-12-18T21:47:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oma](https://avatars.discourse-cdn.com/v4/letter/o/977dab/32.png) [@oma](https://discourse.nodered.org/u/oma)\
**Post date:** [18 December 2020 21:47 UTC](https://discourse.nodered.org/t/display-mysql-with-two-lines-in-one-graph/37729/1 "2020-12-18T21:47:24Z")

</div>

Hi there,

i am pretty new to Node-RED but with a lot of searching and testing i got pretty far. My Goal is now to query data from a MariaDB inserted by Node Red earlier. The table looks like this:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/6/66a61a111b89b078f90771e848c258d8aed70e86.png)

The data inserted are heating related: current temperature (Temperatur) and Valve (Ventil) and i would love to have the graph showing both as separate line within the same graph.  
My sql query sends me back an object containing the rows expected:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/e/2e85cd2e7cd9f45b27516fbda96f999cb825e1b0.png)

Google told me to create a "change" Node to format the data but i assume it was designed for a table where one row contains ALL the data to display at once which is not the case for me as it is in two seperate rows. I was hoping the following would do it but this is unfortunately not doing the trick:

```auto
(
  $series := [
    { "Temperatur": "Wert", "label": "Wert1 label" },
    { "Ventil": "Wert", "label": "Wert2 label" }
  ];
  $xaxis := "timestamp";
  [
    {
      "series": $series.label,
      "data": $series.[
        (
          $yaxis := $.field;
          $$.payload.{
            "x": $lookup($, $xaxis),
            "y": $lookup($, $yaxis)
          }
        )
      ]
    }
  ]
)

```

I believe i have to edit the change node, split the data in two topics and connect this to the graph to display it - but i have no clue how the function need to look like. I know i can query the database twice and select upfront the right rows but i would like to save bandwith and "split" based on a single query. Can anyone help? Appreciate any feedback!

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [18 December 2020 22:04 UTC](https://discourse.nodered.org/t/display-mysql-with-two-lines-in-one-graph/37729/2 "2020-12-18T22:04:20Z")

</div>

Hi @oma, welcome to the forum.

this topic has been covered many many times - search the forum.

[Here](https://discourse.nodered.org/t/dynamic-series-identification-from-message-send-data-to-chart/36682/5) is one such solution

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 January 2021 22:04 UTC](https://discourse.nodered.org/t/display-mysql-with-two-lines-in-one-graph/37729/3 "2021-01-17T22:04:23Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
