11import { csv } from "./export" ;
22import * as model from "../model" ;
3+ import { onSelectionUpdate , updateSelection } from "../selection" ;
34
45var graph ;
56
6- export function updateSelectedNodes ( ) {
7- if ( ! model . uiState . tableToggled )
7+ onSelectionUpdate ( ( selection ) => {
8+ if ( ! model . uiState . tabularToggled )
89 return ;
9- let data = graph . nodes . filter ( node => ! ! node . selected ) . sort ( ( a , b ) =>
10+ let data = selection . sort ( ( a , b ) =>
1011 a . entities [ 0 ] . score > b . entities [ 0 ] . score ? - 1 : 1
1112 ) ,
1213 table = document . querySelector ( "#table table tbody" ) ;
@@ -20,7 +21,7 @@ export function updateSelectedNodes () {
2021 row . insertCell ( 3 ) . textContent = node . entities [ 0 ] . frequency ;
2122 row . insertCell ( 4 ) . textContent = node . entities [ 0 ] . spread ;
2223 }
23- }
24+ } ) ;
2425
2526export function init ( ) {
2627
@@ -29,10 +30,10 @@ export function init () {
2930 d3 . select ( "#tableToggle" )
3031 . data ( [ model . uiState ] )
3132 . on ( "click" , function ( d ) {
32- d . tableToggled = ! d . tableToggled ;
33- d3 . select ( this ) . classed ( "toggled" , d . tableToggled ) ;
34- d3 . select ( "#table" ) . classed ( "active" , d . tableToggled ) ;
35- updateSelectedNodes ( ) ;
33+ d . tabularToggled = ! d . tabularToggled ;
34+ d3 . select ( this ) . classed ( "toggled" , d . tabularToggled ) ;
35+ d3 . select ( "#table" ) . classed ( "active" , d . tabularToggled ) ;
36+ updateSelection ( ) ;
3637 } ) ;
3738
3839 d3 . select ( "#exportCSV" ) . on ( "click" , ( ) => {
0 commit comments