二维码

快速开始

安装

Github 下载

通过 giteegithub 下载前端图形开发引擎js文件,并添加至您的项目中。github下载地址:

gitee: https://gitee.com/graphanywhere/anygraph.js

github: https://github.com/graphanywhere/anygraph.js

使用包管理器

npm install anygraph(即将支持)

示例

显示基本形状

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE html>
<html>

<head>
<title>绘制基本图形(矩形)</title>
<meta charset="UTF-8">
</head>

<body style="margin:10px;">
<div id="graphWrapper" style="width:600px; height:200px; border:solid 1px #CCC;"></div>
</body>
<script type="module">
import { Graph, Rect } from "../../src/index.js";

// graph对象
let graph = new Graph({
"target": "graphWrapper"
});

// 新建绘图图层
let layer = graph.addLayer();

// 绘制矩形
layer.getSource().add(new Rect({ "x": 50, "y": 50, "width": 200, "height": 100, "style":{"lineWidth":4 , "color":"blue"} }));
layer.getSource().add(new Rect({ "x": 350, "y": 50, "width": 200, "height": 100, "rx":10, "ry":10, "style":{ "fillColor" : "#9FFFFF", "fillStyle":1, "lineWidth":4 , "color":"red" } }));

graph.render();
</script>

</html>

加载SVG数据

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE html>
<html>

<head>
<title>SVG</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">

<script type="module">
import { Graph, VectorSource, Layer, SvgFormat } from "../../src/index.js";

// graph对象
let graph = new Graph({
"target": "graphWrapper",
"layers": [
new Layer({
"source": new VectorSource({
"dataType": "xml",
"fileUrl": "../../data/tiger.svg",
"format": new SvgFormat()
})
})
]
});
</script>
</head>

<body style="margin:0px;">
<div id="graphWrapper" style="position:absolute; width:100%; height:100%;"></div>
</body>

</html>