@@ -10,8 +10,11 @@ import {
10
10
import { resetAll } from '../../actions/manager' ;
11
11
import { selectUiSweep , scrollUiWheel , clickUiTarget } from '../../actions/ui' ;
12
12
// import RectFocus from './rect_focus';
13
- import LineFocus from './line_focus' ;
13
+ // import LineFocus from './line_focus';
14
14
import RectFocus from './rect_focus' ;
15
+ import MultiFocus from './multi_focus' ;
16
+ import { extractParams } from '../../helpers/extractParams' ;
17
+ import { findClosest } from '../../helpers/calc' ;
15
18
import {
16
19
drawMain , drawLabel , drawDisplay , drawDestroy ,
17
20
} from '../common/draw' ;
@@ -24,10 +27,15 @@ class ViewerLineRect extends React.Component {
24
27
constructor ( props ) {
25
28
super ( props ) ;
26
29
27
- const { clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct } = props ;
30
+ const {
31
+ clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct, entities,
32
+ } = props ;
28
33
this . rootKlassLine = '.d3Line' ;
29
- this . lineFocus = new LineFocus ( {
30
- W, H, clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct,
34
+ // this.lineFocus = new LineFocus({
35
+ // W, H, clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct,
36
+ // });
37
+ this . lineFocus = new MultiFocus ( {
38
+ W, H, entities, clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct,
31
39
} ) ;
32
40
33
41
this . rootKlassRect = '.d3Rect' ;
@@ -41,7 +49,7 @@ class ViewerLineRect extends React.Component {
41
49
42
50
componentDidMount ( ) {
43
51
const {
44
- seed, cLabel, xLabel, yLabel, feature,
52
+ entities , curveSt , seed, cLabel, xLabel, yLabel, feature,
45
53
tTrEndPts, layoutSt,
46
54
sweepExtentSt, isUiAddIntgSt, isUiNoBrushSt,
47
55
isHidden, sweepExtentSubViewSt,
@@ -54,6 +62,8 @@ class ViewerLineRect extends React.Component {
54
62
55
63
drawMain ( this . rootKlassLine , W , H ) ;
56
64
this . lineFocus . create ( {
65
+ entities,
66
+ curveSt,
57
67
filterSeed,
58
68
tTrEndPts,
59
69
layoutSt,
@@ -78,7 +88,7 @@ class ViewerLineRect extends React.Component {
78
88
79
89
componentDidUpdate ( prevProps ) {
80
90
const {
81
- seed, cLabel, xLabel, yLabel,
91
+ entities , curveSt , seed, cLabel, xLabel, yLabel,
82
92
tTrEndPts, layoutSt,
83
93
sweepExtentSt, isUiAddIntgSt, isUiNoBrushSt,
84
94
isHidden, sweepExtentSubViewSt,
@@ -88,6 +98,8 @@ class ViewerLineRect extends React.Component {
88
98
const filterSeed = seed ;
89
99
90
100
this . lineFocus . update ( {
101
+ entities,
102
+ curveSt,
91
103
filterSeed,
92
104
tTrEndPts,
93
105
layoutSt,
@@ -132,13 +144,19 @@ class ViewerLineRect extends React.Component {
132
144
}
133
145
134
146
extractSubView ( ) {
135
- const { uiSt, features } = this . props ;
147
+ const { uiSt, subEntities } = this . props ;
136
148
const { subViewerAt } = uiSt ;
137
149
let selectFeature = null ;
150
+
138
151
if ( subViewerAt && subViewerAt . x ) {
152
+ const {
153
+ features,
154
+ } = extractParams ( subEntities [ 0 ] , 0 , 1 ) ;
155
+ const arrPageValues = features . map ( ( fe ) => fe . pageValue ) ;
156
+ const closestPage = findClosest ( arrPageValues , subViewerAt . x ) ;
139
157
const filteredFeatures = features . filter ( ( fe ) => {
140
158
const { pageValue } = fe ;
141
- return pageValue === subViewerAt . x ;
159
+ return pageValue === closestPage ;
142
160
} ) ;
143
161
[ selectFeature ] = filteredFeatures ;
144
162
}
@@ -161,6 +179,7 @@ class ViewerLineRect extends React.Component {
161
179
162
180
const mapStateToProps = ( state , props ) => (
163
181
{
182
+ curveSt : state . curve ,
164
183
seed : Topic2Seed ( state , props ) ,
165
184
tTrEndPts : ToThresEndPts ( state , props ) ,
166
185
sweepExtentSt : state . ui . sweepExtent ,
@@ -181,13 +200,16 @@ const mapDispatchToProps = (dispatch) => (
181
200
) ;
182
201
183
202
ViewerLineRect . propTypes = {
203
+ uiSt : PropTypes . object . isRequired ,
204
+ curveSt : PropTypes . object . isRequired ,
205
+ entities : PropTypes . array . isRequired ,
206
+ subEntities : PropTypes . array . isRequired ,
184
207
seed : PropTypes . array . isRequired ,
185
208
cLabel : PropTypes . string . isRequired ,
186
209
xLabel : PropTypes . string . isRequired ,
187
210
yLabel : PropTypes . string . isRequired ,
188
211
layoutSt : PropTypes . string . isRequired ,
189
212
feature : PropTypes . object . isRequired ,
190
- features : PropTypes . array . isRequired ,
191
213
tTrEndPts : PropTypes . array . isRequired ,
192
214
sweepExtentSt : PropTypes . object . isRequired ,
193
215
sweepExtentSubViewSt : PropTypes . object . isRequired ,
@@ -198,7 +220,6 @@ ViewerLineRect.propTypes = {
198
220
selectUiSweepAct : PropTypes . func . isRequired ,
199
221
scrollUiWheelAct : PropTypes . func . isRequired ,
200
222
isHidden : PropTypes . bool . isRequired ,
201
- uiSt : PropTypes . object . isRequired ,
202
223
} ;
203
224
204
225
export default connect ( mapStateToProps , mapDispatchToProps ) ( ViewerLineRect ) ;
0 commit comments