Skip to content

Commit 86f47f8

Browse files
committed
fix: fix zoom reset deriv graph scale
1 parent 947962f commit 86f47f8

File tree

2 files changed

+30
-17
lines changed

2 files changed

+30
-17
lines changed

dist/components/d3_multi/multi_focus.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var _multiplicity_calc = require("../../helpers/multiplicity_calc");
2121
var _calc = require("../../helpers/calc");
2222
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
2323
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
24+
/* eslint-disable no-multi-assign */
2425
/* eslint-disable no-unused-vars, prefer-object-spread, no-mixed-operators,
2526
no-unneeded-ternary, arrow-body-style */
2627

@@ -84,6 +85,13 @@ class MultiFocus {
8485
yU: null
8586
}
8687
};
88+
this.initialSecondaryExtent = {
89+
xExtent: null,
90+
yExtent: {
91+
yL: null,
92+
yU: null
93+
}
94+
};
8795
this.shouldUpdate = {};
8896
// this.freq = false;
8997
this.layout = _list_layout.LIST_LAYOUT.CYCLIC_VOLTAMMETRY;
@@ -287,24 +295,21 @@ class MultiFocus {
287295
this.scales.x.domain([xExtent.xL, xExtent.xU]);
288296
this.axisCall.x.scale(xt);
289297
this.axisCall.y.scale(yt);
290-
if (sweepExtentSt.newOtherGraphExtents) {
291-
this.secondaryYScale = d3.scaleLinear().domain([sweepExtentSt.newOtherGraphExtents.yL, sweepExtentSt.newOtherGraphExtents.yU]).range([this.h, 0]);
298+
if (sweepExtentSt.newOtherGraphExtents || this.secondaryExtent.yExtent.yU !== this.initialSecondaryExtent.yExtent.yL) {
299+
const yExtentValues = sweepExtentSt.newOtherGraphExtents ? [sweepExtentSt.newOtherGraphExtents.yL, sweepExtentSt.newOtherGraphExtents.yU] : [this.initialSecondaryExtent.yExtent.yL, this.initialSecondaryExtent.yExtent.yU];
300+
this.secondaryYScale = d3.scaleLinear().domain(yExtentValues).range([this.h, 0]);
292301
const yAxisSecondary = d3.axisRight(this.secondaryYScale);
293302
this.secondaryAxis.y.call(yAxisSecondary);
294303
this.updateSecondaryPathCall(xt, this.secondaryYScale);
295304
this.secondaryExtent = {
296305
xExtent,
297306
yExtent: {
298-
yL: sweepExtentSt.newOtherGraphExtents.yL,
299-
yU: sweepExtentSt.newOtherGraphExtents.yU
307+
yL: yExtentValues[0],
308+
yU: yExtentValues[1]
300309
}
301310
};
302311
}
303-
this.currentExtent = {
304-
xExtent,
305-
yExtent
306-
};
307-
this.primaryExtent = {
312+
this.currentExtent = this.primaryExtent = {
308313
xExtent,
309314
yExtent
310315
};
@@ -460,6 +465,7 @@ class MultiFocus {
460465
this.secondaryAxisDrawn = true;
461466
this.secondaryYScale = secondaryYScale;
462467
this.secondaryAxis = secondaryAxes;
468+
this.initialSecondaryExtent = this.secondaryExtent;
463469
}
464470
return {
465471
secondaryYScale: this.secondaryYScale,

src/components/d3_multi/multi_focus.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-multi-assign */
12
/* eslint-disable no-unused-vars, prefer-object-spread, no-mixed-operators,
23
no-unneeded-ternary, arrow-body-style */
34
import * as d3 from 'd3';
@@ -68,6 +69,7 @@ class MultiFocus {
6869
this.currentExtent = null;
6970
this.primaryExtent = { xExtent: null, yExtent: { yL: null, yU: null } };
7071
this.secondaryExtent = { xExtent: null, yExtent: { yL: null, yU: null } };
72+
this.initialSecondaryExtent = { xExtent: null, yExtent: { yL: null, yU: null } };
7173
this.shouldUpdate = {};
7274
// this.freq = false;
7375
this.layout = LIST_LAYOUT.CYCLIC_VOLTAMMETRY;
@@ -275,26 +277,30 @@ class MultiFocus {
275277
this.axisCall.x.scale(xt);
276278
this.axisCall.y.scale(yt);
277279

278-
if (sweepExtentSt.newOtherGraphExtents) {
280+
if (sweepExtentSt.newOtherGraphExtents
281+
|| this.secondaryExtent.yExtent.yU !== this.initialSecondaryExtent.yExtent.yL) {
282+
const yExtentValues = sweepExtentSt.newOtherGraphExtents
283+
? [sweepExtentSt.newOtherGraphExtents.yL, sweepExtentSt.newOtherGraphExtents.yU]
284+
: [this.initialSecondaryExtent.yExtent.yL, this.initialSecondaryExtent.yExtent.yU];
285+
279286
this.secondaryYScale = d3.scaleLinear()
280-
.domain([(sweepExtentSt.newOtherGraphExtents.yL),
281-
(sweepExtentSt.newOtherGraphExtents.yU)])
287+
.domain(yExtentValues)
282288
.range([this.h, 0]);
289+
283290
const yAxisSecondary = d3.axisRight(this.secondaryYScale);
284291
this.secondaryAxis.y.call(yAxisSecondary);
285-
286292
this.updateSecondaryPathCall(xt, this.secondaryYScale);
293+
287294
this.secondaryExtent = {
288295
xExtent,
289296
yExtent: {
290-
yL: sweepExtentSt.newOtherGraphExtents.yL,
291-
yU: sweepExtentSt.newOtherGraphExtents.yU,
297+
yL: yExtentValues[0],
298+
yU: yExtentValues[1],
292299
},
293300
};
294301
}
295302

296-
this.currentExtent = { xExtent, yExtent };
297-
this.primaryExtent = { xExtent, yExtent };
303+
this.currentExtent = this.primaryExtent = { xExtent, yExtent };
298304
}
299305
}
300306

@@ -424,6 +430,7 @@ class MultiFocus {
424430
this.secondaryAxisDrawn = true;
425431
this.secondaryYScale = secondaryYScale;
426432
this.secondaryAxis = secondaryAxes;
433+
this.initialSecondaryExtent = this.secondaryExtent;
427434
}
428435
return {
429436
secondaryYScale: this.secondaryYScale,

0 commit comments

Comments
 (0)