11import {
22 constants ,
3+ getDefaultPlugins ,
34 Graph ,
5+ GraphDataModel ,
46 InternalEvent ,
57 Perimeter ,
68 RubberBandHandler ,
@@ -11,9 +13,14 @@ export const initializeGraph = (container: HTMLElement) => {
1113 // Disables the built-in context menu
1214 InternalEvent . disableContextMenu ( container ) ;
1315
14- const graph = new Graph ( container ) ;
16+ const graph = new Graph ( container , new GraphDataModel ( ) , [
17+ ...getDefaultPlugins ( ) ,
18+ RubberBandHandler , // Enables rubber band selection
19+ ] ) ;
1520 graph . setPanning ( true ) ; // Use mouse right button for panning
16- new RubberBandHandler ( graph ) ; // Enables rubber band selection
21+
22+ // Customize the rubber band selection
23+ graph . getPlugin < RubberBandHandler > ( 'RubberBandHandler' ) . fadeOut = true ;
1724
1825 // shapes and styles
1926 registerCustomShapes ( ) ;
@@ -66,7 +73,7 @@ export const initializeGraph = (container: HTMLElement) => {
6673 value : 'a custom rectangle' ,
6774 position : [ 20 , 200 ] ,
6875 size : [ 100 , 100 ] ,
69- style : { shape : 'customRectangle' } ,
76+ style : { shape : 'customRectangle' } ,
7077 } ) ;
7178 // use the new insertVertex method using position and size parameters
7279 const vertex12 = graph . insertVertex ( {
@@ -87,7 +94,7 @@ export const initializeGraph = (container: HTMLElement) => {
8794 value : 'another edge' ,
8895 source : vertex11 ,
8996 target : vertex12 ,
90- style : { endArrow : 'block' } ,
97+ style : { endArrow : 'block' } ,
9198 } ) ;
9299 } ) ;
93100}
0 commit comments