Introduction
In this article, we will explore the basics of GoJS. We will learn the basics because I have written this article focusing on beginners. Also, we will discuss how we use GoJS with ASP.NET.
- Learn GoJS From Beginning - Part One
- Learn GoJS From Beginning - Part Two
- Learn GoJS From Beginning - Part Three
- Learn GoJS From Beginning - Part Four
- Learn GoJS From Beginning - Part Five
Prerequisites
We should have a basic knowledge of HTML and JavaScript.
Any version of Visual Studio should be installed. I recommend you use Visual Studio 2015.
GOJS
GoJS is a JavaScript library for creating custom diagrams, flowcharts, trees, and complex visualizations across all modern web browsers and technology platforms. GoJS provides many advanced features for users. GoJS is completely written in Javascript, so it's easy for developers to Understand and Implement in projects.
We can integrate GoJS in any JavaScript framework like jQuery, AngularJS, or any other JavaScript Framework.
GoJS provides a powerful solution to develop a diagram, modeling, and visualization application. By using GoJS, it’s possible to create user-friendly web applications allowing end-users to construct complex diagrams.
GoJS is used to create your inherent diagrams. It's created and maintained by
Northwoods Software. Northwoods Software was founded in 1994 with a vision to provide graphical user interfaces(GUI) to the Companies and customers. Northwoods launched GoJS IN 2012.
GoJS makes constructing JavaScript diagrams of complex nodes, links, and groups easy with customizable templates and layouts.
It runs completely in the web browsers. There is no need to contact the server.
GoJS is not depended on any third party library
Using GoJS, we can create flowcharts, trees, organizational diagrams, industry specified visualizations etc.
GoJS Classes
- Diagram Classes
- Model Classes
- Collection Classes
- Layout Classes
- Geometry Classes
Diagram Classes |
Model Classes |
Collection Classes |
Geometry Classes |
Diagram |
Binding |
Map |
Size |
Link |
Model |
List |
Spot |
Node |
Transaction |
Set |
Rect |
Shape |
ChangedEvent |
Iterator |
Margin |
TextBlock |
TreeModel |
Iterable |
Geometry |
Step 1
First, we need to include GoJS Library in our project. For this, we can download the library from the GoJS official website or download it from
here.
Or we can add using NPM (Node Package Manager) using this command: $ npm install gojs --save
We also include this library using Nuget: PM>install-package Northwoods.GoJS
We can also add it from GitHub Repository from
GitHub.
Step 2
Add a new item to the project.
Step 3
Add new web form and rename it as GojsDemo1.
Step 4
Now, add the GoJS library in the Head section by simply dragging from the script folder and dropping it on the page.
Step 5
Now, add a div and rename it as divdemodiagram.
Code Snippet
- <div id="Divdemodiagram" style="background-color: white; border: solid 1px blue; width: 100%; height: 500px"></div>
Step 6
Add the Function and write the following code.
Code Snippet
- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GoJsDemo1.aspx.cs" Inherits="SimpleGoJsDemo.GoJdDemo1" %>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title></title>
- <script src="Scripts/jquery-1.10.2.min.js"></script>
- <script src="Scripts/go.js"></script>
- <script>
- function init() {
- var $ = go.GraphObject.make;
-
- myDiagram = $(go.Diagram, "Divdemodiagram",
- {
- initialContentAlignment: go.Spot.Center,
- "undoManager.isEnabled": true
- });
- myDiagram.nodeTemplate =
- $(go.Node, "Auto",
- $(go.Shape, "Ellipse", { strokeWidth: 1 },
-
- new go.Binding("fill", "color")),
- $(go.TextBlock,
- { margin: 10 },
- new go.Binding("text", "key"))
- );
- myDiagram.model = new go.GraphLinksModel(
- [
- { key: "A", color: "Red" },
- { key: "B", color: "Blue" },
- { key: "G", color: "green" },
- { key: "D", color: "pink" }
- ],
- [
- { from: "A", to: "B" },
- { from: "A", to: "c" },
- { from: "B", to: "B" },
- { from: "D", to: "A" }
- ]);
- }
- </script>
- </head>
- <body>
- <form id="form1" runat="server">
- <div id="Demo">
- <div id="Divdemodiagram" style="background-color: white; border: solid 1px blue; width: 100%; height: 500px"></div>
- </div>
- </form>
- </body>
- </html>
Summary
In this article, I have explained a very simple example of GoJS. In my next article, we will learn GoJS classes in detail to better understand the concept of GoJS.