# Dashboard 2 persistent data in chart node

**URL:** <https://discourse.nodered.org/t/dashboard-2-persistent-data-in-chart-node/94618>\
**Category:** Dashboard\
**Tags:** dashboard-2\
**Created:** [14 January 2025 17:52 UTC](https://discourse.nodered.org/t/dashboard-2-persistent-data-in-chart-node/94618 "2025-01-14T17:52:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SveinHa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sveinha/32/71169_2.png) [@SveinHa](https://discourse.nodered.org/u/SveinHa)\
**Post date:** [14 January 2025 17:52 UTC](https://discourse.nodered.org/t/dashboard-2-persistent-data-in-chart-node/94618/1 "2025-01-14T17:52:31Z")

</div>

Is it possible to get persistent data during Node-RED restart/reboot in a dash2 chart node?

In the Dash1 I can use "node-red-contrib-persist" to store all chartdata and automatically reload on restart:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/4/040967d5d30342030f69eee5debc01cb7d5ab6e4.png)

It seems like Dash2/Chart only outputs every single msg received and not the complete chartdata like Dash1/Chart does.

This also makes each topic appear in a more or less random order when the chart is initialized which in turn changes pen colors to the order of which the dara reappears. This problem I have solved with a function sending dummy data with the correct topics on the correct order on reboot:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/2/a22490be6ce3ecfd5c4798e7a2f4f1ff0fa7692c.png)

This is usuallt no big deal but I have a few charts that have an x-axis span of 4 days and even one that is 6 weeks...

---

<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:** [15 January 2025 08:43 UTC](https://discourse.nodered.org/t/dashboard-2-persistent-data-in-chart-node/94618/2 "2025-01-15T08:43:41Z")

</div>

There is already a feature request for this. You could add your comments there.

> <https://github.com/FlowFuse/node-red-dashboard/issues/1362>
>
> \### Description
> 
> The V1 chart has a tested and working subflow that saves the …data and reloads the data 
> after a restart. This is pretty vital functionality and needed for V2 charts.
> Can someone have look at this when there is time please?
> 
> I tested the old working subflow with the V 2 chart and as expected it does not work.
> It would be great if this subflow could be updated to work with 2.0.
> or of course any other way to have the data survive reboots if possible?
> This is the subflow that worked with V1 hooked up to a V2 chart for tests:
> 
> \`\`\`
> \[
> {
> "id": "3b6a1337b69e1574",
> "type": "subflow",
> "name": "vvb d2",
> "info": "",
> "category": "",
> "in": \[
> {
> "x": 50,
> "y": 30,
> "wires": \[
> {
> "id": "0803c4cc5eb6de01"
> }
> \]
> }
> \],
> "out": \[
> {
> "x": 820,
> "y": 160,
> "wires": \[
> {
> "id": "1d445f73ea677ec2",
> "port": 0
> },
> {
> "id": "de6cdd9bd32b3eb1",
> "port": 0
> }
> \]
> }
> \],
> "env": \[\],
> "meta": {},
> "color": "#DDAA99"
> },
> {
> "id": "1d445f73ea677ec2",
> "type": "file",
> "z": "3b6a1337b69e1574",
> "name": "",
> "filename": "",
> "appendNewline": true,
> "createDir": true,
> "overwriteFile": "true",
> "x": 660,
> "y": 140,
> "wires": \[
> \[\]
> \]
> },
> {
> "id": "006debb5e922bb46",
> "type": "file in",
> "z": "3b6a1337b69e1574",
> "name": "",
> "filename": "",
> "format": "utf8",
> "sendError": true,
> "x": 500,
> "y": 180,
> "wires": \[
> \[
> "de6cdd9bd32b3eb1"
> \]
> \]
> },
> {
> "id": "e37d519cbbd162d3",
> "type": "json",
> "z": "3b6a1337b69e1574",
> "name": "",
> "x": 500,
> "y": 140,
> "wires": \[
> \[
> "1d445f73ea677ec2"
> \]
> \]
> },
> {
> "id": "de6cdd9bd32b3eb1",
> "type": "json",
> "z": "3b6a1337b69e1574",
> "name": "",
> "x": 660,
> "y": 180,
> "wires": \[
> \[\]
> \]
> },
> {
> "id": "0803c4cc5eb6de01",
> "type": "function",
> "z": "3b6a1337b69e1574",
> "name": "LoadSave",
> "func": "var strSafe=msg.topic;\\nif(strSafe)\\n{\\n strSafe=strSafe.replace(/\[^a-z0-9\]/gi, '\_').toLowerCase();\\n var loaded=context.get(strSafe)||0;\\n msg.filename =\\"/home/hb19/.node-red/flowsave/vvbd2/\\"+strSafe+\\".dat\\";\\n //node.warn(loaded);\\n if(0===loaded)\\n {\\n //load chart!! \\n msg.payload=\\"load\\";\\n context.set(strSafe,1);\\n \\n //node.warn(\\"Loading \\" +strSafe);\\n }\\n else\\n {\\n //node.warn(\\"Writing \\" +strSafe);\\n }\\n return msg; \\n}\\nreturn null;\\n\\n",
> "outputs": 1,
> "timeout": "",
> "noerr": 0,
> "initialize": "",
> "finalize": "",
> "libs": \[\],
> "x": 200,
> "y": 160,
> "wires": \[
> \[
> "abd9aa795d47fbc6"
> \]
> \]
> },
> {
> "id": "abd9aa795d47fbc6",
> "type": "switch",
> "z": "3b6a1337b69e1574",
> "name": "Load data",
> "property": "payload",
> "propertyType": "msg",
> "rules": \[
> {
> "t": "neq",
> "v": "load",
> "vt": "str"
> },
> {
> "t": "eq",
> "v": "load",
> "vt": "str"
> }
> \],
> "checkall": "false",
> "repair": false,
> "outputs": 2,
> "x": 350,
> "y": 160,
> "wires": \[
> \[
> "e37d519cbbd162d3"
> \],
> \[
> "006debb5e922bb46"
> \]
> \]
> },
> {
> "id": "3dc8c1a1d345ef1d",
> "type": "ui-chart",
> "z": "98b31619.daed3",
> "g": "120d335300e6531b",
> "group": "f83d15d3a238accd",
> "name": "vvb chart week",
> "label": "",
> "order": 4,
> "chartType": "line",
> "category": "topic",
> "categoryType": "msg",
> "xAxisLabel": "",
> "xAxisProperty": "",
> "xAxisPropertyType": "property",
> "xAxisType": "time",
> "xAxisFormat": "",
> "xAxisFormatType": "auto",
> "yAxisLabel": "",
> "yAxisProperty": "",
> "ymin": "15",
> "ymax": "65",
> "action": "append",
> "stackSeries": false,
> "pointShape": "line",
> "pointRadius": "2",
> "showLegend": false,
> "removeOlder": 1,
> "removeOlderUnit": "604800",
> "removeOlderPoints": "",
> "colors": \[
> "#ff9300",
> "#00fdff",
> "#ff7f0e",
> "#2ca02c",
> "#a347e1",
> "#d62728",
> "#ff9896",
> "#9467bd",
> "#c5b0d5"
> \],
> "textColor": \[
> "#ffffff"
> \],
> "textColorDefault": false,
> "gridColor": \[
> "#7a7a7a"
> \],
> "gridColorDefault": false,
> "width": "30",
> "height": "10",
> "className": "",
> "x": 4420,
> "y": 540,
> "wires": \[
> \[
> "2e85ceab3abb96f6"
> \]
> \]
> },
> {
> "id": "2e85ceab3abb96f6",
> "type": "subflow:3b6a1337b69e1574",
> "z": "98b31619.daed3",
> "g": "120d335300e6531b",
> "name": "",
> "x": 4430,
> "y": 600,
> "wires": \[
> \[
> "3dc8c1a1d345ef1d"
> \]
> \]
> },
> {
> "id": "f83d15d3a238accd",
> "type": "ui-group",
> "name": "vvb",
> "page": "40ab10feb1ddf2bb",
> "width": "30",
> "height": "20",
> "order": 1,
> "showTitle": false,
> "className": "",
> "visible": "true",
> "disabled": "false"
> },
> {
> "id": "40ab10feb1ddf2bb",
> "type": "ui-page",
> "name": "vvb",
> "ui": "cd62f850b848415c",
> "path": "/vvb",
> "icon": "home",
> "layout": "grid",
> "theme": "404b2b83a6155d6c",
> "breakpoints": \[
> {
> "name": "Default",
> "px": "0",
> "cols": "30"
> },
> {
> "name": "Tablet",
> "px": "1080",
> "cols": "30"
> },
> {
> "name": "Small Desktop",
> "px": "1080",
> "cols": "30"
> },
> {
> "name": "Desktop",
> "px": "1080",
> "cols": "30"
> }
> \],
> "order": 1,
> "className": "",
> "visible": true,
> "disabled": false
> },
> {
> "id": "cd62f850b848415c",
> "type": "ui-base",
> "name": "flax 24",
> "path": "/dashboard",
> "includeClientData": true,
> "acceptsClientConfig": \[
> "ui-notification",
> "ui-control"
> \],
> "showPathInSidebar": false,
> "showPageTitle": false,
> "navigationStyle": "default",
> "titleBarStyle": "default"
> },
> {
> "id": "404b2b83a6155d6c",
> "type": "ui-theme",
> "name": "dark jtm",
> "colors": {
> "surface": "#000000",
> "primary": "#0094ce",
> "bgPage": "#000000",
> "groupBg": "#000000",
> "groupOutline": "#000000"
> },
> "sizes": {
> "pagePadding": "12px",
> "groupGap": "12px",
> "groupBorderRadius": "4px",
> "widgetGap": "12px",
> "density": "comfortable"
> }
> }
> \]
> \`\`\`
> 
> \### Have you provided an initial effort estimate for this issue?
> 
> I am no FlowFuse team member

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [15 January 2025 09:11 UTC](https://discourse.nodered.org/t/dashboard-2-persistent-data-in-chart-node/94618/3 "2025-01-15T09:11:05Z")

</div>

Hi @joepavitt,

I think a native integration would be the best option for users. They will no longer need to go through a database or any other node.

NR offers an API to write and retrieve data: `RED.storage.saveLibraryEntry`

[https://nodered.org/docs/api/storage/methods](https://nodered.org/docs/api/storage/methods)

I've never used it but in theory it should do the job.

---

<div class="post-metadata">

**Author:** ![joepavitt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/joepavitt/32/59722_2.png) [@joepavitt](https://discourse.nodered.org/u/joepavitt)\
**Post date:** [15 January 2025 09:35 UTC](https://discourse.nodered.org/t/dashboard-2-persistent-data-in-chart-node/94618/4 "2025-01-15T09:35:13Z")

</div>

Yeah, this has come up enough times now that we need to pay attention to it. For what it's worth, you can store all of your messages into a context variable or persisted file, and just pass an array of messages back into your chart - that will work, but is more manual that it needs to be.

---

<div class="post-metadata">

**Author:** ![SveinHa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sveinha/32/71169_2.png) [@SveinHa](https://discourse.nodered.org/u/SveinHa)\
**Post date:** [15 January 2025 09:41 UTC](https://discourse.nodered.org/t/dashboard-2-persistent-data-in-chart-node/94618/5 "2025-01-15T09:41:25Z")

</div>

Thanks all. I did a search before posting but didn't find any posts that I could recognise as a similar feature.

Looks like a solution is not too far in the future...

---

<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:** [14 February 2025 09:42 UTC](https://discourse.nodered.org/t/dashboard-2-persistent-data-in-chart-node/94618/6 "2025-02-14T09:42:12Z")

</div>

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