Skip to content

Commit 6fcf7dc

Browse files
committed
Chart curves redrawing is optimized
1 parent 990c363 commit 6fcf7dc

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

js/graph_config.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ function GraphConfig(graphConfig) {
2424
this.getGraphs = function() {
2525
return graphs;
2626
};
27+
28+
let redrawChart = true;
29+
this.setRedrawChart = function(isRedraw) {
30+
redrawChart = isRedraw;
31+
}
2732

2833
/**
2934
* newGraphs is an array of objects like {label: "graph label", height:, fields:[{name: curve:{power:, MinMax:, steps:}, color:, }, ...]}
@@ -32,9 +37,12 @@ function GraphConfig(graphConfig) {
3237
graphs = newGraphs;
3338

3439
hiddenGraphFields.clear();
35-
36-
notifyListeners();
40+
if (redrawChart) {
41+
notifyListeners();
42+
}
3743
};
44+
45+
3846

3947
/**
4048
* Convert the given graph configs to make them appropriate for the given flight log.

js/graph_config_dialog.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -460,29 +460,34 @@ function GraphConfigurationDialog(dialog, onSave) {
460460
return;
461461
}
462462

463-
if (cfgMustBeRestored)
464-
onSave(prevCfg);
463+
if (cfgMustBeRestored) {
464+
const noRedraw = false;
465+
onSave(prevCfg, noRedraw);
466+
}
465467
});
466468

467469
$(".graph-configuration-dialog-save").click(function() {
468470
if (isMinMaxContextMenuActive())
469471
closeMinMaxContextMenu();
470472

471473
cfgMustBeRestored = false;
472-
onSave(convertUIToGraphConfig());
474+
const noRedraw = true;
475+
onSave(convertUIToGraphConfig(), noRedraw);
473476
});
474477

475478
$(".graph-configuration-dialog-cancel").click(function() {
476479
if (isMinMaxContextMenuActive())
477480
closeMinMaxContextMenu();
478-
481+
482+
const noRedraw = !cfgMustBeRestored;
483+
onSave(prevCfg, noRedraw);
479484
cfgMustBeRestored = false;
480-
onSave(prevCfg);
481485
});
482486

483487
function RefreshCharts() {
484488
cfgMustBeRestored = true;
485-
onSave(convertUIToGraphConfig());
489+
const noRedraw = false;
490+
onSave(convertUIToGraphConfig(), noRedraw);
486491
}
487492

488493
var

js/main.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -997,10 +997,10 @@ function BlackboxLogViewer() {
997997
GpxExporter(flightLog).dump(onSuccess);
998998
}
999999

1000-
function newGraphConfig(newConfig) {
1000+
function newGraphConfig(newConfig, noRedraw) {
10011001
lastGraphConfig = graphConfig; // Remember the last configuration.
10021002
graphConfig = newConfig;
1003-
1003+
activeGraphConfig.setRedrawChart(noRedraw ? false : true);
10041004
activeGraphConfig.adaptGraphs(flightLog, graphConfig, false);
10051005

10061006
prefs.set('graphConfig', graphConfig);
@@ -1410,8 +1410,8 @@ function BlackboxLogViewer() {
14101410
}
14111411

14121412
var
1413-
graphConfigDialog = new GraphConfigurationDialog($("#dlgGraphConfiguration"), function(newConfig) {
1414-
newGraphConfig(newConfig);
1413+
graphConfigDialog = new GraphConfigurationDialog($("#dlgGraphConfiguration"), function(newConfig, redrawChart) {
1414+
newGraphConfig(newConfig, redrawChart);
14151415
}),
14161416

14171417
headerDialog = new HeaderDialog($("#dlgHeaderDialog"), function(newSysConfig) {

0 commit comments

Comments
 (0)