Open Source Go Library to Create & Customize Diagrams

Advanced Free Go Declarative Diagramming Library that Allows Software Developers to Create, Edit, Manipulate & Manage Various Typers of Diagrams and Convert Turns Text to Diagrams inside Go Apps.

What is D2 Library?

In software development, it’s crucial to use interactive diagrams and visuals to explain complex data to users. Declarative diagramming libraries are key in simplifying this process. These tools enable developers to create diagrams and visualizations using a straightforward method, making it simpler to construct and update interactive diagrams. An example of such a library is the D2 Go Declarative Diagramming Library, which provides a robust set of features and capabilities for this purpose. By simplifying the development process, improving code readability, and ensuring data consistency, these libraries empower software developers to focus on delivering meaningful data visualizations for their applications. The library handles rendering the diagram, managing interactions, and maintaining data accuracy. If you’re working on a project involving intricate diagrams or visualizations, you should check out the Go Declarative Diagramming Library.

The D2 library simplifies expressing your visualization ideas by offering a straightforward syntax for describing diagrams. It makes it easy for developers to communicate their visualization requirements. Declarative diagramming libraries are tools that help software developers make intricate diagrams and visualizations by simply describing what they want, instead of getting into the nitty-gritty of handling SVG elements and intricate code. D2, a user-friendly Go Declarative Diagramming Library, is a great choice for web developers who want to craft lively and interactive diagrams with ease. Whether you need to create flowcharts, network diagrams, or any other visual representation, this library is worth exploring.

Previous Next

Getting Started with D2

The recommend way to install D2 is using GitHub. Please use the following command for a smooth installation.

Install D2 Library via GitHub

go get https://github.com/terrastruct/d2.git
You can also download it directly from GibHub.

Generate New Diagram via GO Library

The open source G2 library makes it easy for software developers to generate and manage various types of Diagrams inside their own Go applications. Users can create diagrams within couple of mints. The library has included various methods for creating diagrams such as create diagrams from text, create and delete objects and connections, set attributes, and move objects to different containers, customize a diagram with ease, save diagrams in different images formats and so on. The following example demonstrates how to create a simple diagram inside Go applications.

How to Create a Diagram using Go Library?

# Actors
hans: Hans Niemann

defendants: {
  mc: Magnus Carlsen
  playmagnus: Play Magnus Group
  chesscom: Chess.com
  naka: Hikaru Nakamura

  mc -> playmagnus: Owns majority
  playmagnus <-> chesscom: Merger talks
  chesscom -> naka: Sponsoring
}

# Accusations
hans -> defendants: 'sueing for $100M'

# Claim
defendants.naka -> hans: Accused of cheating on his stream
defendants.mc -> hans: Lost then withdrew with accusations
defendants.chesscom -> hans: 72 page report of cheating	

Customize Diagrams inside Go Apps

The Open Source D2 library gives software developers the power to customize their diagrams according to their own needs. Developers can easily customize the appearance of diagram elements using CSS-like styling, allowing for complete control over the visual presentation. Moreover, the library supports a range of interactive features, such as tooltips, zooming, panning, and selection handling.

Add & Manage Shapes in Diagrams

The Open Source D2 library has provided complete support for handling various types of shapes inside their Go applications.The G2 library likely provides a clear and concise syntax for describing diagrams, making it easy for developers to express their visualization needs. The library supports adding, editing, labeling, deleting various types of shapes such as Square, rectangle, cloud, page, cylinder, diamond, hexagon, document, queue, circle and many more. Once the shapes are created users can use connectors to connect shapes. It is also supported to label the connections. The following example shows how different types of shape with their title are defined inside Go applications.

How to Create Shapes in a Diagram using Go Library?

pg: PostgreSQL
Cloud: my cloud
Cloud.shape: cloud
SQLite; Cassandra
 English