Skip to content

Commit

Permalink
Merge branch 'Custom-Graph-Setup'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Keeble committed Apr 18, 2016
2 parents 220d887 + 4fe86f9 commit 9fecd43
Show file tree
Hide file tree
Showing 3 changed files with 439 additions and 2 deletions.
55 changes: 55 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,65 @@ html.has-log .log-graph-config {
.config-graph-field select {
margin-right:4px;
}

.config-graph-field input[name=smoothing] {
margin-right:4px;
max-width: 75px;
}
.config-graph-field input[name=power] {
margin-right:4px;
max-width: 65px;
}
.config-graph-field input[name=scale] {
margin-right:4px;
max-width: 65px;
}

.config-graph h4 button {
margin-left:0.5em;
}

.config-graph table tr{
margin:0.5em 0;
width: 100%;
line-height: 10px;
}

.config-graph th[name=field] {
margin-right:4px;
width: 265px;
}

.config-graph th[name=smoothing] {
margin-right:4px;
width: 75px;
text-align: center;
}

.config-graph th[name=expo] {
margin-right:4px;
width: 65px;
text-align: center;
}

.config-graph th[name=zoom] {
margin-right:4px;
width: 65px;
text-align: center;
}


.setup-parameters {
margin:0.5em 0;
}

.setup-parameters dd {
margin-top:0.5em;
}

.setup-parameter {
margin:0.5em 0;
}

#graphCanvas {
position:absolute;
Expand Down
35 changes: 33 additions & 2 deletions js/graph_config_dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ function GraphConfigurationDialog(dialog, onSave) {
elem = $(
'<li class="config-graph-field">'
+ '<select class="form-control"><option value="">(choose a field)</option></select>'
+ '<input name="smoothing" class="form-control" type="text"></input>'
+ '<input name="power" class="form-control" type="text"></input>'
+ '<input name="scale" class="form-control" type="text"></input>'
+ '<button type="button" class="btn btn-default btn-sm">Remove</button>'
+ '</li>'
),
Expand All @@ -40,6 +43,17 @@ function GraphConfigurationDialog(dialog, onSave) {
select.append(renderFieldOption(offeredFieldNames[i], selectedFieldName));
}

// the smoothing is in uS rather than %, scale the value somewhere between 0 and 10000uS
$('input[name=smoothing]',elem).val((field.smoothing!=null)?(field.smoothing/100)+'%':'30%');
if(field.curve!=null) {
$('input[name=power]',elem).val((field.curve.power!=null)?(field.curve.power*100)+'%':'100%');
$('input[name=scale]',elem).val((field.curve.outputRange!=null)?(field.curve.outputRange*100)+'%':'100%');
} else
{
$('input[name=power]',elem).val('100%');
$('input[name=scale]',elem).val('100%');
}

return elem;
}

Expand All @@ -57,6 +71,18 @@ function GraphConfigurationDialog(dialog, onSave) {
+ '<input class="form-control" type="text" placeholder="Axis label">'
+ '</div>'
+ '</div>'
+ '<div class="form-group form-group-sm">'
+ '<div class="col-sm-10">'
+ '<table>'
+ '<tr>'
+ '<th name="field"></th>'
+ '<th name="smoothing">Smooth</th>'
+ '<th name="expo">Expo</th>'
+ '<th name="zoom">Zoom</th>'
+ '</tr>'
+ '</table>'
+ '</div>'
+ '</div>'
+ '<div class="form-group form-group-sm">'
+ '<label class="col-sm-2 control-label">Fields</label>'
+ '<div class="col-sm-10">'
Expand Down Expand Up @@ -162,8 +188,13 @@ function GraphConfigurationDialog(dialog, onSave) {

$(".config-graph-field", this).each(function() {
field = {
name: $("select", this).val()
};
name: $("select", this).val(),
smoothing: parseInt($("input[name=smoothing]", this).val())*100, // Value 0-100% = 0-10000uS (higher values are more smooth, 30% is typical)
curve: {
power: parseInt($("input[name=power]", this).val())/100.0, // Value 0-100% = 0-1.0 (lower values exagerate center values - expo)
outputRange: parseInt($("input[name=scale]", this).val())/100.0 // Value 0-100% = 0-1.0 (higher values > 100% zoom in graph vertically)
}
}

if (field.name.length > 0) {
graph.fields.push(field);
Expand Down
Loading

0 comments on commit 9fecd43

Please sign in to comment.