@@ -10,8 +10,11 @@ import {
1010import { resetAll } from '../../actions/manager' ;
1111import { selectUiSweep , scrollUiWheel , clickUiTarget } from '../../actions/ui' ;
1212// import RectFocus from './rect_focus';
13- import LineFocus from './line_focus' ;
13+ // import LineFocus from './line_focus';
1414import RectFocus from './rect_focus' ;
15+ import MultiFocus from './multi_focus' ;
16+ import { extractParams } from '../../helpers/extractParams' ;
17+ import { findClosest } from '../../helpers/calc' ;
1518import {
1619 drawMain , drawLabel , drawDisplay , drawDestroy ,
1720} from '../common/draw' ;
@@ -24,10 +27,15 @@ class ViewerLineRect extends React.Component {
2427 constructor ( props ) {
2528 super ( props ) ;
2629
27- const { clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct } = props ;
30+ const {
31+ clickUiTargetAct, selectUiSweepAct, scrollUiWheelAct, entities,
32+ } = props ;
2833 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,
3139 } ) ;
3240
3341 this . rootKlassRect = '.d3Rect' ;
@@ -41,7 +49,7 @@ class ViewerLineRect extends React.Component {
4149
4250 componentDidMount ( ) {
4351 const {
44- seed, cLabel, xLabel, yLabel, feature,
52+ entities , curveSt , seed, cLabel, xLabel, yLabel, feature,
4553 tTrEndPts, layoutSt,
4654 sweepExtentSt, isUiAddIntgSt, isUiNoBrushSt,
4755 isHidden, sweepExtentSubViewSt,
@@ -54,6 +62,8 @@ class ViewerLineRect extends React.Component {
5462
5563 drawMain ( this . rootKlassLine , W , H ) ;
5664 this . lineFocus . create ( {
65+ entities,
66+ curveSt,
5767 filterSeed,
5868 tTrEndPts,
5969 layoutSt,
@@ -78,7 +88,7 @@ class ViewerLineRect extends React.Component {
7888
7989 componentDidUpdate ( prevProps ) {
8090 const {
81- seed, cLabel, xLabel, yLabel,
91+ entities , curveSt , seed, cLabel, xLabel, yLabel,
8292 tTrEndPts, layoutSt,
8393 sweepExtentSt, isUiAddIntgSt, isUiNoBrushSt,
8494 isHidden, sweepExtentSubViewSt,
@@ -88,6 +98,8 @@ class ViewerLineRect extends React.Component {
8898 const filterSeed = seed ;
8999
90100 this . lineFocus . update ( {
101+ entities,
102+ curveSt,
91103 filterSeed,
92104 tTrEndPts,
93105 layoutSt,
@@ -132,13 +144,19 @@ class ViewerLineRect extends React.Component {
132144 }
133145
134146 extractSubView ( ) {
135- const { uiSt, features } = this . props ;
147+ const { uiSt, subEntities } = this . props ;
136148 const { subViewerAt } = uiSt ;
137149 let selectFeature = null ;
150+
138151 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 ) ;
139157 const filteredFeatures = features . filter ( ( fe ) => {
140158 const { pageValue } = fe ;
141- return pageValue === subViewerAt . x ;
159+ return pageValue === closestPage ;
142160 } ) ;
143161 [ selectFeature ] = filteredFeatures ;
144162 }
@@ -161,6 +179,7 @@ class ViewerLineRect extends React.Component {
161179
162180const mapStateToProps = ( state , props ) => (
163181 {
182+ curveSt : state . curve ,
164183 seed : Topic2Seed ( state , props ) ,
165184 tTrEndPts : ToThresEndPts ( state , props ) ,
166185 sweepExtentSt : state . ui . sweepExtent ,
@@ -181,13 +200,16 @@ const mapDispatchToProps = (dispatch) => (
181200) ;
182201
183202ViewerLineRect . propTypes = {
203+ uiSt : PropTypes . object . isRequired ,
204+ curveSt : PropTypes . object . isRequired ,
205+ entities : PropTypes . array . isRequired ,
206+ subEntities : PropTypes . array . isRequired ,
184207 seed : PropTypes . array . isRequired ,
185208 cLabel : PropTypes . string . isRequired ,
186209 xLabel : PropTypes . string . isRequired ,
187210 yLabel : PropTypes . string . isRequired ,
188211 layoutSt : PropTypes . string . isRequired ,
189212 feature : PropTypes . object . isRequired ,
190- features : PropTypes . array . isRequired ,
191213 tTrEndPts : PropTypes . array . isRequired ,
192214 sweepExtentSt : PropTypes . object . isRequired ,
193215 sweepExtentSubViewSt : PropTypes . object . isRequired ,
@@ -198,7 +220,6 @@ ViewerLineRect.propTypes = {
198220 selectUiSweepAct : PropTypes . func . isRequired ,
199221 scrollUiWheelAct : PropTypes . func . isRequired ,
200222 isHidden : PropTypes . bool . isRequired ,
201- uiSt : PropTypes . object . isRequired ,
202223} ;
203224
204225export default connect ( mapStateToProps , mapDispatchToProps ) ( ViewerLineRect ) ;
0 commit comments