NPM
直接使用npm(或yarn)方式安装使用。
# 安装绘图引擎
npm install @topology/core
# 安装图形库 - 流程图
npm install @topology/flow-diagram
# 安装图形库 - 活动图
npm install @topology/activity-diagram
# 安装图形库 - 类图
npm install @topology/class-diagram
# 安装图形库 - 时序图
npm install @topology/sequence-diagram
# 其他共享图形库
# ...
# 集成打包版本
npm install topology-bundle
package.json参考
{
"name": "topology-demo",
"version": "0.0.1",
"description": "ES6 + Babel: The demo",
"main": "index.js",
"scripts": {
"build": "webpack"
},
"keywords": [
"es2018",
"webpack"
],
"author": "alsmile123@qq.com",
"license": "MIT",
"dependencies": {
"@topology/core": "^0.5.8",
"@topology/activity-diagram": "^0.3.0",
"@topology/class-diagram": "^0.3.0",
"@topology/flow-diagram": "^0.3.0",
"@topology/sequence-diagram": "^0.3.0",
"@topology/chart-diagram": "^0.3.0",
"@topology/layout": "^0.3.0"
},
"devDependencies": {
"@babel/core": "^7.5.5",
"@babel/plugin-transform-runtime": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"babel-loader": "^8.0.6",
"path": "^0.12.7",
"webpack": "^4.37.0",
"webpack-cli": "^3.3.6"
}
}
使用
// 先导入库
import { Topology, Options, registerNode } from '@topology/core';
import { register as registerFlow } from '@topology/flow-diagram';
import { register as registerActivity } from '@topology/activity-diagram';
import { register as registerClass } from '@topology/class-diagram';
import { register as registerSequence } from '@topology/sequence-diagram';
import { register as registerChart } from '@topology/chart-diagram';
// 注册图形库
canvasRegister() {
registerFlow();
registerActivity();
registerClass();
registerSequence();
registerChart();
// ... 其他图形库
}
canvasRegister();
注意,下面示例代码版本属于旧版本号,请参考上面用新版本号
es5使用示例:
https://github.com/le5le-com/topology-es5-demo
es6使用示例:
https://github.com/le5le-com/topology-demo-es6
typescript使用示例:
https://github.com/le5le-com/topology/tree/master/examples/angular/src/app