diff --git a/sym-files2/databasebackend.py b/sym-files2/databasebackend.py index c312bd1..ace6575 100755 --- a/sym-files2/databasebackend.py +++ b/sym-files2/databasebackend.py @@ -347,6 +347,16 @@ def _plugin_single(self, name, settings, sys, plugins): return outstr def _as_function_of(self): + # If several as_function_of's are defined, func_type will tell which one + # - in the legacy case of only one, func type will just be the default + # value and not match a key - root key is (which is the only one in + # the classic case) is then used + func_type = self.o['as_function_of'] + if func_type in self.ggs['as_function_of']: + settings = self.ggs['as_function_of'][func_type] + else: + settings = self.ggs['as_function_of'] + # Get the datetime of the measurement for dat in self.data['left'] + self.data['right']: query = ('SELECT {0} FROM {1} where id = {2}' @@ -358,7 +368,7 @@ def _as_function_of(self): # Fetch all sets of id and label that is from the same time query = ('SELECT id, {0} FROM {1} WHERE TIME = \"{2}\"' - ''.format(self.ggs['as_function_of']['column'], + ''.format(settings['column'], self.ggs['measurements_table'], timestamp.strftime("%Y-%m-%d %H:%M:%S"))) measurements = self._result_from_query(query) @@ -367,8 +377,7 @@ def _as_function_of(self): # e.g.: "temperature" new_x_id = None for measurement in measurements: - search = re.search(self.ggs['as_function_of']['reg_match'], - measurement[1]) + search = re.search(settings['reg_match'], measurement[1]) try: if len(search.group(0)) > 0: new_x_id = measurement[0] @@ -379,7 +388,7 @@ def _as_function_of(self): if new_x_id: # Change the x-axis label self.data['data_treatment']['xlabel'] =\ - self.ggs['as_function_of']['xlabel'] + settings['xlabel'] # Fetch the pertaining temperature data new_x = self.__get_data_xyplot_single(new_x_id) """ Assumes both dat and new_x contains a common diff --git a/sym-files2/export_data.py b/sym-files2/export_data.py index 765d866..72c930c 100755 --- a/sym-files2/export_data.py +++ b/sym-files2/export_data.py @@ -59,6 +59,10 @@ def __init__(self): for pair in options.boolean_options.split(',')[1:]: key, value = pair.split(':') self.o[key] = True if value == 'checked' else False + if key == 'as_function_of': + if value: + self.o['as_function_of'] = value + # Parse bounds bkeys = [s + '_bounding' for s in ['xscale', 'left_yscale', 'right_yscale']] for bound in bkeys: @@ -168,7 +172,7 @@ def _print_out_header_xy_data(self, data): for n, d in enumerate(data['left'] + data['right']): # Only make output if the current warning key is present in the # current datasets graphsettings - if d['lgs'].has_key(warning): + if warning in d['lgs']: out += ['"' + warning + '"', '"' + d['lgs'][warning] + '"'] else: out += ['', ''] diff --git a/sym-files2/plot.py b/sym-files2/plot.py index 017ede3..9cc450f 100755 --- a/sym-files2/plot.py +++ b/sym-files2/plot.py @@ -85,6 +85,10 @@ def __init__(self): for pair in options.boolean_options.split(',')[1:]: key, value = pair.split(':') self.o[key] = True if value == 'checked' else False + if key == 'as_function_of': + if value: + self.o['as_function_of'] = value + # Parse bounds bkeys = [s + '_bounding' for s in ['xscale', 'left_yscale', 'right_yscale']] for bound in bkeys: diff --git a/sym-files2/xyplot.php b/sym-files2/xyplot.php index f990799..f6c2b1d 100755 --- a/sym-files2/xyplot.php +++ b/sym-files2/xyplot.php @@ -53,7 +53,7 @@ $matplotlib = isset($_GET["matplotlib"]) ? "checked" : ""; $plot_options = isset($_GET["plot_options"]) ? "checked" : ""; $flip_x = isset($_GET["flip_x"]) ? "checked" : ""; -$as_function_of = isset($_GET["as_function_of"]) ? "checked" : ""; +$as_function_of = isset($_GET["as_function_of"]) ? $_GET["as_function_of"] : ""; $diff_left_y = isset($_GET["diff_left_y"]) ? "checked" : ""; $diff_right_y = isset($_GET["diff_right_y"]) ? "checked" : ""; $linscale_x0 = isset($_GET["linscale_x0"]) ? "checked" : ""; @@ -237,17 +237,32 @@ function microtime_float() } else { $show_plot_options = "display:none"; } - ?> - -
- + +
+
"); } + if(in_array("as_function_of",array_keys($settings)) == "1"){ - echo($settings["as_function_of"]["gui"] . "
"); + $checked = ""; + if ($as_function_of == 'default'){ + $checked = "checked"; + } + echo($settings["as_function_of"]["gui"] . "
"); } + foreach ($settings["as_function_of"] as $key => $value){ + if (is_array($value)){ + $checked = ""; + if ($as_function_of == $key){ + $checked = "checked"; + } + echo($value["gui"] . "
"); + } + } + if(in_array("diff_left_y",array_keys($settings)) == "1"){ echo($settings["diff_left_y"]["gui"] . "
"); }