You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

77 lines
9.7 KiB

  1. <!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>Installation · Diagrams</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="It uses [Graphviz](https://www.graphviz.org/) to render the diagram, so you need to [install Graphviz](https://graphviz.gitlab.io/download/) to use **diagrams**. After installing graphviz (or already have it), install the **diagrams**."/><meta name="docsearch:language" content="en"/><meta property="og:title" content="Installation · Diagrams"/><meta property="og:type" content="website"/><meta property="og:url" content="https://diagrams.mingrammer.com/"/><meta property="og:description" content="It uses [Graphviz](https://www.graphviz.org/) to render the diagram, so you need to [install Graphviz](https://graphviz.gitlab.io/download/) to use **diagrams**. After installing graphviz (or already have it), install the **diagrams**."/><meta property="og:image" content="https://diagrams.mingrammer.com/img/diagrams.png"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://diagrams.mingrammer.com/img/diagrams.png"/><link rel="shortcut icon" href="/img/diagrams.ico"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/diagrams.ico" alt="Diagrams"/><h2 class="headerTitleWithLogo">Diagrams</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class="siteNavGroupActive siteNavItemActive"><a href="/docs/installation" target="_self">Docs</a></li><li class="siteNavGroupActive"><a href="/docs/diagram" target="_self">Guides</a></li><li class=""><a href="https://github.com/mingrammer/diagrams" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="docsNavContainer" id="docsNav"><nav class="toc"><div class="toggleNav"><section class="navWrapper wrapper"><div class="navBreadcrumb wrapper"><div class="navToggle" id="navToggler"><div class="hamburger-menu"><div class="line1"></div><div class="line2"></div><div class="line3"></div></div></div><h2><i>›</i><span>Getting Started</span></h2><div class="tocToggler" id="tocToggler"><i class="icon-toc"></i></div></div><div class="navGroups"><div class="navGroup"><h3 class="navGroupCategoryTitle">Getting Started</h3><ul class=""><li class="navListItem navListItemActive"><a class="navItem" href="/docs/installation">Installation</a></li><li class="navListItem"><a class="navItem" href="/docs/examples">Examples</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Guides</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/diagram">Diagrams</a></li><li class="navListItem"><a class="navItem" href="/docs/node">Nodes</a></li><li class="navListItem"><a class="navItem" href="/docs/cluster">Clusters</a></li></ul></div></div></section></div><script>
  2. var coll = document.getElementsByClassName('collapsible');
  3. var checkActiveCategory = true;
  4. for (var i = 0; i < coll.length; i++) {
  5. var links = coll[i].nextElementSibling.getElementsByTagName('*');
  6. if (checkActiveCategory){
  7. for (var j = 0; j < links.length; j++) {
  8. if (links[j].classList.contains('navListItemActive')){
  9. coll[i].nextElementSibling.classList.toggle('hide');
  10. coll[i].childNodes[1].classList.toggle('rotate');
  11. checkActiveCategory = false;
  12. break;
  13. }
  14. }
  15. }
  16. coll[i].addEventListener('click', function() {
  17. var arrow = this.childNodes[1];
  18. arrow.classList.toggle('rotate');
  19. var content = this.nextElementSibling;
  20. content.classList.toggle('hide');
  21. });
  22. }
  23. document.addEventListener('DOMContentLoaded', function() {
  24. createToggler('#navToggler', '#docsNav', 'docsSliderActive');
  25. createToggler('#tocToggler', 'body', 'tocActive');
  26. var headings = document.querySelector('.toc-headings');
  27. headings && headings.addEventListener('click', function(event) {
  28. var el = event.target;
  29. while(el !== headings){
  30. if (el.tagName === 'A') {
  31. document.body.classList.remove('tocActive');
  32. break;
  33. } else{
  34. el = el.parentNode;
  35. }
  36. }
  37. }, false);
  38. function createToggler(togglerSelector, targetSelector, className) {
  39. var toggler = document.querySelector(togglerSelector);
  40. var target = document.querySelector(targetSelector);
  41. if (!toggler) {
  42. return;
  43. }
  44. toggler.onclick = function(event) {
  45. event.preventDefault();
  46. target.classList.toggle(className);
  47. };
  48. }
  49. });
  50. </script></nav></div><div class="container mainContainer docsContainer"><div class="wrapper"><div class="post"><header class="postHeader"><h1 id="__docusaurus" class="postHeaderTitle">Installation</h1></header><article><div><span><p>It uses <a href="https://www.graphviz.org/">Graphviz</a> to render the diagram, so you need to <a href="https://graphviz.gitlab.io/download/">install Graphviz</a> to use <strong>diagrams</strong>. After installing graphviz (or already have it), install the <strong>diagrams</strong>.</p>
  51. <pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> pip install diagrams</span>
  52. </code></pre>
  53. <h2><a class="anchor" aria-hidden="true" id="quick-start"></a><a href="#quick-start" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Quick Start</h2>
  54. <pre><code class="hljs css language-python"><span class="hljs-comment"># diagram.py</span>
  55. <span class="hljs-keyword">from</span> diagrams <span class="hljs-keyword">import</span> Diagram
  56. <span class="hljs-keyword">from</span> diagrams.aws.compute <span class="hljs-keyword">import</span> EC2
  57. <span class="hljs-keyword">from</span> diagrams.aws.database <span class="hljs-keyword">import</span> RDS
  58. <span class="hljs-keyword">from</span> diagrams.aws.network <span class="hljs-keyword">import</span> ELB
  59. <span class="hljs-keyword">with</span> Diagram(<span class="hljs-string">"Web Service"</span>, show=<span class="hljs-literal">False</span>):
  60. ELB(<span class="hljs-string">"lb"</span>) &gt;&gt; EC2(<span class="hljs-string">"web"</span>) &gt;&gt; RDS(<span class="hljs-string">"userdb"</span>)
  61. </code></pre>
  62. <p>This code generates below diagram.</p>
  63. <pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> python diagram.py</span>
  64. </code></pre>
  65. <p><img src="/img/web_service_diagram.png" alt="web service diagram"></p>
  66. <p>It will be saved as <code>web_service.png</code> on your working directory.</p>
  67. <h2><a class="anchor" aria-hidden="true" id="next"></a><a href="#next" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Next</h2>
  68. <p>See more <a href="/docs/examples">Examples</a> or see <a href="/docs/diagram">Guides</a> page for more details.</p>
  69. </span></div></article></div><div class="docLastUpdate"><em>Last updated on 2020-2-3</em></div><div class="docs-prevnext"><a class="docs-next button" href="/docs/examples"><span>Examples</span><span class="arrow-next"> →</span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#quick-start">Quick Start</a></li><li><a href="#next">Next</a></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><a href="/" class="nav-home"><img src="/img/diagrams.ico" alt="Diagrams" width="66" height="58"/></a><div><h5>Docs</h5><a href="/docs/en/installation">Getting Started</a><a href="/docs/en/diagram">Guides</a></div><div><h5>More</h5><a href="https://github.com/mingrammer/diagrams">GitHub</a><a class="github-button" data-icon="octicon-star" data-count-href="/mingrammer/diagrams/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star this project on GitHub">Star</a></div></section><section class="copyright">Copyright © 2020 mingrammer</section></footer></div></body></html>