From 9a9641a02436eef00e80c41fad1557efec34bd82 Mon Sep 17 00:00:00 2001 From: l_samenv Date: Tue, 27 Aug 2024 15:58:43 +0200 Subject: [PATCH] Added NaN repr field in export popup --- client/components/export_popup/export_popup.js | 9 ++++++++- client/jsFiles/SEAWebClientGraphics.js | 4 ++-- influxgraph.py | 5 +++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/client/components/export_popup/export_popup.js b/client/components/export_popup/export_popup.js index 244002f..b7b1dbb 100644 --- a/client/components/export_popup/export_popup.js +++ b/client/components/export_popup/export_popup.js @@ -104,6 +104,8 @@ class ExportPopup extends HTMLElement{ return } + let nanRepresentation = this.getElementsByClassName("nan-input")[0].value; + let binningCheckbox = this.getElementsByClassName("binning-checkbox")[0]; let binningValue = null; if(binningCheckbox.checked){ @@ -123,7 +125,7 @@ class ExportPopup extends HTMLElement{ else { this.hide(); - this.exportCallback(selectedVariables, startDateTimeMs, endDateTimeMs, binningValue); + this.exportCallback(selectedVariables, startDateTimeMs, endDateTimeMs, nanRepresentation, binningValue); } } @@ -171,6 +173,11 @@ class ExportPopup extends HTMLElement{ + +
+ NaN value : + +
diff --git a/client/jsFiles/SEAWebClientGraphics.js b/client/jsFiles/SEAWebClientGraphics.js index 36429d6..6fc2793 100644 --- a/client/jsFiles/SEAWebClientGraphics.js +++ b/client/jsFiles/SEAWebClientGraphics.js @@ -284,12 +284,12 @@ function loadExportPopup(){ graphsContainer.appendChild(exportPopup); } -function exportCallback(selectedVariables, startDateTimeMs, endDateTimeMs, binning=null){ +function exportCallback(selectedVariables, startDateTimeMs, endDateTimeMs, nan, binning=null){ let binningParam = "None"; if (binning !== null) binningParam = binning - let exportURL = "http://" + hostPort + "/export?time=" + startDateTimeMs/1000 + "," + endDateTimeMs/1000 + "&variables=" + selectedVariables + "&interval=" + binningParam + "&id=" + clientID + let exportURL = "http://" + hostPort + "/export?time=" + startDateTimeMs/1000 + "," + endDateTimeMs/1000 + "&variables=" + selectedVariables + "&nan=" + nan + "&interval=" + binningParam + "&id=" + clientID let a = document.createElement('a'); a.href = exportURL a.click() diff --git a/influxgraph.py b/influxgraph.py index 04745f3..8ac23db 100644 --- a/influxgraph.py +++ b/influxgraph.py @@ -163,7 +163,7 @@ class InfluxGraph: self.livemode = self.LIVE return dict(type='accept-graph', live=True) - def w_export(self, variables, time, interval): + def w_export(self, variables, time, nan, interval): """ Returns the bytes of a dataframe with the curves given by variables in the time range "time" Called when the route /export is reached. @@ -171,6 +171,7 @@ class InfluxGraph: Parameters : variables (str) : a comma separataed value string of variable names (influx names) to retrieve time (str) : a commma separated value string (range) of seconds. + nan (str) : the representation for NaN values in the TSV interval (str) : the interval (resolution) of the values to get (string in seconds) Returns : @@ -187,7 +188,7 @@ class InfluxGraph: df = self.influx_data_getter.get_curves_data_frame(queried_variables, [start, end], interval) mem = io.BytesIO() - df.to_csv(mem, sep="\t", index=False, float_format="%.15g") + df.to_csv(mem, sep="\t", index=False, float_format="%.15g", na_rep=nan) mem.seek(0) return mem