Skip to content

Commit 5f28cd4

Browse files
authored
Fixed issues of first applications run (#753)
* resolved issue of load default workspace configuration * The onSwitchWorkspace function call optimization * Resolved issue: GraphConfig load error by first programm run * resolved error of loading undefined stored graph config data by first program run * Code style improvement * resolved issue of wrong curves colors by first application run * The SonarCloud issue improvement * The SonarCloud issue improvement * Resolved issue of color assign for combined (Gyro+PID) samples graphs
1 parent 748638e commit 5f28cd4

File tree

3 files changed

+193
-191
lines changed

3 files changed

+193
-191
lines changed

src/graph_config.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,18 @@ export function GraphConfig(graphConfig) {
4747
const matches = field.name.match(/^(.+)\[all\]$/);
4848
const logFieldNames = flightLog.getMainFieldNames();
4949
const fields = [];
50+
const setupColor = field?.color == -1;
5051
if (matches) {
5152
const
5253
nameRoot = matches[1],
5354
nameRegex = new RegExp("^" + escapeRegExp(nameRoot) + "\[[0-9]+\]$");
54-
55+
let colorIndex = 0;
5556
for (const fieldName of logFieldNames) {
5657
if (fieldName.match(nameRegex)) {
5758
// forceNewCurve must be true for min max computing extended curves.
5859
const forceNewCurve = true;
59-
field.color = undefined;
60+
const color = GraphConfig.PALETTE[colorIndex++ % GraphConfig.PALETTE.length].color;
61+
field.color = setupColor ? color : undefined;
6062
fields.push(adaptField(flightLog, $.extend({}, field, {curve: $.extend({}, field.curve), name: fieldName, friendlyName: FlightLogFieldPresenter.fieldNameToFriendly(fieldName, flightLog.getSysConfig().debug_mode)}), forceNewCurve));
6163
}
6264
}
@@ -1395,7 +1397,8 @@ GraphConfig.load = function(config) {
13951397

13961398
for (const srcFieldName of srcGraph.fields) {
13971399
const destField = {
1398-
name: srcFieldName
1400+
name: srcFieldName,
1401+
color: -1,
13991402
};
14001403

14011404
destGraph.fields.push(destField);

src/graph_config_dialog.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,14 @@ export function GraphConfigurationDialog(dialog, onSave) {
291291
$('select.graph-height', graphElem).replaceWith(chooseHeight(graph.height?(graph.height):1));
292292

293293
// Add Field List
294+
let colorIndex = 0;
294295
for (const field of graph.fields) {
295296
const extendedFields = activeGraphConfig.extendFields(activeFlightLog, field);
296-
let colorIndex = 0;
297297
for (const extField of extendedFields) {
298-
const color = extField.color ?? GraphConfig.PALETTE[colorIndex++ % GraphConfig.PALETTE.length].color;
299-
const fieldElem = renderField(flightLog, extField, color);
298+
if (!extField.color || extField.color == -1) {
299+
extField.color = GraphConfig.PALETTE[colorIndex++ % GraphConfig.PALETTE.length].color;
300+
}
301+
const fieldElem = renderField(flightLog, extField, extField.color);
300302
fieldList.append(fieldElem);
301303
}
302304
}

0 commit comments

Comments
 (0)