Generates a folder at the given path containing an index.html that visualizes the graph using the HTML5 tag.
(self, path, overwrite=False, encoding="utf-8")
| 1429 | return self.data |
| 1430 | |
| 1431 | def export(self, path, overwrite=False, encoding="utf-8"): |
| 1432 | """ Generates a folder at the given path containing an index.html |
| 1433 | that visualizes the graph using the HTML5 <canvas> tag. |
| 1434 | """ |
| 1435 | if overwrite and os.path.exists(path): |
| 1436 | rmtree(path) |
| 1437 | os.mkdir(path) # With overwrite=False, raises OSError if the path already exists. |
| 1438 | os.mkdir(os.path.join(path, "js")) |
| 1439 | # Copy compressed graph.js + canvas.js (unless a custom path is given.) |
| 1440 | if self.javascript == "js/": |
| 1441 | for p, f in (("..", "canvas.js"), (".", "graph.js")): |
| 1442 | a = open(os.path.join(MODULE, p, f), "r") |
| 1443 | b = open(os.path.join(path, "js", f), "w") |
| 1444 | b.write(minify(a.read())) |
| 1445 | b.close() |
| 1446 | # Create style.css. |
| 1447 | if self.stylesheet == DEFAULT: |
| 1448 | f = open(os.path.join(path, "style.css"), "w") |
| 1449 | f.write(self.style) |
| 1450 | f.close() |
| 1451 | # Create index.html. |
| 1452 | f = open(os.path.join(path, "index.html"), "w", encoding=encoding) |
| 1453 | f.write(self.html) |
| 1454 | f.close() |
| 1455 | |
| 1456 | def render(graph, type=HTML, **kwargs): |
| 1457 | renderer = HTMLCanvasRenderer(graph) |