Skip to content

Commit 48a71f9

Browse files
committed
fix: zoom through graphes fixed
1 parent 6b0f69e commit 48a71f9

File tree

6 files changed

+53
-19
lines changed

6 files changed

+53
-19
lines changed

src/components/d3_line_rect/index.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -169,22 +169,22 @@ class ViewerLineRect extends React.Component {
169169
super(props);
170170

171171
const {
172-
clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct, entities,
172+
clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct, entities, uiSt,
173173
} = props;
174174

175175
this.rootKlassLine = `.${LIST_ROOT_SVG_GRAPH.LINE}`;
176176
this.lineFocus = new LineFocus({
177-
W, H, entities, clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct,
177+
W, H, entities, clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct, graphIndex: 0, uiSt,
178178
});
179179

180180
this.rootKlassMulti = `.${LIST_ROOT_SVG_GRAPH.MULTI}`;
181181
this.multiFocus = new MultiFocus({
182-
W, H, entities, clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct,
182+
W, H, entities, clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct, graphIndex: 1, uiSt,
183183
});
184184

185185
this.rootKlassRect = `.${LIST_ROOT_SVG_GRAPH.RECT}`;
186186
this.rectFocus = new RectFocus({
187-
W, H, clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct,
187+
W, H, clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct, graphIndex: 2, uiSt,
188188
});
189189

190190
this.normChange = this.normChange.bind(this);
@@ -282,6 +282,7 @@ class ViewerLineRect extends React.Component {
282282
tTrEndPts,
283283
isUiNoBrushSt: true,
284284
sweepExtentSt: sweepExtent[0],
285+
uiSt,
285286
});
286287
drawLabel(this.rootKlassLine, null, 'Minutes', 'Intensity');
287288
drawDisplay(this.rootKlassLine, false);
@@ -298,6 +299,7 @@ class ViewerLineRect extends React.Component {
298299
sweepExtentSt: sweepExtent[1],
299300
isUiAddIntgSt,
300301
isUiNoBrushSt,
302+
uiSt,
301303
});
302304
drawLabel(this.rootKlassMulti, cLabel, 'Minutes', 'Intensity');
303305
drawDisplay(this.rootKlassMulti, isHidden);
@@ -319,6 +321,7 @@ class ViewerLineRect extends React.Component {
319321
tTrEndPts: curTrEndPts,
320322
isUiNoBrushSt: true,
321323
sweepExtentSt: sweepExtent[2],
324+
uiSt,
322325
});
323326
drawLabel(this.rootKlassRect, `${pageValue} min`, 'M/Z', 'Intensity');
324327
drawDisplay(this.rootKlassRect, false);

src/components/d3_line_rect/line_focus.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ const d3 = require('d3');
1616
class LineFocus {
1717
constructor(props) {
1818
const {
19-
W, H, clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct,
19+
W, H, clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct, graphIndex, uiSt,
2020
} = props;
21-
21+
this.graphIndex = graphIndex;
22+
this.uiSt = uiSt;
2223
this.jcampIdx = 0;
2324
this.rootKlass = `.${LIST_ROOT_SVG_GRAPH.LINE}`;
2425
this.margin = {
@@ -216,12 +217,12 @@ class LineFocus {
216217
update({
217218
filterSeed, tTrEndPts,
218219
layoutSt,
219-
sweepExtentSt, isUiAddIntgSt, isUiNoBrushSt,
220+
sweepExtentSt, isUiAddIntgSt, isUiNoBrushSt, uiSt,
220221
}) {
221222
this.root = d3.select(this.rootKlass).selectAll('.focus-main');
222223
this.scales = InitScale(this, false);
223224
this.setDataParams(filterSeed, tTrEndPts, layoutSt);
224-
225+
this.uiSt = uiSt;
225226
if (this.data && this.data.length > 0) {
226227
this.setConfig(sweepExtentSt);
227228
this.getShouldUpdate();

src/components/d3_line_rect/multi_focus.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ const d3 = require('d3');
2121
class MultiFocus {
2222
constructor(props) {
2323
const {
24-
W, H, clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct, entities,
24+
W, H, clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct, entities, graphIndex, uiSt,
2525
} = props;
26-
26+
this.graphIndex = graphIndex;
27+
this.uiSt = uiSt;
2728
this.entities = entities;
2829
this.jcampIdx = 0;
2930
this.isShowAllCurves = false;
@@ -270,7 +271,7 @@ class MultiFocus {
270271
entities, curveSt,
271272
filterSeed, tTrEndPts,
272273
layoutSt,
273-
sweepExtentSt, isUiNoBrushSt,
274+
sweepExtentSt, isUiNoBrushSt, uiSt,
274275
}) {
275276
this.root = d3.select(this.rootKlass).selectAll('.focus-main');
276277
this.scales = InitScale(this, false);
@@ -279,6 +280,7 @@ class MultiFocus {
279280
const jcampIdx = curveIdx;
280281
this.isShowAllCurves = isShowAllCurve;
281282
this.entities = entities;
283+
this.uiSt = uiSt;
282284

283285
this.setDataParams(filterSeed, tTrEndPts, layoutSt, jcampIdx);
284286

src/components/d3_line_rect/rect_focus.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ const d3 = require('d3');
1616
class RectFocus {
1717
constructor(props) {
1818
const {
19-
W, H, clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct,
19+
W, H, clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct, graphIndex, uiSt,
2020
} = props;
21-
21+
this.graphIndex = graphIndex;
22+
this.uiSt = uiSt;
2223
this.rootKlass = `.${LIST_ROOT_SVG_GRAPH.RECT}`;
2324
this.brushClass = `.${LIST_BRUSH_SVG_GRAPH.RECT}`;
2425
this.margin = {
@@ -230,10 +231,11 @@ class RectFocus {
230231

231232
update({
232233
filterSeed, filterPeak, tTrEndPts, tSfPeaks,
233-
sweepExtentSt, isUiAddIntgSt, isUiNoBrushSt,
234+
sweepExtentSt, isUiAddIntgSt, isUiNoBrushSt, uiSt,
234235
}) {
235236
this.root = d3.select(this.rootKlass).selectAll('.focus-main');
236237
this.setDataParams(filterSeed, filterPeak, tTrEndPts, tSfPeaks);
238+
this.uiSt = uiSt;
237239

238240
if (this.data && this.data.length > 0) {
239241
this.setConfig(sweepExtentSt);

src/helpers/brush.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable prefer-object-spread */
2-
32
import { MouseMove } from './compass';
3+
import { LIST_UI_SWEEP_TYPE } from '../constants/list_ui';
44

55
const d3 = require('d3');
66

@@ -44,8 +44,23 @@ const MountBrush = (focus, isUiAddIntgSt, isUiNoBrushSt, brushedClass = '.d3Svg'
4444
} = focus;
4545
svg.selectAll('.brush').remove();
4646
svg.selectAll('.brushX').remove();
47+
if (focus.uiSt
48+
&& focus.uiSt.zoom
49+
&& Array.isArray(focus.uiSt.zoom.sweepTypes)
50+
&& focus.uiSt.zoom.sweepTypes[focus.graphIndex] !== LIST_UI_SWEEP_TYPE.ZOOMIN) {
51+
return;
52+
}
4753

48-
const brushedCb = (event) => brushed(focus, isUiAddIntgSt, event, brushedClass);
54+
const brushedCb = (event) => {
55+
if (focus.graphIndex !== undefined
56+
&& focus.uiSt
57+
&& focus.uiSt.zoom
58+
&& Array.isArray(focus.uiSt.zoom.sweepTypes)
59+
&& focus.uiSt.zoom.sweepTypes[focus.graphIndex] !== LIST_UI_SWEEP_TYPE.ZOOMIN) {
60+
return;
61+
}
62+
brushed(focus, isUiAddIntgSt, event, brushedClass);
63+
};
4964
const wheeledCb = (event) => wheeled(focus, event);
5065

5166
if (isUiNoBrushSt) {

src/reducers/reducer_ui.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,20 @@ const updateSweepType = (state, action) => {
3636
});
3737
}
3838
const { zoom } = state;
39-
const { sweepTypes } = zoom;
40-
sweepTypes[graphIndex] = sweepType;
41-
const newZoom = Object.assign({}, zoom, { sweepTypes, graphIndex });
39+
let newSweepTypes = zoom.sweepTypes.slice();
40+
newSweepTypes[graphIndex] = sweepType;
41+
42+
if (sweepType === LIST_UI_SWEEP_TYPE.ZOOMIN) {
43+
newSweepTypes = newSweepTypes.map((val, idx) => (
44+
idx === graphIndex
45+
? LIST_UI_SWEEP_TYPE.ZOOMIN
46+
: LIST_UI_SWEEP_TYPE.ZOOMRESET
47+
));
48+
}
49+
const newZoom = Object.assign({}, zoom, {
50+
sweepTypes: newSweepTypes,
51+
graphIndex,
52+
});
4253
return Object.assign({}, state, {
4354
zoom: newZoom,
4455
sweepType,

0 commit comments

Comments
 (0)