Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions sym-files2/databasebackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'
Expand All @@ -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)
Expand All @@ -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]
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion sym-files2/export_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 += ['', '']
Expand Down
4 changes: 4 additions & 0 deletions sym-files2/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
29 changes: 22 additions & 7 deletions sym-files2/xyplot.php
Original file line number Diff line number Diff line change
Expand Up @@ -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" : "";
Expand Down Expand Up @@ -237,17 +237,32 @@ function microtime_float()
} else {
$show_plot_options = "display:none";
}
?>
<span id="plot_options" style="<?php echo($show_plot_options);?>">
<hr>
<?php
// Check for specific settings defined in graphsettings.xml and print if defined
?>
<span id="plot_options" style="<?php echo($show_plot_options);?>">
<hr>
<?php
// Check for specific settings defined in graphsettings.xml and print if defined
if(in_array("flip_x",array_keys($settings)) == "1"){
echo($settings["flip_x"]["gui"] . "<input type=\"checkbox\" name=\"flip_x\" value=\"checked\"" . $flip_x . "><br>");
}

if(in_array("as_function_of",array_keys($settings)) == "1"){
echo($settings["as_function_of"]["gui"] . "<input type=\"checkbox\" name=\"as_function_of\" value=\"checked\"" . $as_function_of . "><br>");
$checked = "";
if ($as_function_of == 'default'){
$checked = "checked";
}
echo($settings["as_function_of"]["gui"] . "<input type=\"checkbox\" name=\"as_function_of\" value=\"default\"" . $checked . "><br>");
}
foreach ($settings["as_function_of"] as $key => $value){
if (is_array($value)){
$checked = "";
if ($as_function_of == $key){
$checked = "checked";
}
echo($value["gui"] . "<input type=\"checkbox\" name=\"as_function_of\" value=\"" . $key . "\"" . $checked . "><br>");
}
}

if(in_array("diff_left_y",array_keys($settings)) == "1"){
echo($settings["diff_left_y"]["gui"] . "<input type=\"checkbox\" title=\"Assumes equidistant x-spacing!\" name=\"diff_left_y\" value=\"checked\"" . $diff_left_y . "><br>");
}
Expand Down