1. 程式人生 > 其它 >Node-RED中使用node-random節點來實現隨機數在折線圖中顯示

Node-RED中使用node-random節點來實現隨機數在折線圖中顯示

場景

Node-RED簡介與Windows上安裝、啟動和執行示例:

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/121884766

Node-RED怎樣匯出匯入流程為json檔案:

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/124130985

Node-RED安裝圖形化節點dashboard實現訂閱mqtt主題並在儀表盤中顯示溫度:

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/121992760

在上面的基礎上怎樣使用node-random隨機數節點,並構造出變化的模擬資料

在折線圖中顯示。

 

 

 

注:

部落格:
https://blog.csdn.net/badao_liumang_qizhi
關注公眾號
霸道的程式猿
獲取程式設計相關電子書、教程推送與免費下載。

實現

1、選單-節點管理-搜尋node-red-node-random隨機數節點,來產生隨機數。

 

 

然後就可以在面板中找到random元件

 

編輯random節點從1到100

 

 

2、拖拽chart元件並編輯折線圖屬性

 

 

 

設定inject節點每隔兩秒執行

 

 

 

3、json資料

[
    {
        "id": "bd92edab3c781ab4
", "type": "inject", "z": "f4a4d8eab7935bc8", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "2", "crontab": ""
, "once": false, "onceDelay": 0.1, "topic": "", "payloadType": "date", "x": 220, "y": 180, "wires": [ [ "97002e0a588d91d2" ] ] }, { "id": "3ecb265fb81d22fc", "type": "debug", "z": "f4a4d8eab7935bc8", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 590, "y": 180, "wires": [] }, { "id": "97002e0a588d91d2", "type": "random", "z": "f4a4d8eab7935bc8", "name": "", "low": 1, "high": "100", "inte": "true", "property": "payload", "x": 400, "y": 180, "wires": [ [ "3ecb265fb81d22fc", "6a376c712f33f004" ] ] }, { "id": "6a376c712f33f004", "type": "ui_chart", "z": "f4a4d8eab7935bc8", "name": "", "group": "248cbbb0.18e794", "order": 1, "width": 0, "height": 0, "label": "折線圖", "chartType": "line", "legend": "false", "xformat": "HH:mm:ss", "interpolate": "linear", "nodata": "", "dot": false, "ymin": "", "ymax": "", "removeOlder": 1, "removeOlderPoints": "20", "removeOlderUnit": "3600", "cutout": 0, "useOneColor": false, "useUTC": false, "colors": [ "#1f77b4", "#aec7e8", "#ff7f0e", "#2ca02c", "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5" ], "outputs": 1, "useDifferentColor": false, "className": "", "x": 570, "y": 260, "wires": [ [] ] }, { "id": "248cbbb0.18e794", "type": "ui_group", "name": "MyGroup", "tab": "3f79c420.cfc1bc", "order": 1, "disp": true, "width": "6", "collapse": false }, { "id": "3f79c420.cfc1bc", "type": "ui_tab", "name": "Home", "icon": "dashboard", "disabled": false, "hidden": false } ]