1- import { Entity , Model , IEntityDatum } from '@alephdata/followthemoney'
1+ import { defaultModel , Entity , Model , IEntityDatum } from '@alephdata/followthemoney'
22import { forceSimulation , forceLink , forceCollide } from 'd3-force' ;
33import { DraggableEvent } from 'react-draggable' ;
44import { Vertex } from './Vertex'
@@ -31,12 +31,12 @@ export class GraphLayout {
3131 selection = new Array < string > ( )
3232 private hasDraggedSelection = false
3333
34- constructor ( config : GraphConfig , model : Model ) {
34+ constructor ( config : GraphConfig ) {
3535 this . config = config
36- this . model = model
36+ this . model = new Model ( defaultModel ) ;
3737
38- this . addVertex = this . addVertex . bind ( this )
39- this . addEdge = this . addEdge . bind ( this )
38+ this . addVertex = this . addVertex . bind ( this ) ;
39+ this . addEdge = this . addEdge . bind ( this ) ;
4040 this . addEntity = this . addEntity . bind ( this ) ;
4141 this . removeEntity = this . removeEntity . bind ( this ) ;
4242 this . isGroupingSelected = this . isGroupingSelected . bind ( this ) ;
@@ -153,11 +153,11 @@ export class GraphLayout {
153153 }
154154
155155 selectVerticesByFilter ( predicate : VertexPredicate ) {
156- this . selection = this . getVertices ( ) . filter ( predicate ) . map ( ( v ) => v . id )
156+ this . selection = this . getVertices ( ) . filter ( ( vertex ) => ! vertex . isHidden ( ) ) . filter ( predicate ) . map ( ( v ) => v . id )
157157 }
158158
159159 selectArea ( area : Rectangle ) {
160- const selected = this . getVertices ( ) . filter ( ( vertex ) => area . contains ( vertex . position ) )
160+ const selected = this . getVertices ( ) . filter ( ( vertex ) => ! vertex . isHidden ( ) && area . contains ( vertex . position ) )
161161 this . selection = selected . map ( ( vertex ) => vertex . id )
162162 }
163163
@@ -376,7 +376,7 @@ export class GraphLayout {
376376 }
377377
378378 update ( withData :IGraphLayoutData ) :GraphLayout {
379- return GraphLayout . fromJSON ( this . config , this . model , withData )
379+ return GraphLayout . fromJSON ( this . config , withData )
380380 }
381381
382382 toJSON ( ) : IGraphLayoutData {
@@ -389,11 +389,11 @@ export class GraphLayout {
389389 }
390390 }
391391
392- static fromJSON ( config : GraphConfig , model : Model , data : any ) : GraphLayout {
392+ static fromJSON ( config : GraphConfig , data : any ) : GraphLayout {
393393 const layoutData = data as IGraphLayoutData
394- const layout = new GraphLayout ( config , model )
394+ const layout = new GraphLayout ( config )
395395 layoutData . entities . forEach ( ( edata ) => {
396- layout . entities . set ( edata . id , model . getEntity ( edata ) )
396+ layout . entities . set ( edata . id , layout . model . getEntity ( edata ) )
397397 } )
398398 layoutData . vertices . forEach ( ( vdata ) => {
399399 const vertex = Vertex . fromJSON ( layout , vdata )
0 commit comments