08-27-周三_17-09-29
This commit is contained in:
28
node_modules/dagre-layout/lib/position/index.js
generated
vendored
Normal file
28
node_modules/dagre-layout/lib/position/index.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import _ from 'lodash'
|
||||
|
||||
import util from '../util'
|
||||
import { positionX } from './bk'
|
||||
|
||||
function position (g) {
|
||||
g = util.asNonCompoundGraph(g)
|
||||
|
||||
positionY(g)
|
||||
_.forEach(positionX(g), function (x, v) {
|
||||
g.node(v).x = x
|
||||
})
|
||||
}
|
||||
|
||||
function positionY (g) {
|
||||
const layering = util.buildLayerMatrix(g)
|
||||
const rankSep = g.graph().ranksep
|
||||
let prevY = 0
|
||||
_.forEach(layering, function (layer) {
|
||||
const maxHeight = _.max(_.map(layer, function (v) { return g.node(v).height }))
|
||||
_.forEach(layer, function (v) {
|
||||
g.node(v).y = prevY + maxHeight / 2
|
||||
})
|
||||
prevY += maxHeight + rankSep
|
||||
})
|
||||
}
|
||||
|
||||
export default position
|
Reference in New Issue
Block a user