Skip to content

Commit

Permalink
Merge pull request #1037 from n-gist/synchonizer-y-zoom-ignorance-fix
Browse files Browse the repository at this point in the history
Synchronizer plugin vertical zoom ignorance fix
  • Loading branch information
mirabilos authored Feb 4, 2025
2 parents ecdc964 + 79715fd commit 767b454
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/extras/synchronizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,10 @@ function attachZoomHandlers(gs, syncOpts, prevCallbacks) {
}

block = true;

var opts = {
dateWindow: me.xAxisRange()
};
if (!me.isZoomed('x'))
opts.dateWindow = null;
if (syncOpts.range)
opts.valueRange = me.yAxisRange();

Expand All @@ -208,14 +207,17 @@ function attachZoomHandlers(gs, syncOpts, prevCallbacks) {
continue;
}

// Only redraw if there are new options
if (arraysAreEqual(opts.dateWindow, gs[j].getOption('dateWindow')) &&
(!syncOpts.range ||
arraysAreEqual(opts.valueRange, gs[j].getOption('valueRange')))) {
continue;
}
// If X-zoom differs, update
var update = !arraysAreEqual(opts.dateWindow, gs[j].getOption('dateWindow'));
// If Y-zoom differs and syncing, update
if (!update && syncOpts.range && !arraysAreEqual(opts.valueRange, gs[j].getOption('valueRange')))
update = true;
// If about to update, but not syncing Y-zoom, pass current value
if (update && !syncOpts.range)
opts.valueRange = gs[j].yAxisRange();

gs[j].updateOptions(opts);
if (update)
gs[j].updateOptions(opts);
}
block = false;
}
Expand Down

0 comments on commit 767b454

Please sign in to comment.