代码拉取完成,页面将自动刷新
English | 简体中文
Le5le-topology 是一个可视化在线绘图工具,使用 Canvas + Typescript。可以很方便的绘制各种如 topology, UML 等图;还可以很方便的分析微服务之间的关联关系、动态流量等。
- libs
|- topology // topogoly-core库源码
- src // 官网源码.
- demo // demo
import { Topology } from 'togology-core';
var canvas = new Topology('topo-dom', options);
canvas.render(data, true);
[Todo]
// 节点node绘图函数
export function diagram(ctx: CanvasRenderingContext2D, node: Node) {
ctx.beginPath();
// ...
ctx.fill();
ctx.stroke();
}
// [可选] 计算节点node图标区域,默认使用矩形相关函数.
export function diagramIconRect(node: Node) {
let w = node.rect.width / 3;
let h = node.rect.height / 3;
if (w > h) {
w = h;
} else {
h = w;
}
let top = node.rect.width / 5;
if (top < 10) {
top = 10;
}
node.iconRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + top, w, h);
}
// [可选] 计算节点node文字区域,默认使用矩形相关函数.
// fullTextRect - Only text.
// iconTextRect - Incloud icon and text.
export function diagramTextRect(node: Node) {
let bottom = node.rect.height / 10;
if (bottom < 5) {
bottom = 0;
}
node.iconTextRect = new Rect(
node.rect.x + node.rect.width / 3,
node.rect.y + (node.rect.height * 2) / 3 - bottom,
node.rect.width / 3,
node.rect.height / 3 - 5
);
const w = node.rect.width / 2;
const h = (node.rect.height * 1) / 2;
node.fullTextRect = new Rect(node.rect.x + (node.rect.width - w) / 2, node.rect.y + node.rect.height / 4, w, h);
}
// [可选] 计算节点node可连线的锚点,默认使用矩形相关函数.
export function diagramAnchors(node: Node) {
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y, Direction.Up));
node.anchors.push(new Point(node.rect.x + node.rect.width, node.rect.y + node.rect.height / 2, Direction.Right));
node.anchors.push(new Point(node.rect.x + node.rect.width / 2, node.rect.y + node.rect.height, Direction.Bottom));
node.anchors.push(new Point(node.rect.x, node.rect.y + node.rect.height / 2, Direction.Left));
}
// registerNode: Register a custom node.
// name - The name of node.
// drawFn - How to draw.
// anchorsFn - How to get the anchors.
// iconRectFn - How to get the icon rect.
// textRectFn - How to get the text rect.
// force - Overwirte the node if exists.
registerNode(
name: string,
drawFn: (ctx: CanvasRenderingContext2D, node: Node) => void,
anchorsFn?: (node: Node) => void,
iconRectFn?: (node: Node) => void,
textRectFn?: (node: Node) => void,
force?: boolean
);
在线画图官网 前端源码
$ cd topology
$ yarn or npm install
$ cd topology/libs/topology-activity-diagram
$ yarn or npm install
$ cd topology/libs/topology-class-diagram
$ yarn or npm install
$ cd topology/libs/topology-flow-diagram
$ yarn or npm install
$ cd topology/libs/topology-sequence-diagram
$ yarn or npm install
# build watching file changes and run angular project
$ npm start
# build
$ npm run build
核心库源码
[libs/topology#] yarn or npm install
# build
[libs/topology#] npm run build
流程图源码
[libs/topology#] yarn or npm install
# build
[libs/topology-flow-diagram#] npm run build
demo 源码
[demo#] yarn or npm install
# build
[demo#] npm run build
有任何建议或问题可以在 issue 提出;或提供一个 pr。
MIT © le5le.com
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。