diff --git a/src/graph_config.js b/src/graph_config.js
index 8e990f4e..fd57108c 100644
--- a/src/graph_config.js
+++ b/src/graph_config.js
@@ -3,14 +3,13 @@ import { DSHOT_MIN_VALUE, DSHOT_RANGE, RATES_TYPE, DEBUG_MODE } from "./flightlo
import { escapeRegExp } from "./tools";
export function GraphConfig(graphConfig) {
- var
- graphs = graphConfig ? graphConfig : [],
- listeners = [],
- that = this;
+ const listeners = [];
+ const that = this;
+ let graphs = graphConfig ?? [];
function notifyListeners() {
- for (var i = 0; i < listeners.length; i++) {
- listeners[i](that);
+ for (const listener of listeners) {
+ listener(that);
}
}
@@ -44,20 +43,58 @@ export function GraphConfig(graphConfig) {
}
};
+ this.extendFields = function(flightLog, field) {
+ const matches = field.name.match(/^(.+)\[all\]$/);
+ const logFieldNames = flightLog.getMainFieldNames();
+ const fields = [];
+ if (matches) {
+ const
+ nameRoot = matches[1],
+ nameRegex = new RegExp("^" + escapeRegExp(nameRoot) + "\[[0-9]+\]$");
+
+ for (const fieldName of logFieldNames) {
+ if (fieldName.match(nameRegex)) {
+ // forceNewCurve must be true for min max computing extended curves.
+ const forceNewCurve = true;
+ field.color = undefined;
+ fields.push(adaptField(flightLog, $.extend({}, field, {curve: $.extend({}, field.curve), name: fieldName, friendlyName: FlightLogFieldPresenter.fieldNameToFriendly(fieldName, flightLog.getSysConfig().debug_mode)}), forceNewCurve));
+ }
+ }
+ } else {
+ // Don't add fields if they don't exist in this log
+ if (flightLog.getMainFieldIndexByName(field.name) !== undefined) {
+ fields.push(adaptField(flightLog, $.extend({}, field, {curve: $.extend({}, field.curve), friendlyName: FlightLogFieldPresenter.fieldNameToFriendly(field.name, flightLog.getSysConfig().debug_mode)})));
+ }
+ }
+ return fields;
+ };
+
+ let adaptField = function(flightLog, field, forceNewCurve) {
+ const defaultCurve = GraphConfig.getDefaultCurveForField(flightLog, field.name);
+ if (field.curve === undefined || forceNewCurve) {
+ field.curve = defaultCurve;
+ } else {
+ if (field.curve.MinMax == undefined)
+ field.curve.MinMax = defaultCurve.MinMax;
+ }
+
+ if (field.smoothing === undefined) {
+ field.smoothing = GraphConfig.getDefaultSmoothingForField(flightLog, field.name);
+ }
+
+ return field;
+ };
+
/**
* Convert the given graph configs to make them appropriate for the given flight log.
*/
- this.adaptGraphs = function(flightLog, graphs, isNewLog) {
- var
- logFieldNames = flightLog.getMainFieldNames(),
-
+ this.adaptGraphs = function(flightLog, graphs) {
+ const
// Make copies of graphs into here so we can modify them without wrecking caller's copy
newGraphs = [];
- for (var i = 0; i < graphs.length; i++) {
- var
- graph = graphs[i],
- newGraph = $.extend(
+ for (const graph of graphs) {
+ const newGraph = $.extend(
// Default values for missing properties:
{
height: 1,
@@ -68,66 +105,11 @@ export function GraphConfig(graphConfig) {
{
fields:[],
},
- ),
- colorIndex = 0;
-
- for (var j = 0; j < graph.fields.length; j++) {
- var
- field = graph.fields[j],
- matches;
-
- var adaptField = function(field, colorIndexOffset, forceNewCurve) {
- const defaultCurve = GraphConfig.getDefaultCurveForField(flightLog, field.name);
-
- if (field.curve === undefined || forceNewCurve) {
- field.curve = defaultCurve;
- }
- else {
- if (field.curve.MinMax == undefined)
- field.curve.MinMax = defaultCurve.MinMax;
- }
-
- if(colorIndexOffset!=null && field.color != undefined) { // auto offset the actual color (to expand [all] selections)
- var index;
- for(index=0; index < GraphConfig.PALETTE.length; index++)
- {
- if(GraphConfig.PALETTE[index].color == field.color) break;
- }
- field.color = GraphConfig.PALETTE[(index + colorIndexOffset) % GraphConfig.PALETTE.length].color
- }
-
- if (field.color === undefined) {
- field.color = GraphConfig.PALETTE[colorIndex % GraphConfig.PALETTE.length].color;
- colorIndex++;
- }
-
- if (field.smoothing === undefined) {
- field.smoothing = GraphConfig.getDefaultSmoothingForField(flightLog, field.name);
- }
-
- return field;
- };
+ );
- if ((matches = field.name.match(/^(.+)\[all\]$/))) {
- var
- nameRoot = matches[1],
- nameRegex = new RegExp("^" + escapeRegExp(nameRoot) + "\[[0-9]+\]$"),
- colorIndexOffset = 0;
-
- for (var k = 0; k < logFieldNames.length; k++) {
- if (logFieldNames[k].match(nameRegex)) {
- // forceNewCurve must be true for min max computing extended curves.
- let forceNewCurve = true;
- newGraph.fields.push(adaptField($.extend({}, field, {curve: $.extend({}, field.curve), name: logFieldNames[k], friendlyName: FlightLogFieldPresenter.fieldNameToFriendly(logFieldNames[k], flightLog.getSysConfig().debug_mode)}), colorIndexOffset, forceNewCurve));
- colorIndexOffset++;
- }
- }
- } else {
- // Don't add fields if they don't exist in this log
- if (flightLog.getMainFieldIndexByName(field.name) !== undefined) {
- newGraph.fields.push(adaptField($.extend({}, field, {curve: $.extend({}, field.curve), friendlyName: FlightLogFieldPresenter.fieldNameToFriendly(field.name, flightLog.getSysConfig().debug_mode)})));
- }
- }
+ for (const field of graph.fields) {
+ const fields = this.extendFields(flightLog, field);
+ newGraph.fields = newGraph.fields.concat(fields);
}
newGraphs.push(newGraph);
@@ -173,15 +155,10 @@ GraphConfig.PALETTE = [
GraphConfig.load = function(config) {
// Upgrade legacy configs to suit the newer standard by translating field names
if (config) {
- for (var i = 0; i < config.length; i++) {
- var graph = config[i];
-
- for (var j = 0; j < graph.fields.length; j++) {
- var
- field = graph.fields[j],
- matches;
-
- if ((matches = field.name.match(/^gyroData(.+)$/))) {
+ for (const graph of config) {
+ for (const field of graph.fields) {
+ const matches = field.name.match(/^gyroData(.+)$/);
+ if (matches) {
field.name = "gyroADC" + matches[1];
}
}
@@ -214,10 +191,10 @@ GraphConfig.load = function(config) {
};
GraphConfig.getDefaultCurveForField = function(flightLog, fieldName) {
- var
+ const
sysConfig = flightLog.getSysConfig();
- var maxDegreesSecond = function(scale) {
+ let maxDegreesSecond = function(scale) {
switch(sysConfig["rates_type"]){
case RATES_TYPE.indexOf('ACTUAL'):
case RATES_TYPE.indexOf('QUICK'):
@@ -231,14 +208,14 @@ GraphConfig.load = function(config) {
}
}
- var getMinMaxForFields = function(/* fieldName1, fieldName2, ... */) {
+ let getMinMaxForFields = function(/* fieldName1, fieldName2, ... */) {
// helper to make a curve scale based on the combined min/max of one or more fields
let
min = Number.MAX_VALUE,
max = -Number.MAX_VALUE;
- for(let i in arguments) {
- const mm = flightLog.getMinMaxForFieldDuringAllTime(arguments[i]);
+ for(const argument of arguments) {
+ const mm = flightLog.getMinMaxForFieldDuringAllTime(argument);
min = Math.min(mm.min, min);
max = Math.max(mm.max, max);
}
@@ -250,7 +227,7 @@ GraphConfig.load = function(config) {
return {min:-500, max:500};
}
- var getCurveForMinMaxFields = function(/* fieldName1, fieldName2, ... */) {
+ let getCurveForMinMaxFields = function(/* fieldName1, fieldName2, ... */) {
const mm = getMinMaxForFields.apply(null, arguments);
// added convertation min max values from log file units to friendly chart
const mmChartUnits =
@@ -264,10 +241,10 @@ GraphConfig.load = function(config) {
};
}
- var getCurveForMinMaxFieldsZeroOffset = function(/* fieldName1, fieldName2, ... */) {
+ let getCurveForMinMaxFieldsZeroOffset = function(/* fieldName1, fieldName2, ... */) {
const mm = getMinMaxForFields.apply(null, arguments);
// added convertation min max values from log file units to friendly chart
- let mmChartUnits =
+ const mmChartUnits =
{
min: FlightLogFieldPresenter.ConvertFieldValue(flightLog, fieldName, true, mm.min),
max: FlightLogFieldPresenter.ConvertFieldValue(flightLog, fieldName, true, mm.max)
@@ -417,7 +394,7 @@ GraphConfig.load = function(config) {
};
} else if (fieldName.match(/^debug.*/) && sysConfig.debug_mode!=null) {
- var debugModeName = DEBUG_MODE[sysConfig.debug_mode];
+ const debugModeName = DEBUG_MODE[sysConfig.debug_mode];
switch (debugModeName) {
case 'CYCLETIME':
switch (fieldName) {
@@ -558,7 +535,7 @@ GraphConfig.load = function(config) {
max: 50
}
};
- case 'debug[3]': // Vario
+ case 'debug[3]': // vario
return {
power: 1.0,
MinMax: {
@@ -1282,7 +1259,7 @@ GraphConfig.load = function(config) {
const minTime = WindowCenterTime - WindowWidthTime/2;
const maxTime = WindowCenterTime + WindowWidthTime/2;
- let mm = flightLog.getMinMaxForFieldDuringTimeInterval(fieldName, minTime, maxTime);
+ const mm = flightLog.getMinMaxForFieldDuringTimeInterval(fieldName, minTime, maxTime);
if (mm == undefined)
return {
min: -500,
@@ -1309,7 +1286,7 @@ GraphConfig.load = function(config) {
if (maxTime == false)
maxTime = flightLog.getMaxTime();
- let mm = flightLog.getMinMaxForFieldDuringTimeInterval(fieldName, minTime, maxTime);
+ const mm = flightLog.getMinMaxForFieldDuringTimeInterval(fieldName, minTime, maxTime);
if (mm == undefined)
return {
min: -500,
@@ -1326,7 +1303,7 @@ GraphConfig.load = function(config) {
* @param fieldName Name of the field
*/
GraphConfig.getMinMaxForFieldDuringAllTime = function(flightLog, fieldName) {
- let mm = flightLog.getMinMaxForFieldDuringAllTime(fieldName);
+ const mm = flightLog.getMinMaxForFieldDuringAllTime(fieldName);
if (mm.min == Number.MAX_VALUE || mm.max == -Number.MAX_VALUE) {
return {
min: -500,
@@ -1345,10 +1322,7 @@ GraphConfig.load = function(config) {
* Supply an array of strings `graphNames` to only fetch the graph with the given names.
*/
GraphConfig.getExampleGraphConfigs = function(flightLog, graphNames) {
- var
- result = [],
- i, j;
-
+ const result = [];
const EXAMPLE_GRAPHS = [];
if (!flightLog.isFieldDisabled().MOTORS) {
@@ -1396,20 +1370,19 @@ GraphConfig.load = function(config) {
EXAMPLE_GRAPHS.push({label: "GPS",fields: ["GPS_numSat", "GPS_altitude", "GPS_speed", "GPS_ground_course", "GPS_coord[all]"]});
}
- for (i = 0; i < EXAMPLE_GRAPHS.length; i++) {
- var
- srcGraph = EXAMPLE_GRAPHS[i],
+ for (const srcGraph of EXAMPLE_GRAPHS) {
+ const
destGraph = {
label: srcGraph.label,
fields: [],
height: srcGraph.height || 1
- },
- found;
+ };
+ let found;
if (graphNames !== undefined) {
found = false;
- for (j = 0; j < graphNames.length; j++) {
- if (srcGraph.label == graphNames[j]) {
+ for (const name of graphNames) {
+ if (srcGraph.label == name) {
found = true;
break;
}
@@ -1420,10 +1393,8 @@ GraphConfig.load = function(config) {
}
}
- for (j = 0; j < srcGraph.fields.length; j++) {
- var
- srcFieldName = srcGraph.fields[j],
- destField = {
+ for (const srcFieldName of srcGraph.fields) {
+ const destField = {
name: srcFieldName
};
diff --git a/src/graph_config_dialog.js b/src/graph_config_dialog.js
index 5675fb6c..eb5395a9 100644
--- a/src/graph_config_dialog.js
+++ b/src/graph_config_dialog.js
@@ -13,16 +13,17 @@ export function GraphConfigurationDialog(dialog, onSave) {
activeFlightLog,
logGrapher = null,
prevCfg = null,
+ activeGraphConfig = null,
cfgMustBeRestored = false;
function chooseColor(currentSelection) {
const selectColor = $('');
- for(let i=0; i')
.text(GraphConfig.PALETTE[i].name)
.attr('value', GraphConfig.PALETTE[i].color)
.css('color', GraphConfig.PALETTE[i].color);
- if(currentSelection == GraphConfig.PALETTE[i].color) {
+ if (currentSelection == GraphConfig.PALETTE[i].color) {
option.attr('selected', 'selected');
selectColor.css('background', GraphConfig.PALETTE[i].color)
.css('color', GraphConfig.PALETTE[i].color);
@@ -37,11 +38,11 @@ export function GraphConfigurationDialog(dialog, onSave) {
const MAX_HEIGHT = 5;
const selectHeight = $('');
- for(let i=1; i<=MAX_HEIGHT; i++) {
+ for(let i = 1; i <= MAX_HEIGHT; i++) {
const option = $('')
.text(i)
.attr('value', i);
- if(currentSelection == i || (currentSelection==null && i==1)) {
+ if (currentSelection == i || (currentSelection==null && i==1)) {
option.attr('selected', 'selected');
}
selectHeight.append(option);
@@ -52,7 +53,7 @@ export function GraphConfigurationDialog(dialog, onSave) {
// Show/Hide remove all button
function updateRemoveAllButton() {
- var graphCount = $('.config-graph').length;
+ const graphCount = $('.config-graph').length;
if (graphCount > 0) {
$('.config-graphs-remove-all-graphs').show();
@@ -64,16 +65,16 @@ export function GraphConfigurationDialog(dialog, onSave) {
// Renumber the "Graph X" blocks after additions/deletions
function renumberGraphIndexes() {
- var graphIndexes = $('.graph-index-number');
- var graphCount = graphIndexes.length;
- for (var i = 0; i < graphCount; i++) {
- var currentGraphNumber = i+1;
- $(graphIndexes[i]).html(currentGraphNumber);
- }
- }
+ const graphIndexes = $('.graph-index-number');
+ const graphCount = graphIndexes.length;
+ for (let i = 0; i < graphCount; i++) {
+ let currentGraphNumber = i+1;
+ $(graphIndexes[i]).html(currentGraphNumber);
+ }
+ }
function renderFieldOption(fieldName, selectedName) {
- var
+ const
option = $("")
.text(FlightLogFieldPresenter.fieldNameToFriendly(fieldName, activeFlightLog.getSysConfig().debug_mode))
.attr("value", fieldName);
@@ -87,7 +88,7 @@ export function GraphConfigurationDialog(dialog, onSave) {
// Set the current smoothing options for a field
function renderSmoothingOptions(elem, flightLog, field) {
- if(elem) {
+ if (elem) {
// 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).toFixed(0)+'%':(GraphConfig.getDefaultSmoothingForField(flightLog, field.name)/100)+'%');
if (field.curve != null) {
@@ -114,7 +115,7 @@ export function GraphConfigurationDialog(dialog, onSave) {
* initial selection.
*/
function renderField(flightLog, field, color) {
- var
+ const
elem = $(
''
+ ' | '
@@ -128,18 +129,17 @@ export function GraphConfigurationDialog(dialog, onSave) {
+ '
'
),
select = $('select.form-control', elem),
- selectedFieldName = field ?field.name : false,
- i;
+ selectedFieldName = field ? field.name : false;
- for (i = 0; i < offeredFieldNames.length; i++) {
- select.append(renderFieldOption(offeredFieldNames[i], selectedFieldName));
+ for (const field of offeredFieldNames) {
+ select.append(renderFieldOption(field, selectedFieldName));
}
// Set the smoothing values
renderSmoothingOptions(elem, flightLog, field);
// Set the line width values
- $('input[name=linewidth]',elem).val((field.lineWidth)?field.lineWidth:1);
+ $('input[name=linewidth]',elem).val((field.lineWidth) ? field.lineWidth : 1);
//Populate the Color Picker
$('select.color-picker', elem).replaceWith(chooseColor(color));
@@ -147,10 +147,28 @@ export function GraphConfigurationDialog(dialog, onSave) {
// Add event when selection changed to retrieve the current smoothing settings.
$('select.form-control', elem).change( function() {
- var selectedField = {
+ const selectedField = {
name: $('select.form-control option:selected', elem).val()
- };
- renderSmoothingOptions(elem, activeFlightLog, selectedField);
+ };
+ const fields = activeGraphConfig.extendFields(activeFlightLog, selectedField);
+ if (fields.length === 1) {
+ renderSmoothingOptions(elem, activeFlightLog, fields[0]);
+ } else {
+ let colorIndex = $('select.color-picker', elem).prop('selectedIndex');
+ for (let i = 0; i < fields.length - 1; i++) {
+ const color = GraphConfig.PALETTE[colorIndex++ % GraphConfig.PALETTE.length].color;
+ const row = renderField(flightLog, fields[i], color) ;
+ elem.before(row);
+ }
+
+ const index = $('select.form-control', elem).prop('selectedIndex');
+ $('select.form-control', elem).prop('selectedIndex', index + fields.length);
+ $('select.form-control', elem).trigger('change');
+
+ const colorPicker = $('select.color-picker', elem);
+ colorPicker.prop('selectedIndex', colorIndex % GraphConfig.PALETTE.length);
+ colorPicker.trigger('change');
+ }
RefreshCharts();
});
@@ -194,7 +212,7 @@ export function GraphConfigurationDialog(dialog, onSave) {
}
function renderGraph(flightLog, index, graph) {
- var
+ const
graphElem = $(
''
+ ''
@@ -252,17 +270,17 @@ export function GraphConfigurationDialog(dialog, onSave) {
$("input", graphElem).val(graph.label);
- var fieldCount = graph.fields.length;
-
// "Add field" button
$(".add-field-button", graphElem).click(function(e) {
- fieldList.append(renderField(flightLog, {}, GraphConfig.PALETTE[fieldCount++].color));
+ const colorIndex = $("tbody", graphElem)[0].childElementCount;
+ const color = GraphConfig.PALETTE[colorIndex % GraphConfig.PALETTE.length].color;
+ fieldList.append(renderField(flightLog, {}, color));
e.preventDefault();
});
// "Remove Graph" button
$(".remove-single-graph-button", graphElem).click(function(e) {
- var parentGraph = $(this).parents('.config-graph');
+ const parentGraph = $(this).parents('.config-graph');
parentGraph.remove();
updateRemoveAllButton();
RefreshCharts();
@@ -273,17 +291,18 @@ export function GraphConfigurationDialog(dialog, onSave) {
$('select.graph-height', graphElem).replaceWith(chooseHeight(graph.height?(graph.height):1));
// Add Field List
- for (var i = 0; i < graph.fields.length; i++) {
- var
- field = graph.fields[i],
- fieldElem = renderField(flightLog, field, field.color?(field.color):(GraphConfig.PALETTE[i].color));
-
- fieldList.append(fieldElem);
+ for (const field of graph.fields) {
+ const extendedFields = activeGraphConfig.extendFields(activeFlightLog, field);
+ let colorIndex = 0;
+ for (const extField of extendedFields) {
+ const color = extField.color ?? GraphConfig.PALETTE[colorIndex++ % GraphConfig.PALETTE.length].color;
+ const fieldElem = renderField(flightLog, extField, color);
+ fieldList.append(fieldElem);
+ }
}
fieldList.on('click', 'button', function(e) {
- var
- parentGraph = $(this).parents('.config-graph');
+ const parentGraph = $(this).parents('.config-graph');
$(this).parents('.config-graph-field').remove();
@@ -302,20 +321,17 @@ export function GraphConfigurationDialog(dialog, onSave) {
}
function renderGraphs(flightLog, graphs) {
- var
+ const
graphList = $(".config-graphs-list", dialog);
graphList.empty();
- for (var i = 0; i < graphs.length; i++) {
+ for (let i = 0; i < graphs.length; i++) {
graphList.append(renderGraph(flightLog, i, graphs[i]));
}
}
function populateExampleGraphs(flightLog, menu) {
- var
- i;
-
menu.empty();
exampleGraphs = GraphConfig.getExampleGraphConfigs(flightLog);
@@ -326,31 +342,25 @@ export function GraphConfigurationDialog(dialog, onSave) {
dividerAfter: true
});
- for (i = 0; i < exampleGraphs.length; i++) {
- var
- graph = exampleGraphs[i],
- li = $('
');
+ for (let i = 0; i < exampleGraphs.length; i++) {
+ const li = $('');
$('a', li)
- .text(graph.label)
+ .text(exampleGraphs[i].label)
.data('graphIndex', i);
menu.append(li);
- if (graph.dividerAfter) {
+ if (exampleGraphs[i].dividerAfter) {
menu.append('');
}
}
}
function convertUIToGraphConfig() {
- var
- graphs = [],
- graph,
- field;
-
+ const graphs = [];
$(".config-graph", dialog).each(function() {
- graph = {
+ const graph = {
fields: [],
height: 1
};
@@ -362,7 +372,7 @@ export function GraphConfigurationDialog(dialog, onSave) {
const fieldName = $("select", this).val();
const minimum = $("input[name=MinValue]", this).val();
const maximum = $("input[name=MaxValue]", this).val();
- field = {
+ const field = {
name: fieldName,
smoothing: parseInt($("input[name=smoothing]", this).val())*100, // Value 0-100% = 0-10000uS (higher values are more smooth, 30% is typical)
curve: {
@@ -397,19 +407,15 @@ export function GraphConfigurationDialog(dialog, onSave) {
// Decide which fields we should offer to the user
function buildOfferedFieldNamesList(flightLog, config) {
- var
- i, j,
- lastRoot = null,
- fieldNames = flightLog.getMainFieldNames(),
- fieldsSeen = {};
+ let lastRoot = null;
+ const fieldNames = flightLog.getMainFieldNames(),
+ fieldsSeen = {};
offeredFieldNames = [];
- for (i = 0; i < fieldNames.length; i++) {
+ for (const fieldName of fieldNames) {
// For fields with multiple bracketed x[0], x[1] versions, add an "[all]" option
- var
- fieldName = fieldNames[i],
- matches = fieldName.match(/^(.+)\[[0-9]+\]$/);
+ const matches = fieldName.match(/^(.+)\[[0-9]+\]$/);
if (BLACKLISTED_FIELDS[fieldName])
continue;
@@ -434,14 +440,8 @@ export function GraphConfigurationDialog(dialog, onSave) {
* the GUI anyway. (This way we can build a config when using a tricopter (which includes a tail servo) and
* keep that tail servo in the config when we're viewing a quadcopter).
*/
- for (i = 0; i < config.length; i++) {
- var
- graph = config[i];
-
- for (j = 0; j < graph.fields.length; j++) {
- var
- field = graph.fields[j];
-
+ for (const graph of config) {
+ for (const field of graph.fields) {
if (!fieldsSeen[field.name]) {
offeredFieldNames.push(field.name);
}
@@ -449,10 +449,12 @@ export function GraphConfigurationDialog(dialog, onSave) {
}
}
- this.show = function(flightLog, config, grapher) {
+ this.show = function(flightLog, graphConfig, grapher) {
dialog.modal('show');
activeFlightLog = flightLog;
logGrapher = grapher;
+ activeGraphConfig = graphConfig;
+ const config = activeGraphConfig.getGraphs();
buildOfferedFieldNamesList(flightLog, config);
@@ -504,7 +506,7 @@ export function GraphConfigurationDialog(dialog, onSave) {
onSave(convertUIToGraphConfig(), noRedraw);
}
- var
+ let
exampleGraphsButton = $(".config-graphs-add"),
exampleGraphsMenu = $(".config-graphs-add ~ .dropdown-menu"),
configGraphsList = $('.config-graphs-list');
@@ -520,7 +522,7 @@ export function GraphConfigurationDialog(dialog, onSave) {
exampleGraphsButton.dropdown();
exampleGraphsMenu.on("click", "a", function(e) {
- var
+ const
graph = exampleGraphs[$(this).data("graphIndex")],
graphElem = renderGraph(activeFlightLog, $(".config-graph", dialog).length, graph);
@@ -536,10 +538,10 @@ export function GraphConfigurationDialog(dialog, onSave) {
});
// Remove all Graphs button
- var removeAllGraphsButton = $(".config-graphs-remove-all-graphs");
+ const removeAllGraphsButton = $(".config-graphs-remove-all-graphs");
removeAllGraphsButton.on("click", function() {
$('.config-graph').remove();
updateRemoveAllButton();
RefreshCharts();
});
-}
\ No newline at end of file
+}
diff --git a/src/main.js b/src/main.js
index a26d9340..75b8559d 100644
--- a/src/main.js
+++ b/src/main.js
@@ -673,7 +673,7 @@ function BlackboxLogViewer() {
setVideoInTime(false);
setVideoOutTime(false);
- activeGraphConfig.adaptGraphs(flightLog, graphConfig, true);
+ activeGraphConfig.adaptGraphs(flightLog, graphConfig);
graph.onSeek = function(offset) {
//Seek faster
@@ -1004,7 +1004,7 @@ function BlackboxLogViewer() {
lastGraphConfig = graphConfig; // Remember the last configuration.
graphConfig = newConfig;
activeGraphConfig.setRedrawChart(noRedraw ? false : true);
- activeGraphConfig.adaptGraphs(flightLog, graphConfig, false);
+ activeGraphConfig.adaptGraphs(flightLog, graphConfig);
prefs.set('graphConfig', graphConfig);
}
@@ -1444,7 +1444,7 @@ function BlackboxLogViewer() {
$(".open-graph-configuration-dialog").click(function(e) {
e.preventDefault();
- graphConfigDialog.show(flightLog, activeGraphConfig.getGraphs(), graph);
+ graphConfigDialog.show(flightLog, activeGraphConfig, graph);
});
$(".open-header-dialog").click(function(e) {