@@ -17,14 +17,14 @@ export class CellListComponent implements OnInit, OnDestroy, DoCheck {
1717 cells : any ;
1818 session : any ;
1919 clickedUnitId : number ;
20+ clickedUnitIndex : number ;
2021 cellsByProbeIns = [ ] ;
2122 sortedCellsByProbeIns = [ ] ;
2223 plot_data ;
2324 plot_layout ;
2425 plot_config ;
2526
2627 targetClusterRowInfo = [ ] ;
27- targetUnitId ;
2828 targetClusterDepth ;
2929 targetClusterAmp ;
3030 targetProbeIndex ;
@@ -59,6 +59,7 @@ export class CellListComponent implements OnInit, OnDestroy, DoCheck {
5959
6060 ngOnInit ( ) {
6161 this . session = this . sessionInfo ;
62+ this . clickedUnitIndex = 0 ;
6263 let probeCount = 0
6364 while ( probeCount < this . sessionInfo [ 'probe_count' ] ) {
6465 this . probeInsertions . push ( probeCount + 1 ) ;
@@ -72,7 +73,7 @@ export class CellListComponent implements OnInit, OnDestroy, DoCheck {
7273 . subscribe ( ( cellListData ) => {
7374 this . unitBehaviorLoading = false ;
7475 this . unitPsthLoading = false ;
75- console . log ( 'logging retrieved cell list data: ' , cellListData ) ;
76+ // console.log('logging retrieved cell list data: ', cellListData);
7677 if ( Object . entries ( cellListData ) . length > 0 ) {
7778 this . cells = cellListData ;
7879 const x_data = [ ] ;
@@ -117,7 +118,6 @@ export class CellListComponent implements OnInit, OnDestroy, DoCheck {
117118 this . color_data_adjusted = color_data . map ( function ( elem ) {
118119 return `rgba(0, 125, ${ 255 * ( elem - Math . min ( ...color_data ) ) / ( Math . max ( ...color_data ) - Math . min ( ...color_data ) ) } , 0.33)`
119120 } ) ;
120- this . targetUnitId = 1 ;
121121 this . clickedUnitId = 1 ;
122122 // console.log('adjusted color data:', this.color_data_adjusted);
123123 this . plot_data = [ {
@@ -180,9 +180,9 @@ export class CellListComponent implements OnInit, OnDestroy, DoCheck {
180180 ngDoCheck ( ) {
181181 const markerColors = [ ] ;
182182 if ( this . plot_data ) {
183- if ( this . plot_data [ 0 ] [ 'x' ] && this . clickedUnitId > - 1 ) {
183+ if ( this . plot_data [ 0 ] [ 'x' ] && this . clickedUnitIndex > - 1 ) {
184184 for ( let i = 0 ; i < this . plot_data [ 0 ] [ 'x' ] . length ; i ++ ) {
185- if ( this . clickedUnitId - 1 === i ) {
185+ if ( this . clickedUnitIndex === i ) {
186186 markerColors . push ( 'rgba(0, 0, 0, 1)' ) ; // black
187187 } else {
188188 markerColors . push ( this . color_data_adjusted [ i ] ) ;
@@ -199,9 +199,7 @@ export class CellListComponent implements OnInit, OnDestroy, DoCheck {
199199 // console.log('markerColors: ', markerColors);
200200 }
201201
202- if ( this . targetUnitId ) {
203- this . cells
204- }
202+
205203
206204 }
207205 ngOnDestroy ( ) {
@@ -267,7 +265,6 @@ export class CellListComponent implements OnInit, OnDestroy, DoCheck {
267265 } ] ;
268266 this . unitBehaviorLoading = false ;
269267 this . unitPsthLoading = false ;
270- this . targetUnitId = 1 ;
271268 this . clickedUnitId = 1 ;
272269 // console.log('plot data for probe (' + probeInsNum + ') is - ', this.plot_data);
273270 }
@@ -280,64 +277,62 @@ export class CellListComponent implements OnInit, OnDestroy, DoCheck {
280277 const rows = element . querySelectorAll ( 'tr' ) ;
281278 // console.log('printing rows');
282279 // console.log(rows);
283- // this.targetUnitId = this.clickedUnitId;
284280 // console.log('clicked unitId is: ', this.clickedUnitId);
285281 if ( data [ 'points' ] && data [ 'points' ] [ 0 ] [ 'customdata' ] ) {
286282 // console.log('data[points][0] is: ', data['points'][0]);
287283 this . clickedUnitId = data [ 'points' ] [ 0 ] [ 'customdata' ] ;
288- this . targetUnitId = this . clickedUnitId ;
289- // console.log('clicked unitId according to data is: ', data['points'][0]['customdata']);
290- rows [ this . clickedUnitId ] . scrollIntoView ( {
291- behavior : 'smooth' ,
292- block : 'center' } ) ;
284+ for ( const [ ind , row ] of Object . entries ( rows ) ) {
285+
286+
287+ // console.log('row inner text is - ', row['innerText']);
288+ if ( this . clickedUnitId == row [ 'innerText' ] . split ( ' ' ) [ 0 ] ) {
289+ // console.log('row unit id is - ', row['innerText'].split(' ')[0]);
290+ const unitId = row [ 'innerText' ] . split ( ' ' ) [ 0 ] ;
291+ this . clickedUnitIndex = parseInt ( ind , 10 ) ;
292+ row . scrollIntoView ( {
293+ behavior : 'smooth' ,
294+ block : 'center'
295+ } ) ;
296+ }
297+
298+ }
299+
300+ // rows[this.clickedUnitId].scrollIntoView({
301+ // behavior: 'smooth',
302+ // block: 'center' });
293303 }
294304
295305 }
296306
297307 clusterSelectedTable ( unit_id ) {
298- // console.log('table row selected!')
299- const element = this . el_nav . nativeElement . children [ 1 ] ;
300- const rows = element . querySelectorAll ( 'tr' ) ;
301- this . clickedUnitId = unit_id ;
302- this . targetUnitId = this . clickedUnitId ;
308+
309+ for ( const [ index , unit ] of Object . entries ( this . cellsByProbeIns ) ) {
310+ if ( unit [ 'unit' ] === unit_id ) {
311+
312+ this . clickedUnitIndex = parseInt ( index , 10 ) ;
313+ this . clickedUnitId = unit_id ;
314+ }
315+ }
316+ // const element = this.el_nav.nativeElement.children[1];
317+ // const rows = element.querySelectorAll('tr');
318+ // this.clickedUnitId = unit_id;
303319
304320 }
305321
306322 navigate_cell_plots ( event , direction ) {
307- // console.log('navigation activated')
308- // let element = this.el_nav.nativeElement.children[1];
309- // let rows = element.querySelectorAll('tr');
310- // let HLrowID = element.querySelectorAll('#highlighted-row');
311- // console.log('element: ', element)
312- // console.log('rows: ', rows)
313- // console.log('highlighted id: ', HLrowID)
314- // console.log('highlighted id[0]: ', HLrowID[0])
315- // console.log('highlighted id[0] type: ', typeof HLrowID[0])
316- // console.log('highlighted id[0][outerText]: ', HLrowID[0]['outerText'])
317- // console.log('=============================')
318- // rows.forEach((row, index) => {
319- // if (row.id == 'highlighted-row') {
320- // console.log('highlighted row at index - ', index)
321- // console.log('highlighted row at rowindex - ', row['rowIndex'])
322- // console.log('unit - ', row['outerText'].split('')[2])
323- // }
324- // })
325-
326- // console.log('clickedUnitId before - ', this.clickedUnitId);
327323 if ( direction === 'up' ) {
328- if ( this . clickedUnitId - 1 > - 1 ) {
329- this . clickedUnitId -= 1 ;
330- this . targetUnitId = this . clickedUnitId ;
324+ if ( this . clickedUnitIndex - 1 > - 1 ) {
325+ this . clickedUnitIndex -= 1 ;
326+
331327 }
332- // console.log('clickedUnitId after - ', this.clickedUnitId);
333328 }
334329 if ( direction === 'down' ) {
335- if ( this . clickedUnitId + 1 < this . plot_data [ 0 ] [ 'x' ] . length + 1 ) {
336- this . clickedUnitId += 1 ;
337- this . targetUnitId = this . clickedUnitId ;
330+ if ( this . clickedUnitIndex + 1 < this . plot_data [ 0 ] [ 'x' ] . length + 1 ) {
331+ this . clickedUnitIndex += 1 ;
338332 }
339- // console.log('clickedUnitId after - ', this.clickedUnitId);
340333 }
334+ // console.log('this.cellsByProbeIns[this.clickedUnitId][unit]: ', this.cellsByProbeIns[this.clickedUnitIndex]['unit'])
335+ this . clickedUnitId = this . cellsByProbeIns [ this . clickedUnitIndex ] [ 'unit' ] ;
341336 }
342337
343338 // sortData(sort: Sort) {
0 commit comments