import { IGroup , IShape } from '@antv/g-base' ; import { deepMix } from '@antv/util' ; import { Item , NodeConfig , ShapeStyle , UpdateType } from '../../types' ; import Global from '../../global' ; import Shape from '../shape' ; import { ShapeOptions } from '../../interface/shape' ; Shape . registerNode ( 'simple-circle' , { options : { size : Global . defaultNode . size , style : { x : 0 , y : 0 , stroke : Global . defaultNode . style . stroke , fill : Global . defaultNode . style . fill , lineWidth : Global . defaultNode . style . lineWidth , } , labelCfg : { style : { fill : Global . nodeLabel . style . fill , fontSize : Global . nodeLabel . style . fontSize , fontFamily : Global . windowFontFamily } , } , stateStyles : { ... Global . nodeStateStyles , } , } , shapeType : 'simple-circle' , labelPosition : 'center' , shapeMap : { } , drawShape ( cfg , group ) { const style = this . getShapeStyle ! ( cfg ) ; const name = `${ this . type }-keyShape` ; const keyShape = group . addShape ( 'circle' , { attrs : style , className : `${ this . type }-keyShape` , name , draggable : true , } ) ; group [ 'shapeMap' ] [ name ] = keyShape ; return keyShape ; } , param { Object } cfg return { Object } getShapeStyle ( cfg ) { const { style : defaultStyle } = this . mergeStyle || this . getOptions ( cfg ) as NodeConfig ; const strokeStyle = { stroke : cfg . color , } ; const style = deepMix ( { } , defaultStyle , strokeStyle ) ; const size = ( this as ShapeOptions ) . getSize ! ( cfg ) ; const r = size [ 0 ] / 2 ; const styles = { x : 0 , y : 0 , r , ... style , } ; return styles ; } , update ( cfg , item , updateType ? ) { const size = ( this as ShapeOptions ) . getSize ! ( cfg ) ; const strokeStyle = { stroke : cfg . color , r : size [ 0 ] / 2 , } ; const keyShape = item . get ( 'keyShape' ) ; const style = deepMix ( { } , keyShape . attr ( ) , strokeStyle , cfg . style ) ; ( this as any ) . updateShape ( cfg , item , style , true , updateType ) ; } , } , 'single-node' ) ;