forked from fex-team/kityminder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
106 additions
and
0 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,12 @@ | ||
/** | ||
* @fileOverview | ||
* | ||
* 鱼骨头主干连线 | ||
* | ||
* @author: techird | ||
* @copyright: Baidu FEX, 2014 | ||
*/ | ||
|
||
KityMinder.registerConnectProvider('fish-bone-master', function(node, parent, connection) { | ||
|
||
}); |
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,57 @@ | ||
/** | ||
* @fileOverview | ||
* | ||
* 鱼骨图主骨架布局 | ||
* | ||
* @author: techird | ||
* @copyright: Baidu FEX, 2014 | ||
*/ | ||
/* global Layout:true */ | ||
KityMinder.registerLayout('fish-bone-master', kity.createClass('FishBoneMasterLayout', { | ||
base: Layout, | ||
|
||
doLayout: function(parent, children) { | ||
var upPart = [], | ||
downPart = []; | ||
|
||
var child = children[0]; | ||
var pBox = parent.getContentBox(); | ||
|
||
parent.setVertexOut(new kity.Point(pBox.right, pBox.cy)); | ||
parent.setLayoutVectorOut(new kity.Vector(1, 0)); | ||
|
||
if (!child) return; | ||
|
||
var pMarginRight = parent.getStyle('margin-right'); | ||
var cMarginLeft = child.getStyle('margin-left'); | ||
var cMarginTop = child.getStyle('margin-top'); | ||
var cMarginBottom = child.getStyle('margin-bottom'); | ||
|
||
children.forEach(function(child, index) { | ||
child.setLayoutTransform(new kity.Matrix()); | ||
var cBox = child.getContentBox(); | ||
|
||
if (index % 2) { | ||
downPart.push(child); | ||
child.setVertexIn(new kity.Point(cBox.left, cBox.top)); | ||
child.setLayoutVectorIn(new kity.Vector(cMarginLeft, cMarginTop)); | ||
} | ||
else { | ||
upPart.push(child); | ||
child.setVertexIn(new kity.Point(cBox.left, cBox.bottom)); | ||
child.setLayoutVectorIn(new kity.Vector(1, -1)); | ||
} | ||
|
||
}); | ||
|
||
this.stack(upPart, 'x'); | ||
this.stack(downPart, 'x'); | ||
|
||
this.align(upPart, 'bottom'); | ||
this.align(downPart, 'top'); | ||
|
||
this.move(upPart, pMarginRight + cMarginLeft, -cMarginBottom); | ||
this.move(downPart, pMarginRight + cMarginLeft + cMarginLeft, +cMarginTop); | ||
|
||
} | ||
})); |
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,35 @@ | ||
/** | ||
* @fileOverview | ||
* | ||
* 默认模板 - 鱼骨头模板 | ||
* | ||
* @author: techird | ||
* @copyright: Baidu FEX, 2014 | ||
*/ | ||
|
||
KityMinder.registerTemplate('fish-bone', { | ||
|
||
getLayout: function(node) { | ||
|
||
if (node.getData('layout')) return node.getData('layout'); | ||
|
||
var level = node.getLevel(); | ||
|
||
// 根节点 | ||
if (level === 0) { | ||
return 'fish-bone-master'; | ||
} | ||
|
||
// 一级节点 | ||
if (level === 1) { | ||
return 'right'; | ||
} | ||
|
||
return node.parent.getLayout(); | ||
}, | ||
|
||
// getConnect: function(node) { | ||
// if (node.getLevel() == 1) return 'arc'; | ||
// return 'under'; | ||
// } | ||
}); |