二维码

加载Geom数据

运行效果

以下为加载 Geom 数据的运行效果:

源代码

以下为加载 Geom 数据的源代码:

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
32
33
34
35
36
37
<!DOCTYPE html>
<html>

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

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

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

// 显示辅助网格
BgUtil.generateGrid(Object.assign({ "interval": 10, "graph": graph }, graph.getSize()));

// 数据层
let currentLayer = graph.addLayer({ "name": "数据层" });
currentLayer.getSource().loadData([
{ "type": "Polygon", "coords": [[1, 1], [161, 1], [81, 81]], "style": { "fillStyle": 1, "fillColor": "#caff67" } },
{ "type": "Polygon", "coords": [[1, 2], [81, 82], [1, 162]], "style": { "fillStyle": 1, "fillColor": "#67becf" } },
{ "type": "Polygon", "coords": [[162, 1], [162, 81], [122, 121], [122, 41]], "style": { "fillStyle": 1, "fillColor": "#ef3d61" } },
{ "type": "Polygon", "coords": [[121, 42], [121, 122], [81, 82]], "style": { "fillStyle": 1, "fillColor": "#f9f51a" } },
{ "type": "Polygon", "coords": [[82, 82], [122, 122], [82, 162], [42, 122]], "style": { "fillStyle": 1, "fillColor": "#a54c09" } },
{ "type": "Polygon", "coords": [[42, 122], [82, 162], [2, 162]], "style": { "fillStyle": 1, "fillColor": "#fa8ccc" } },
{ "type": "Polygon", "coords": [[162, 82], [162, 162], [82, 162]], "style": { "fillStyle": 1, "fillColor": "#f6ca29" } }
]);
</script>
</head>

<body style="margin:0px;" oncontextmenu="return false;">
<div id="graphWrapper" style="position:absolute; width:100%; height:100%; border:solid 0px #CCC;"></div>
</body>

</html>