日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

Showing multiple lines on a single chart in Node-RED

發(fā)布時(shí)間:2024/1/23 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Showing multiple lines on a single chart in Node-RED 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

This simple tutorial explains how to display multiple lines on a Node-RED chart. We’ll be building on a previous example in our lecture series (Example 7.2 in lecture 7)

As discussed in that lecture, let’s set up a simple flow to generate a random number and display it on a chart.

We use a cloud hosted version of Node-RED for these tutorials called FRED. Sign up for a free account at FRED. You can use this tutorial with a vanilla N0de-RED, eg on a Pi, but make sure you are accessing the correct URL for the dashboard (and not the FRED specific one).
To start, let’s wire up a simple flow that sends a random number between 0 and 99 to a simple chart. For that you’ll need an inject node to repeatedly fire every few seconds, a function node to generate the random number and one of the node-red-dashboard nodes – in this case the chart node.

Before we look a how the chart node works, let’s configure the inject node to send a timestamp every 5 seconds by setting the payload to timestamp and the repeat field to an interval of 5 seconds. This will act as our repeating trigger. Now we need to set up the function node to generate a random number – we’ll use a simple JS math function to do this:

msg.payload = Math.round(Math.random()*100);
return msg;

This will generate a random number between 0 ~ 99 which is passed to the chart node.

So now let’s take a look at the chart node. When you double click it, you’ll see it’s configuration options:

If you click on the button of the Group field, you will be prompted to configure the tabs of the UI.

The Tab option allows you to specify which tab of the UI page you will see the UI element on – in this case our chart. The default tab is Home – which we are using here. If you select the edit button to the right of the Tab field you can create a new tab and then select that. However, we’ll use the default home for now.

The Name field is the standard Node-RED node name – by default this is chart but you can set it to anything you like.

The Group field allows you to group UI elements – we’ll show you how that works when we add another UI element so let’s use group “Default[Home]” for now – of course, you can use any string you like.

The X-axis field allows you to tell the chart how much data it should store and display – the longer the ‘last‘ filed is set to, the more data is stored and displayed by the chart. Let’s use a short 5 mins which will start to throw away the data that is 5 minutes old.

Lastly the Interpolate field defines how the chart will interpolate values in between actual data values it receives, you can select between linear, step, b-spline and cardinal – which are standard interpolation algorithms. We’ll use the default linear.

Wire these nodes up, hit the deploy button – check that your debug node is showing that random values are showing. Then head over to your default dashboard page to see the results. By default, under FRED, you’ll see your UI at:

https://{your user name}.fred.sensetecnic.com/api/ui/

When you visit that page you’ll see your initial chart as shown below:

As you can see, you get a nice line chart, scaled for your data values (X axis) and the time they arrived (y axis). You can also see “Default” at the top left of the chart, indicating this is UI group “Default” – which is the group name we set in the configuration fields for the chart node.

Adding a second line to our chart
Ok, now let’s see how to add another line to the same chart.

If you take a look at the info box for the chart node, you’ll see it mentions that the the msg.topic field can be used to show multiple lines. Essentially the chart node will receive messages, take a look at the msg.topic field, and then append the data to the appropriate line as defined by the topic.

So, to extend our example to handle multiple lines on a single chart, we have to do two things:

update our function node to generate two random numbers and assign these to different messages with different topics
Wire up a second output from the function node to handle the second message
To do that, open up the function node and update the code inside as shown below. As you can see we explicitly create two messages, msg and msg1 (lines 1-2).

At line 4-5 we set msg.topic to ‘Line1’ and a random number is assigned to the payload. We repeat that at line7-8 setting msg1.topic to ‘Line2’ and assigning a different random number.

screen-shot-2016-12-05-at-5-28-56-pm

Both messages are returned using the return message (line 9) – because we are generating two return message, we need to tell the function node that it has two outputs by setting the outputs field to 2 (see above).

More details of generating multiple messages from nodes can be found in the main lectures Example 5.2 in lecture 5.

Once you’ve done this, your flow should look like the screen shot below.

screen-shot-2016-12-05-at-5-23-17-pm

Wire up both outputs from the function node to the chart node and then take a look at the dashboard and the chart. As you can see (shown below) the chart now shows two lines (Line1 and Line2) with different colours. Note we set the dashboard theme to dark to make the two lines clearer.screen-shot-2016-12-05-at-5-24-06-pm

Obviously this example is contrived, in a more realistic example you might have two sources of data, and so two function nodes delivering messages (rather than the single function node with two outputs).

In addition, you’d be pulling the data from a real source, e.g. a web scrape, an MQTT feed or perhaps a DB. You can see examples of these:

Scraping financial data from a web site (Example 6.1 in lecture 6)
Getting data from an MQTT broker (Example 3.1 in lecture 3)
Graphing data from a SQLite node (SQLite tutorial)

總結(jié)

以上是生活随笔為你收集整理的Showing multiple lines on a single chart in Node-RED的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 国产精品秘入口18禁麻豆免会员 | 久久久高清免费视频 | 91免费视频国产 | 欧美在线观看一区 | 欧美成人午夜精品久久久 | 国内老熟妇对白hdxxxx | 亚洲一级色 | 国产一区二区三区视频网站 | 亚洲精品国产精品乱码不卡 | 无码精品一区二区三区AV | 亚洲国产影院 | 最新中文字幕一区 | 久久久久久久久免费 | 日批免费在线观看 | 女同性做受全过程动图 | 91蝌蚪视频在线观看 | 亚洲天堂精品一区 | 亚洲国产毛片aaaaa无费看 | 在线观看亚洲大片短视频 | 久草网在线观看 | 国产成人精品一区二区在线小狼 | 国产精品卡一卡二 | 99riav1国产精品视频 | 国产精品成人免费一区久久羞羞 | 男人天堂网av | 潘金莲一级淫片免费放动漫 | 毛片直接看 | 色天天综合 | 少妇裸体视频 | 少妇做爰免费理伦电影 | av免费网站观看 | 69影院少妇在线观看 | 日本一区二区精品视频 | 日韩激情一区二区三区 | 久久久久久99精品 | 日本韩国欧美中文字幕 | 性插插视频 | 午夜精品一区二区三区在线播放 | 91美女片黄 | av片网| 国产三级久久 | 色噜噜成人 | 天天5g天天爽免费观看 | 久久久久中文 | www.日韩视频 | 一级视频在线观看 | 亚洲AV无码成人精品区明星换面 | 亚洲图片中文字幕 | 久一在线视频 | 天天干天天舔天天操 | www亚洲| 国产吃瓜在线 | 少妇被爽到高潮动态图 | 中国女人内96xxxxx | 黄视频在线观看免费 | 国产视频999| 色屋视频 | 日本高清免费不卡视频 | 日韩黄色片网站 | 无码国产精品久久一区免费 | 五月开心网 | 18成人在线观看 | 国产成人短视频在线观看 | 免费无遮挡无码永久视频 | 久久艹免费视频 | 欧美v日本 | 男人操女人网站 | 亚洲乱仑 | 亚洲欧美在线观看视频 | 超碰在线97观看 | 69国产成人精品二区 | 亚洲黄色片免费看 | 国产成人自拍在线 | 亚洲一区二区麻豆 | 国产伦精品一区二区三区视频痴汉 | 国产免费视频一区二区三区 | 色综合图片 | 羞羞羞网站| 日本3p视频 | 快射视频网站 | 日韩一本在线 | 国产欧美激情 | 东京热加勒比无码少妇 | 国产91精品久久久久久久网曝门 | 欧美性猛交xxxx偷拍洗澡 | 久久9966| 亚洲射射 | 手机看片福利视频 | 97国产视频 | 天天狠狠干 | 久久www视频 | 国产精品白虎 | 黄av在线播放 | 国产香蕉视频在线观看 | 亚洲不卡电影 | 体感预报日剧 | 国产日韩欧美电影 | 91精品国产aⅴ一区 黄色a网 | 成人日韩视频 |