No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

custom.md 2.7 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. ---
  2. id: custom
  3. title: Custom
  4. ---
  5. ## Custom with local icons
  6. For this example we use the following architecture:
  7. ```
  8. .
  9. ├── custom_local.py
  10. ├── my_resources
  11. │ ├── cc_heart.black.png
  12. │ ├── cc_attribution.png
  13. │ ├──...
  14. ```
  15. The content of custom_local.py file:
  16. ```python
  17. from diagrams import Diagram, Cluster
  18. from diagrams.custom import Custom
  19. with Diagram("Custom with local icons\n Can be downloaded here: \nhttps://creativecommons.org/about/downloads/", show=False, filename="custom_local", direction="LR"):
  20. cc_heart = Custom("Creative Commons", "./my_resources/cc_heart.black.png")
  21. cc_attribution = Custom("Credit must be given to the creator", "./my_resources/cc_attribution.png")
  22. cc_sa = Custom("Adaptations must be shared\n under the same terms", "./my_resources/cc_sa.png")
  23. cc_nd = Custom("No derivatives or adaptations\n of the work are permitted", "./my_resources/cc_nd.png")
  24. cc_zero = Custom("Public Domain Dedication", "./my_resources/cc_zero.png")
  25. with Cluster("Non Commercial"):
  26. non_commercial = [Custom("Y", "./my_resources/cc_nc-jp.png") - Custom("E", "./my_resources/cc_nc-eu.png") - Custom("S", "./my_resources/cc_nc.png")]
  27. cc_heart >> cc_attribution
  28. cc_heart >> non_commercial
  29. cc_heart >> cc_sa
  30. cc_heart >> cc_nd
  31. cc_heart >> cc_zero
  32. ```
  33. It will generate the following diagram:
  34. ![custom local](/img/custom_local.png)
  35. ## Custom with remote icons
  36. If your icons are hosted and can be accessed when you generate the diagrams, you can
  37. ```python
  38. from diagrams import Diagram, Cluster
  39. from diagrams.custom import Custom
  40. from urllib.request import urlretrieve
  41. with Diagram("Custom with remote icons", show=False, filename="custom_remote", direction="LR"):
  42. # download the icon image file
  43. diagrams_url = "https://github.com/mingrammer/diagrams/raw/master/assets/img/diagrams.png"
  44. diagrams_icon = "diagrams.png"
  45. urlretrieve(diagrams_url, diagrams_icon)
  46. diagrams = Custom("Diagrams", diagrams_icon)
  47. with Cluster("Some Providers"):
  48. openstack_url = "https://github.com/mingrammer/diagrams/raw/master/resources/openstack/openstack.png"
  49. openstack_icon = "openstack.png"
  50. urlretrieve(openstack_url, openstack_icon)
  51. openstack = Custom("OpenStack", openstack_icon)
  52. elastic_url = "https://github.com/mingrammer/diagrams/raw/master/resources/elastic/saas/elastic.png"
  53. elastic_icon = "elastic.png"
  54. urlretrieve(elastic_url, elastic_icon)
  55. elastic = Custom("Elastic", elastic_icon)
  56. diagrams >> openstack
  57. diagrams >> elastic
  58. ```
  59. It will generate the following diagram:
  60. ![custom local](/img/custom_remote.png)
  61. Another example can be found [Here](https://diagrams.mingrammer.com/docs/getting-started/examples#rabbitmq-consumers-with-custom-nodes).