earthcubeprojects-chords / chords

EarthCube CHORDS application code
GNU General Public License v2.0
25 stars 13 forks source link

Live plot is blank on initial open #597

Open MisterMartin opened 1 year ago

MisterMartin commented 1 year ago

For some instruments, the live plot starts out with now data. If you active the live update and wait a little while, it will eventually populate.

This behavior appeared in 1.1.0-rc3. But the live plot was completely broken before that.

See the 3d PAWS portal. Instrument id's 1 & 3 behave properly, but instruments ids 4 & 5 demonstrate this behavior.

mdye commented 1 year ago

I tracked down one of the problems, and have created a branch to fix the issue: highcharts-fix-597

One of the variable names contained a tab at the end of it's name ("MCP Temperature 1 "). When out dynamically created code tried to turn this in to JSON for the highcharts label it broke (JSON required tabs -among other things - the be escaped). The fix is to trim whitespace from the beginning and end of the variable names while generating the JSON.

This gets the plot to load, but there is still an error preventing the live updating. I'm working on that next.

mdye commented 1 year ago

I was able to fix another bug, also on the highcharts-fix-597 branch.

In generating the graph, data for multiple variables are returned simultaneously. When there were data for one variable but not another there was not a check to make sure the (multidimensional) array was not empty before attempting to access sub-elements of that array.

E.g.live_last_times[series_index] = points[points.length - 1][0];

The fix is the verify that the array contains at least one element before accessing it: if (points.length > 0) { live_last_times[series_index] = points[points.length - 1][0]; }