gojs实现可拖动编辑任务工作看板效果代码
代码语言:html
所属分类:图表
代码描述:gojs实现可拖动编辑任务工作看板效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<script src="//repo.bfw.wiki/bfwrepo/js/go.js"></script>
<div id="allSampleContent" class="p-4 w-full">
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700" rel="stylesheet" type="text/css">
<script id="code">
// define a custom grid layout that makes sure the length of each lane is the same
// and that each lane is broad enough to hold its subgraph
class PoolLayout extends go.GridLayout {
constructor() {
super();
this.MINLENGTH = 200; // this controls the minimum length of any swimlane
this.MINBREADTH = 100; // this controls the minimum breadth of any non-collapsed swimlane
this.cellSize = new go.Size(1, 1);
this.wrappingColumn = Infinity;
this.wrappingWidth = Infinity;
this.spacing = new go.Size(0, 0);
this.alignment = go.GridLayout.Position;
}
doLayout(coll) {
const diagram = this.diagram;
if (diagram === null) return;
diagram.startTransaction("PoolLayout");
// make sure all of the Group Shapes are big enough
const minlen = this.computeMinPoolLength();
diagram.findTopLevelGroups().each(lane => {
if (!(lane instanceof go.Group)) return;
const shape = lane.selectionObject;
if (shape !== null) { // change the desiredSize to be big enough in both directions
const sz = this.computeLaneSize(lane);
shape.width = (!isNaN(shape.width)) ? Math.max(shape.width, sz.width) : sz.width;
// if you want the height of all of the lanes to shrink as the maximum needed height decreases:
shape.height = minlen;
// if you want the height of all of the lanes to remain at the maximum height ever needed:
//shape.height = (isNaN(shape.height) ? minlen : Math.max(shape.height, minlen));
const cell = lane.resizeCellSize;
if (!isNaN(shape.width) && !isNaN(cell.width) && cell.width > 0) shape.width = Math.ceil(shape.width / cell.width) * cell.width;
if (!isNaN(shape.height) && !isNaN(cell.height) && cell.height > 0) shape.height = Math.ceil(shape.height / cell.height) * cell.height;
}
});
// now do all of the usual stuff, according to whatever properties have been set on this GridLayout
super.doLayout(coll);
diagram.commitTransaction("PoolLayout");
};
// compute the minimum length of the whole diagram needed to hold all of the Lane Groups
computeMinPoolLength() {
let len = this.MINLENGTH;
myDiagram.findTopLevelGroups().each(lane => {
const holder = lane.placeholder;
if (holder !== null) {
const sz = holder.actualBounds;
len = Math.max(len, sz.height);
}
});
return len;
}
// compute the minimum size for a particular Lane Group
computeLaneSize(lane) {
// assert(lane instanceof go.Group);
const sz = new go.Size(lane.isSubGraphExpanded ? this.MINBREADTH : 1, this.MINLENGTH);
if (lane.isSubGraphExpanded) {
const holder = lane.placeholder;
if (holder !== null) {
const hsz = holder.actualBounds;
sz.width = Math.max(sz.width, hsz.width);
}
}
// minimum breadth needs to be big enough to hold the header
const hdr = lane.findObject("HEADER");
if (hdr !== null) sz.width = Math.max(sz.width, hdr.actualBounds.width);
return sz;
}
}
// end PoolLayout class
function init() {
// Since 2.2 you can.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0