Use data in an xml file to make a graph

Hello,

I want to retrieve data in the following XML file in order to create graphs.

The data I want is the timestamp of each item as well as the value.

I have no idea how to proceed. Can anyone help me? Thank you.

The X axis must be timestamp and Y = value.

Welcome to the forum.

The first thing to do is to send it through an XML node and see what you get out.

Hello, thank you for your answer. Here is what I did and the results I get.


What do the timestamps and values look like?

To that :

The timestamps look ok, presumably you know what time zone they are in. The values will need to be turned into numbers, presumably 1,04 represents 1.04. If the file cold be produced with dots instead of commas it would help, but it isn't a big problem.

Now that you have the data in a javascript object you just need to turn it into the format required by the chart. This document describes what is needed, in the section Stored Data.

You haven't given us any indication of your experience, if you are a node red beginner then I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

Then have a look at the node red docs pages Working with Messages and Writing Functions.

Then if necessary come back and tell us which bit you are having difficulty with.

Thank you very much for the information.

Nevertheless, I am stuck at converting string to number.

msg2.payload is of type string and I would like it to be in full so that it can be used for creating the chart.

So I tried using Number (), parseInt (), and parseFloat () but no positive results.

It is useless posting a screenshot showing only half the line length. To post code please copy/paste it and use the </> button at the top of the forum entry window when pasting it in.
Do you mean you don't know how to convert data values to numbers? If so then something like

let splitValue = whatever.split(",")
blabla = Number(splitValue[0] + "." + splitValue[1]) 

For the date you should be able to feed it directly into newDate(theDateString). The graph will accept Date objects I think in the structure. If not the use toTime() to convert to milliseconds.
For converting the arrays of values and numbers look at the Array.map() function rather than iterating through the array.

Please excuse me. Here is the code in question.

var msg1={};
var msg2={};

p=msg.payload;
node.log(typeof p);
msg1.payload=p.data["FTI-018"][0].timestamp[0].timestamp;
msg1.topic="Timestamp";
msg2.payload = p.data["FTI-018"][0].values[0].value;
msg2.topic = "Value";

//return msg2;
//return [msg1,msg2];
//var data = [];
//data.push({"x": p.data["FTI-018"][0].timestamp[0].timestamp, "y" : (p.data["FTI-018"][0].values[0].value)});
//msg.payload = {label: "label", data, series: "X"};
//return msg;

//msg.payload = [];
//msg.payload.push(msg1.payload);
//msg.payload.push(msg2.payload);
//return msg;

var m={};
m.labels = [msg1.payload];
m.series = ['Series 1'];
m.data = [msg2.payload];
//m.data = msg2.payload;
return {payload:[m]};

My previous post should help with converting the values, but you seem to have misinterpreted the information in the link I posted. For filling the chart with information from a set of data you need to construct it as described in the section Stored Data.