# Get multiple charts from json file

**URL:** https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435
**Category:** Dashboard
**Created:** [22 February 2021 14:55 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435 "2021-02-22T14:55:57Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![kapusticka](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kapusticka](https://discourse.nodered.org/u/kapusticka)
#### Post date: [22 February 2021 14:55 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/1 "2021-02-22T14:55:57Z")

</div>

Hi, I have a json file, which I want to process to multiple charts.my file looks like this:

({"teplota":10.5678,"vlhkost":65.891,"oblacnost":0,"vietor":0,"tlak":1028.18,"smer":"JZ","pocitovo":9.24,"pocasie":"01d","vychod":"06:37","zapad":"17:15","cas":"Pondelok 22.2. 15:44","zrazky24":0});

my vision is to select value "teplota" and render it as a chart, next chart for "vlhkost",etc. thanks for your help.

---

<div class="post-metadata">

### Author: ![linhtranvu](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/linhtranvu/32/30053_2.png) [@linhtranvu](https://discourse.nodered.org/u/linhtranvu)
#### Post date: [22 February 2021 15:06 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/2 "2021-02-22T15:06:26Z")

</div>

Everything explain here

> [@Multiple lines on single chart ui](https://discourse.nodered.org/t/multiple-lines-on-single-chart-ui/29266/3):
>
> I tried your way and passed seperately two function nodes in chart node. Still Only one line is rendered in the chart.Like first temperature line appears for a second and then wind line shows without showing temperature line. My UI has form button when I click it, the function nodes are triggered.[error-mul]

A keyword for your search is “multiple line on single chart”, so you could read more to know about chart data structure. It has been discussed many before

---

<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: [22 February 2021 17:03 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/3 "2021-02-22T17:03:32Z")

</div>

Do you multiple multiple charts, each with one line, or one chart with multiple lines.  
See [these docs](https://github.com/node-red/node-red-dashboard/blob/master/Charts.md) (linked from the chart help text) for how to format data for pre-filling a chart.

---

<div class="post-metadata">

### Author: ![kapusticka](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kapusticka](https://discourse.nodered.org/u/kapusticka)
#### Post date: [22 February 2021 17:09 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/4 "2021-02-22T17:09:26Z")

</div>

That file is rendered from website. I just want to extract some values to the graph.

---

<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: [22 February 2021 17:58 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/5 "2021-02-22T17:58:38Z")

</div>

I am not sure I fully understand. Do you really mean a chart, which is an area with scales and lines drawn on it? You have only shown one set of values so I don't see how that can be used to draw lines.

**[Edit]** Also are the parentheses and semicolon really in the string? If so then strip those off and feed it through a JSON node which should convert the JSON string to a javascript object.

---

<div class="post-metadata">

### Author: ![kapusticka](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kapusticka](https://discourse.nodered.org/u/kapusticka)
#### Post date: [23 February 2021 07:39 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/6 "2021-02-23T07:39:40Z")

</div>

I can't edit an original file, because is on website. here is my flow:

```auto
[{"id":"1a2d781c.46fa4","type":"tab","label":"Weather","disabled":false,"info":""},{"id":"e275a8a5.6029b8","type":"inject","z":"1a2d781c.46fa4","name":"make request","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":100,"y":80,"wires":[["aaf7ab1c.57a3e"]]},{"id":"25dd6728.b352c8","type":"debug","z":"1a2d781c.46fa4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":880,"y":120,"wires":[]},{"id":"aaf7ab1c.57a3e","type":"http request","z":"1a2d781c.46fa4","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"http://meteosasova.sk/bbo_api.php","tls":"","persist":false,"proxy":"","authType":"","x":190,"y":30,"wires":[["da84b8a7.59e13"]]},{"id":"71a1ee05.00e1f","type":"json","z":"1a2d781c.46fa4","name":"","property":"payload","action":"str","pretty":true,"x":340,"y":120,"wires":[["429836e1.7d4568"]]},{"id":"429836e1.7d4568","type":"file","z":"1a2d781c.46fa4","name":"chart","filename":"homie/homey-5ac5f38e42b2c4296e150d77/tester","appendNewline":false,"createDir":true,"overwriteFile":"true","x":460,"y":130,"wires":[["af7ad592.ac9f18"]]},{"id":"2f80eb1c.584794","type":"file in","z":"1a2d781c.46fa4","name":"chart","filename":"homie/homey-5ac5f38e42b2c4296e150d77/tester","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":590,"y":70,"wires":[["a5e9bc66.d78a7"]]},{"id":"714e54e1.d9d134","type":"inject","z":"1a2d781c.46fa4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":590,"y":20,"wires":[["2f80eb1c.584794"]]},{"id":"af7ad592.ac9f18","type":"debug","z":"1a2d781c.46fa4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":470,"y":180,"wires":[]},{"id":"ed17743.b16b308","type":"ui_chart","z":"1a2d781c.46fa4","name":"","group":"8ac23c9c.86f8a8","order":13,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":880,"y":50,"wires":[[]]},{"id":"44e5ee4.4aba71","type":"change","z":"1a2d781c.46fa4","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"meteostanica","tot":"str"},{"t":"set","p":"label","pt":"msg","to":"sasova","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":80,"wires":[["71a1ee05.00e1f"]]},{"id":"a5e9bc66.d78a7","type":"change","z":"1a2d781c.46fa4","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"meteostanica","tot":"str"},{"t":"set","p":"label","pt":"msg","to":"sasova","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":80,"wires":[["ed17743.b16b308","25dd6728.b352c8"]]},{"id":"da84b8a7.59e13","type":"split","z":"1a2d781c.46fa4","name":"","splt":"\\n","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"payload","x":350,"y":30,"wires":[["44e5ee4.4aba71"]]},{"id":"8ac23c9c.86f8a8","type":"ui_group","z":"","name":"Outside weather","tab":"98a2ef12.9e1df","order":1,"disp":false,"width":21,"collapse":false},{"id":"98a2ef12.9e1df","type":"ui_tab","z":"","name":"Weather","icon":"fa-sun-o","order":5,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [23 February 2021 09:03 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/7 "2021-02-23T09:03:58Z")

</div>

> [@kapusticka](#):
>
> I can't edit an original file, because is on website. here is my flow:

But you can manipulate the data once you hav retreived it....

First off, I suggest you run the original request and save the output to a file. That way you can use that file as input to test your flow without hammering the website.

Then I would change the split note to this:  
 ![Screen Shot 2021-02-23 at 3.54.09 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/e/7e74ad89a8b4c03d532a0e1657ff55bbbefe723f.png)

and add a `switch` node to only pass on lines containing `({`  
 ![Screen Shot 2021-02-23 at 3.55.48 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/f/2f4c649af86cddf2a6f16acc0d58c89729d63bec.png)

Now you can use a change node to get rid of what ever you need before feeding it into a `json` node.

---

<div class="post-metadata">

### Author: ![kapusticka](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kapusticka](https://discourse.nodered.org/u/kapusticka)
#### Post date: [23 February 2021 09:21 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/8 "2021-02-23T09:21:08Z")

</div>

can you send me a edited flow?I am not sure where I need to place nodes ☹

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [23 February 2021 09:51 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/9 "2021-02-23T09:51:09Z")

</div>

Here is a screen print of the flow to help you build it:  
 ![Screen Shot 2021-02-23 at 4.49.32 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/e/6ed3abd8e593e50206cd70ed0877c2b3fa0fa32f.png)

Note I had captured the html request and stuck it in a file for testing

---

<div class="post-metadata">

### Author: ![kapusticka](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kapusticka](https://discourse.nodered.org/u/kapusticka)
#### Post date: [23 February 2021 10:48 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/10 "2021-02-23T10:48:51Z")

</div>

> [@zenofmud](#):
>
> ({

what is a "get rid of `(` and `)`? I am not sure what I need to set in "change" node.please export your flow.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [23 February 2021 11:05 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/11 "2021-02-23T11:05:19Z")

</div>

> [@kapusticka](#):
>
> "get rid of `(` and `)` ?

The string you are getting that you display in your first post has opening and closing parentheses. You need to get rid of them so you can convert the line into a json object. Use a `change` node to search for a `(` and replace it with nothing and do the same for the `)`

While I could give you the flow, one learns best by doing 🙂

---

<div class="post-metadata">

### Author: ![kapusticka](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kapusticka](https://discourse.nodered.org/u/kapusticka)
#### Post date: [23 February 2021 11:10 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/12 "2021-02-23T11:10:20Z")

</div>

that is what I tried it. but it gives me a lot of debug messages and it looks like it doesn't work for me ☹

```auto
[{"id":"b6c82e3e.6848d","type":"change","z":"1a2d781c.46fa4","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"(","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":")","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":190,"wires":[["4f96e5c5.27967c"]]}]

```

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [23 February 2021 11:19 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/13 "2021-02-23T11:19:47Z")

</div>

All you have provided is the change node. With no reference to where you put it in your flow or copies of the debug messages, how do you expect someone help you? What kind of debug msgs are you seeing? are they coming from this node? Where did you put the change node?

---

<div class="post-metadata">

### Author: ![kapusticka](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kapusticka](https://discourse.nodered.org/u/kapusticka)
#### Post date: [23 February 2021 12:04 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/14 "2021-02-23T12:04:24Z")

</div>

I have added debug to last node "json file". I see a lot of messages. ☹

 ![Snímka obrazovky 2021-02-23 o 13.03.14](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/b/cb9c8b0e81de50bb1a71c93b86abdde54158d1aa.png)

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [23 February 2021 12:06 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/15 "2021-02-23T12:06:45Z")

</div>

Have ou got your `json` node set to 'Convert between JSON String & Object'? If not, set it to that.

Also give a name to the debug nodes so people can see- in the debug sidebar - which node they come from

---

<div class="post-metadata">

### Author: ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)
#### Post date: [23 February 2021 12:15 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/16 "2021-02-23T12:15:52Z")

</div>

.. and there is still a question mark `;` at the end of the msg.payload string that needs to be filtered out with an additional Change rule ... in order to make it valid JSON

---

<div class="post-metadata">

### Author: ![kapusticka](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kapusticka](https://discourse.nodered.org/u/kapusticka)
#### Post date: [23 February 2021 12:17 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/17 "2021-02-23T12:17:23Z")

</div>

set to "convert between json" it makes me error ☹

 ![Snímka obrazovky 2021-02-23 o 13.16.25](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/d/4d0a5472e1f5eed7a22ee3d3e5583f4a6ac4fc07.png)

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [23 February 2021 12:33 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/18 "2021-02-23T12:33:58Z")

</div>

That means the data you are sending nto the `json` node is not a json string. That means you haven't filtered out oll the data you do not want to pass thru. Not knowing what your 'cchat' file looks like, I can't tell you what to do, but if you put a `debug` on the on the ootput of the `split` node it should tell you what esle to filter out.

---

<div class="post-metadata">

### Author: ![kapusticka](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kapusticka](https://discourse.nodered.org/u/kapusticka)
#### Post date: [23 February 2021 12:44 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/19 "2021-02-23T12:44:58Z")

</div>

I have this in "split" nodes

 ![Snímka obrazovky 2021-02-23 o 13.44.02](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/2/92b2392db9e6be983f5059c9cc4a25a9b68e2fb8.png)  
 ![Snímka obrazovky 2021-02-23 o 13.47.25](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/3/53e3269758ddf4144223d0212db87750676e4de8.png)

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [23 February 2021 14:05 UTC](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435/20 "2021-02-23T14:05:34Z")

</div>

If you look at the last debug, what do you see as the first character in msg.payload and what should it be?

[Next page](https://discourse.nodered.org/t/get-multiple-charts-from-json-file/41435.md?page=2)
