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 38 39 40 41 42 43 44 45 46 47 48
| <!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, BgUtil } from "../../src/index.js";
let fileUrl = "/asset/data/tiger.svg";
let graph = new Graph({ "target": "graphWrapper", "layers": [ new Layer({ "source": new VectorSource({ "dataType": "xml", "fileUrl": fileUrl, "format": new SvgFormat({ "ready": function (result) { let viewBox = result.document.viewBox; if (viewBox != null && viewBox.length > 0) { if (viewBox.length === 4) { graph.showExtent(viewBox); } } else { graph.render(); } } }) }) }) ] });
BgUtil.generateGrid(Object.assign({ "interval": 10, "graph": graph }, graph.getSize())); </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>
|