Count how many times the same unknown json value comes thru

Hey Brains Trust,

I'm trying to do some stats for paging decoder
I used a tcp to receive the JSON data from paging system
I separate the data into Address, Alias and Agency & timestamp

I would like to graph or get stats on how many times an Address gets paged (Per Day to start with) and then use the Alias to display who that address belongs too.

Im having trouble figuring out how to count because the address is unknown and is 7 digits long.

See below my current flow

[
    {
        "id": "71e1ac58ae8f5785",
        "type": "tab",
        "label": "Sonic - Pagermon Stats",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "32f80a696d199e73",
        "type": "tcp in",
        "z": "71e1ac58ae8f5785",
        "name": "",
        "server": "server",
        "host": "",
        "port": "8080",
        "datamode": "stream",
        "datatype": "buffer",
        "newline": "100000",
        "topic": "",
        "trim": false,
        "base64": false,
        "tls": "",
        "x": 120,
        "y": 80,
        "wires": [
            [
                "6cddd30e35d3aced"
            ]
        ]
    },
    {
        "id": "24debaee2abee42a",
        "type": "debug",
        "z": "71e1ac58ae8f5785",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1010,
        "y": 60,
        "wires": []
    },
    {
        "id": "d3ee32429f9c84e6",
        "type": "json",
        "z": "71e1ac58ae8f5785",
        "name": "Convert To Json",
        "property": "payload",
        "action": "obj",
        "pretty": true,
        "x": 420,
        "y": 80,
        "wires": [
            [
                "24debaee2abee42a",
                "b69d5f171bbe7e6f",
                "3c5796d8f5a90fc5"
            ]
        ]
    },
    {
        "id": "6cddd30e35d3aced",
        "type": "function",
        "z": "71e1ac58ae8f5785",
        "name": "Clean TCP Packet",
        "func": "msg.payload = msg.payload.toString('utf8');\nlet body_end = msg.payload.search(\"\\r\\n\\r\\n\");\nlet body = msg.payload.slice(body_end, msg.payload.length);\nmsg.payload=body\nreturn msg",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 170,
        "y": 160,
        "wires": [
            [
                "a5536a1799d369d6",
                "d3ee32429f9c84e6"
            ]
        ]
    },
    {
        "id": "81bfbe3ca6b242a8",
        "type": "function",
        "z": "71e1ac58ae8f5785",
        "name": "Get Agency",
        "func": "msg.payload = msg.payload.agency\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 650,
        "y": 280,
        "wires": [
            [
                "b435fa510a54b22b"
            ]
        ]
    },
    {
        "id": "b435fa510a54b22b",
        "type": "debug",
        "z": "71e1ac58ae8f5785",
        "name": "debug 1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1060,
        "y": 140,
        "wires": []
    },
    {
        "id": "a5536a1799d369d6",
        "type": "debug",
        "z": "71e1ac58ae8f5785",
        "name": "debug 2",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 120,
        "y": 260,
        "wires": []
    },
    {
        "id": "5157af30f56cac22",
        "type": "function",
        "z": "71e1ac58ae8f5785",
        "name": "Get TimeStamp",
        "func": "msg.payload = msg.payload.timestamp\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 660,
        "y": 140,
        "wires": [
            [
                "b435fa510a54b22b"
            ]
        ]
    },
    {
        "id": "9234fb2b2bf1944d",
        "type": "function",
        "z": "71e1ac58ae8f5785",
        "name": "Get Alias",
        "func": "msg.payload = msg.payload.alias\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 640,
        "y": 180,
        "wires": [
            [
                "b435fa510a54b22b"
            ]
        ]
    },
    {
        "id": "b69d5f171bbe7e6f",
        "type": "deduplicate",
        "z": "71e1ac58ae8f5785",
        "name": "Filter Duplicates for 1 Second",
        "keyproperty": "",
        "expiry": "1",
        "x": 390,
        "y": 260,
        "wires": [
            [
                "5157af30f56cac22",
                "9234fb2b2bf1944d",
                "81bfbe3ca6b242a8",
                "9fd4e4625955af85"
            ],
            []
        ],
        "inputLabels": [
            "Eingang"
        ],
        "outputLabels": [
            "Einmal",
            "Duplikat"
        ]
    },
    {
        "id": "3c5796d8f5a90fc5",
        "type": "debug",
        "z": "71e1ac58ae8f5785",
        "name": "debug 4",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 620,
        "y": 40,
        "wires": []
    },
    {
        "id": "9fd4e4625955af85",
        "type": "function",
        "z": "71e1ac58ae8f5785",
        "name": "Get Address",
        "func": "msg.payload = msg.payload.address\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 650,
        "y": 220,
        "wires": [
            [
                "b435fa510a54b22b"
            ]
        ]
    }
]

Any wisdom to help me achieve this

Thanks
Sonic

Do you have any sample data to exercise it ?

Hey @dceejay,

See below example json being send from paging system

{ address: "1112280", timestamp: 1670298810, alias: "Hills FCO/DCO", agency: "The Hills" }
{ address: "6666666", timestamp: 1670299213, alias: "Sonic", agency: "Admin" }
{ address: "1112280", timestamp: 1670298810, alias: "Hills FCO/DCO", agency: "The Hills" }
{ address: "0108111", timestamp: 1670299533, alias: "81 Windsor", agency: "ESPN" }
{ address: "0108811", timestamp: 1670399533, alias: "88 Campbelltown", agency: "ESPN" }
{ address: "0570000", timestamp: 1670399533, alias: "Central Coast Broadcast Message", agency: "RFS" }

Hope this helps

Your example JSON is not a valid json

If it was an array of object you could do something similar to this example

[{"id":"9e0ba0751ef7f149","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"address\":\"1112280\",\"timestamp\":1670298810,\"alias\":\"Hills FCO/DCO\",\"agency\":\"The Hills\"},{\"address\":\"6666666\",\"timestamp\":1670299213,\"alias\":\"Sonic\",\"agency\":\"Admin\"},{\"address\":\"1112280\",\"timestamp\":1670298810,\"alias\":\"Hills FCO/DCO\",\"agency\":\"The Hills\"},{\"address\":\"0108111\",\"timestamp\":1670299533,\"alias\":\"81 Windsor\",\"agency\":\"ESPN\"},{\"address\":\"0108811\",\"timestamp\":1670399533,\"alias\":\"88 Campbelltown\",\"agency\":\"ESPN\"},{\"address\":\"0570000\",\"timestamp\":1670399533,\"alias\":\"Central Coast Broadcast Message\",\"agency\":\"RFS\"}]","payloadType":"json","x":70,"y":4200,"wires":[["0b817630276456cd"]]},{"id":"0b817630276456cd","type":"change","z":"452103ea51141731","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"(\t   $groups := $$.payload{address:$count($)};\t   [\t       {\t           \"series\": [$distinct($$.payload.alias)],\t           \"data\": [[$groups.*]],\t           \"labels\":[$keys($groups)]\t       }\t]\t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":220,"y":4200,"wires":[["bf165f7508b2c5a1"]]},{"id":"bf165f7508b2c5a1","type":"ui_chart","z":"452103ea51141731","name":"","group":"2d4fe667.28f8ba","order":17,"width":0,"height":0,"label":"chart","chartType":"bar","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"],"outputs":1,"useDifferentColor":false,"className":"","x":410,"y":4180,"wires":[["629a73e8a91e3c62"]]},{"id":"629a73e8a91e3c62","type":"debug","z":"452103ea51141731","name":"debug 111","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":4120,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":2,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

To make it per day you would filter the array on the timestamp removing all not in the day concerned.

Hey @E1cid,

Thanks for your effort but this doesn't quite work for me..

So each message comes as a single stream in the following format via TCP on port 8080

{ address: "1112280", timestamp: 1670298810, alias: "Hills FCO/DCO", agency: "The Hills" }

I would need to store the address some how and then group all the address that are the same then count how many values in that group..

I know its not real json.. thats what the paging thing spits out and I cant change it..

Any ideas how I can do this?

Thanks
Sonic

something like this should work

[{"id":"35b363a9adc6fce8","type":"change","z":"452103ea51141731","name":"Quote namds and commas between objects","rules":[{"t":"change","p":"payload","pt":"msg","from":"address","fromt":"str","to":"\"address\"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"timestamp","fromt":"str","to":"\"timestamp\"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"alias","fromt":"str","to":"\"alias\"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"agency","fromt":"str","to":"\"agency\"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"} {","fromt":"str","to":"}, {","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":4020,"wires":[["3e584326107cbc30"]]},{"id":"a4b30fae5dd4c95b","type":"inject","z":"452103ea51141731","name":"simulate incoming object","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"($ran := $floor($random()*5);\t$array := [\t   '{ address: \"1112280\", timestamp: 1670298810, alias: \"Hills FCO/DCO\", agency: \"The Hills\" }',\t'{ address: \"6666666\", timestamp: 1670299213, alias: \"Sonic\", agency: \"Admin\" }',\t'{ address: \"0108111\", timestamp: 1670299533, alias: \"81 Windsor\", agency: \"ESPN\" }',\t'{ address: \"0108811\", timestamp: 1670399533, alias: \"88 Campbelltown\", agency: \"ESPN\" }',\t'{ address: \"0570000\", timestamp: 1670399533, alias: \"Central Coast Broadcast Message\", agency: \"RFS\" }'\t];\t$array[$ran])\t","payloadType":"jsonata","x":190,"y":4060,"wires":[["35b363a9adc6fce8"]]},{"id":"3e584326107cbc30","type":"json","z":"452103ea51141731","name":"","property":"payload","action":"","pretty":false,"x":550,"y":4020,"wires":[["0b817630276456cd"]]},{"id":"0b817630276456cd","type":"change","z":"452103ea51141731","name":"","rules":[{"t":"set","p":"address_count[msg.payload.address]","pt":"flow","to":"{\t   \"count\": $sum(\t       [\t           $lookup($flowContext(\"address_count\"), $$.payload.address ).count\t       ]\t   ) + 1,\t   \"name\": $$.payload.alias\t}\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":4060,"wires":[["629a73e8a91e3c62"]]},{"id":"629a73e8a91e3c62","type":"debug","z":"452103ea51141731","name":"debug 111","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":4000,"wires":[]},{"id":"bf165f7508b2c5a1","type":"ui_chart","z":"452103ea51141731","name":"","group":"2d4fe667.28f8ba","order":17,"width":0,"height":0,"label":"chart","chartType":"pie","legend":"false","xformat":"HH:mm:ss","interpolate":"step","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"],"outputs":1,"useDifferentColor":false,"className":"","x":650,"y":4200,"wires":[["629a73e8a91e3c62"]]},{"id":"4db00729d650c271","type":"change","z":"452103ea51141731","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"address_count","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"[{\t    \"series\":[$keys($$.payload)],\t    \"data\":[[$$.payload.*.count]],\t    \"labels\":[$$.payload.*.name.$substring($, 0, 15)]\t}]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":4200,"wires":[["629a73e8a91e3c62","bf165f7508b2c5a1"]]},{"id":"c6778bcbc1d0e0c6","type":"change","z":"452103ea51141731","name":"","rules":[{"t":"delete","p":"address_count","pt":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":4160,"wires":[["bf165f7508b2c5a1"]]},{"id":"0909e484c5f5bf16","type":"inject","z":"452103ea51141731","name":"every 5mins or what ever","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":4220,"wires":[["4db00729d650c271"]]},{"id":"0116f1fe0953f6b9","type":"inject","z":"452103ea51141731","name":"reset daily","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[]","payloadType":"json","x":100,"y":4160,"wires":[["c6778bcbc1d0e0c6"]]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":2,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

it stores the incoming count per address and creates chart from store count.

May I make a litle suggestion. Before you try to process the data, change it into a json object. This means you will have to add double quotes, commas and brackets but it is easily doable with a change node or two.

Here is what your example data looks like before and after being changed:
Screen Shot 2022-12-08 at 6.16.58 AM

And here is the flow:

[{"id":"b7dcb52616e29887","type":"inject","z":"71e1ac58ae8f5785","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{ address: \"1112280\", timestamp: 1670298810, alias: \"Hills FCO/DCO\", agency: \"The Hills\" } { address: \"6666666\", timestamp: 1670299213, alias: \"Sonic\", agency: \"Admin\" } { address: \"1112280\", timestamp: 1670298810, alias: \"Hills FCO/DCO\", agency: \"The Hills\" } { address: \"0108111\", timestamp: 1670299533, alias: \"81 Windsor\", agency: \"ESPN\" } { address: \"0108811\", timestamp: 1670399533, alias: \"88 Campbelltown\", agency: \"ESPN\" } { address: \"0570000\", timestamp: 1670399533, alias: \"Central Coast Broadcast Message\", agency: \"RFS\" }","payloadType":"str","x":130,"y":60,"wires":[["405a313e2226c4ee","2a80193e61166e70"]]},{"id":"b37bfc7968c42d5f","type":"debug","z":"71e1ac58ae8f5785","name":"Converted data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1080,"y":60,"wires":[]},{"id":"72539a0815f582e0","type":"change","z":"71e1ac58ae8f5785","name":"Quote namds and commas between objects","rules":[{"t":"change","p":"payload","pt":"msg","from":"address","fromt":"str","to":"\"address\"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"timestamp","fromt":"str","to":"\"timestamp\"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"alias","fromt":"str","to":"\"alias\"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"agency","fromt":"str","to":"\"agency\"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"} {","fromt":"str","to":"}, {","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":60,"wires":[["3e584326107cbc30"]]},{"id":"405a313e2226c4ee","type":"change","z":"71e1ac58ae8f5785","name":"Put brackets around data","rules":[{"t":"move","p":"payload","pt":"msg","to":"string","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"[qaz]","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"qaz","fromt":"str","to":"string","tot":"msg"},{"t":"delete","p":"string","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":60,"wires":[["72539a0815f582e0"]]},{"id":"3e584326107cbc30","type":"json","z":"71e1ac58ae8f5785","name":"","property":"payload","action":"","pretty":false,"x":910,"y":60,"wires":[["b37bfc7968c42d5f"]]},{"id":"2a80193e61166e70","type":"debug","z":"71e1ac58ae8f5785","name":"Original data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":290,"y":120,"wires":[]}]

Hi @zenofmud,

Im a bit confused..
Im my flow I have it converted to json didn't I?

Where do I put ur thing in my flow.. I cant get it to work.. comes up with a error

This is the actual output I get after the TCP Clean Up Function

image

I cant change it unfortunalty

I figured it out :slightly_smiling_face:

[
    {
        "id": "71e1ac58ae8f5785",
        "type": "tab",
        "label": "Sonic - Pagermon Stats",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "32f80a696d199e73",
        "type": "tcp in",
        "z": "71e1ac58ae8f5785",
        "name": "",
        "server": "server",
        "host": "",
        "port": "8080",
        "datamode": "stream",
        "datatype": "buffer",
        "newline": "100000",
        "topic": "",
        "trim": false,
        "base64": false,
        "tls": "",
        "x": 120,
        "y": 60,
        "wires": [
            [
                "6cddd30e35d3aced"
            ]
        ]
    },
    {
        "id": "6cddd30e35d3aced",
        "type": "function",
        "z": "71e1ac58ae8f5785",
        "name": "Clean TCP Packet",
        "func": "msg.payload = msg.payload.toString('utf8');\nlet body_end = msg.payload.search(\"\\r\\n\\r\\n\");\nlet body = msg.payload.slice(body_end, msg.payload.length);\nmsg.payload=body\nreturn msg",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 170,
        "y": 160,
        "wires": [
            [
                "a5536a1799d369d6",
                "f71675345d2cb2c8"
            ]
        ]
    },
    {
        "id": "a5536a1799d369d6",
        "type": "debug",
        "z": "71e1ac58ae8f5785",
        "name": "debug 2",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 120,
        "y": 260,
        "wires": []
    },
    {
        "id": "f71675345d2cb2c8",
        "type": "function",
        "z": "71e1ac58ae8f5785",
        "name": "function 1",
        "func": "msg.payload = msg.payload.trim()\nif (msg.payload)\n    return msg\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 400,
        "y": 160,
        "wires": [
            [
                "59d6c9454908cf5f"
            ]
        ]
    },
    {
        "id": "1756233668353fe8",
        "type": "debug",
        "z": "71e1ac58ae8f5785",
        "name": "Converted data",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 840,
        "y": 260,
        "wires": []
    },
    {
        "id": "59d6c9454908cf5f",
        "type": "change",
        "z": "71e1ac58ae8f5785",
        "name": "Put brackets around data",
        "rules": [
            {
                "t": "move",
                "p": "payload",
                "pt": "msg",
                "to": "string",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "[qaz]",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "qaz",
                "fromt": "str",
                "to": "string",
                "tot": "msg"
            },
            {
                "t": "delete",
                "p": "string",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 210,
        "y": 380,
        "wires": [
            [
                "31412dbc69be8552"
            ]
        ]
    },
    {
        "id": "940c1acdf900434c",
        "type": "json",
        "z": "71e1ac58ae8f5785",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 790,
        "y": 380,
        "wires": [
            [
                "1756233668353fe8"
            ]
        ]
    },
    {
        "id": "31412dbc69be8552",
        "type": "change",
        "z": "71e1ac58ae8f5785",
        "name": "Quote namds and commas between objects",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "} {",
                "fromt": "str",
                "to": "}, {",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 530,
        "y": 380,
        "wires": [
            [
                "940c1acdf900434c"
            ]
        ]
    }
]

Its properly formatted json now

Thanks @zenofmud

Still need to figure out how to graph it..

Sorry, I saw the output in post 2 and was working with that. You could strip out the two carrage returns with a simple function

let text = msg.payload
msg.payload = text.substr(2);
return msg;

p.s. I edited your previous post to make the flow importable. You need three back tics before and after your code. :slightly_smiling_face:

what part of the data do you need to graph? What kind of graph?

Well It would be nice to see how many calls per address..
and with that address have the correct brigade.

There is alot of brigades so Im not sure the best way of showing it..
Pie?
Or just have a list of brigades/addresses and the stats next to it..

What would u use?

Thanks
Sonic

Depending on the volume, You could write the data to a database like sqlite and then do a Select count(address), address FROM calls group by address
I threw together an example and here is what the results would look like (data entered multiple times)

or you could create a context variable object and incriment a counted per address.

Thanks @zenofmud

I will write to a sqlite db and then pull the data.. thats the easiest way

Thanks again for your help
sonic

Hey @zenofmud,

So Im using the following flow but cant get it displaying on a graph..

Im using a function with the following code

var counts = [];

msg.payload.forEach(function (row) {
    addresses.push(row.address);
    counts.push(row.count);
});

msg.payload = {
    
    labels: addresses,
    datasets: [
        {
            label: "Message counts",
            data: counts
        }
    ]
};

return msg;

It doesn't display in graph tho..

Thanks
Sonic

You haven't provided your flow just a screen shot of an output and a function nodes code.

Just wondering if you looked at my 2nd example for you?

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