Hello guys,
in my current little hobby project I'm (amongst other astronomical things) visualising the day length for certain locations. Here's how the chart currently looks like:
Now I want the daylight hours – a decimal number that comes from my API – in the tooltip to be displayed in an hh:mm:ss format instead of the pure floating point number.
Here's the function node's code that sits directly in front of the chart node (sorry for the German comments
):
const apiResponses = msg.payload;
const flatPayload = [];
apiResponses.forEach(response => {
response.curve_data.forEach(pt => {
// Präzise Umrechnung in Sekunden für hh:mm:ss
const totalSeconds = Math.round(pt.daylight_hours * 3600);
const h = Math.floor(totalSeconds / 3600);
const m = Math.floor((totalSeconds % 3600) / 60);
const s = totalSeconds % 60;
// Formatierung nach ISO (24h)
const timeStr = [h, m, s]
.map(v => v.toString().padStart(2, '0'))
.join(':');
flatPayload.push({
series: response.location,
x: new Date(pt.date + "T12:00:00Z").getTime(),
y: pt.daylight_hours,
// Wir parken den Zeit-String im 'name' Attribut für den Tooltip {b}
name: timeStr
});
});
});
msg.payload = flatPayload;
msg.ui_update = {
chartOptions: {
tooltip: {
show: true,
trigger: 'axis',
formatter: '< now what here??? >',
valueFormatter: '< or is it this one? how? >'
}
}
};
// Ausgang 1: Chart | Ausgang 2: Spinner-Template (auf false setzen)
return [msg, { payload: false }];
So, you see, I already did the building of the string I want to see but I just don't know how to put it into the value region of the tooltip window. ![]()
The 2nd output of the function node just triggers the visibility of a spinner so that during the HTTP requests that actually get the data from the API the user sees that something is happening.
Here's a screenshot of a debug node's output that shows the data right after the function node:
We see that the duration formatting (key name) actually works.
But how can I replace the decimal duration in the tooltip with this string now?
In case it's important: The chart node is configured like this:
Thanks so much in advance!! ![]()
Stefan.


