-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: Lineage render problem * Spotless Apply --------- Co-authored-by: leechor <[email protected]>
- Loading branch information
Showing
3 changed files
with
194 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import LineageDag from 'react-lineage-dag'; | ||
|
||
import * as _ from 'lodash'; | ||
import * as ReactDOM from 'react-dom'; | ||
import { transformEdges, transformInitData } from 'react-lineage-dag/src/adaptor'; | ||
import LineageCanvas from 'react-lineage-dag/src/canvas/canvas'; | ||
|
||
export default class LineageDagExt extends LineageDag { | ||
componentDidMount() { | ||
let root = ReactDOM.findDOMNode(this) as HTMLElement; | ||
|
||
let enableHoverChain = _.get(this.props, 'config.enableHoverChain', true); | ||
let titleRender = _.get(this.props, 'config.titleRender'); | ||
|
||
let canvasObj = { | ||
root: root, | ||
disLinkable: false, | ||
linkable: false, | ||
draggable: false, | ||
zoomable: true, | ||
moveable: true, | ||
theme: { | ||
edge: { | ||
type: 'endpoint', | ||
// shapeType: 'AdvancedBezier', | ||
arrow: true, | ||
isExpandWidth: true, | ||
arrowPosition: 1, | ||
arrowOffset: -5 | ||
}, | ||
endpoint: { | ||
limitNum: undefined, | ||
expandArea: { | ||
left: 0, | ||
right: 0, | ||
top: 0, | ||
botton: 0 | ||
} | ||
} | ||
}, | ||
data: { | ||
enableHoverChain: enableHoverChain | ||
} | ||
}; | ||
|
||
this.canvas = new LineageCanvas(canvasObj); | ||
|
||
let result = transformInitData({ | ||
tables: this.props.tables, | ||
relations: this.props.relations, | ||
columns: this.props.columns, | ||
operator: this.props.operator, | ||
_titleRender: titleRender, | ||
_enableHoverChain: enableHoverChain, | ||
_emptyContent: this.props.emptyContent, | ||
_emptyWidth: this.props.emptyWidth | ||
}); | ||
|
||
this.originEdges = result.edges; | ||
|
||
result = transformEdges(result.nodes, _.cloneDeep(result.edges)); | ||
this.canvasData = { | ||
nodes: result.nodes, | ||
edges: result.edges | ||
}; | ||
|
||
let minimap = _.get(this, 'props.config.minimap', {}); | ||
|
||
const minimapCfg = _.assign({}, minimap.config, { | ||
events: ['system.node.click', 'system.canvas.click'] | ||
}); | ||
|
||
if (minimap && minimap.enable) { | ||
this.canvas.setMinimap(true, minimapCfg); | ||
} | ||
|
||
if (_.get(this, 'props.config.gridMode')) { | ||
this.canvas.setGridMode(true, _.assign({}, _.get(this, 'props.config.gridMode', {}))); | ||
} | ||
|
||
if (result.nodes.length !== 0) { | ||
this.canvas.focusCenterWithAnimate(); | ||
this._isFirstFocus = true; | ||
} | ||
|
||
this.props.onLoaded && this.props.onLoaded(this.canvas); | ||
this.canvas.on('system.node.click', (data) => { | ||
let node = data.node; | ||
this.canvas.focus(node.id); | ||
}); | ||
this.canvas.on('system.canvas.click', () => { | ||
this.canvas.unfocus(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters