HTML5 network topology diagram application example explanation
This article mainly introduces relevant information on the rapid development of HTML5-based network topology map applications. The editor thinks it is quite good, so I will share it with you now and give it as a reference. Let’s follow the editor to take a look, I hope it can help everyone.
Starting today, we will analyze how to build an HTML5 Canvas topology graph application from the most basic level. HT internally encapsulates a topology graph component ht.graph.GraphView (hereinafter referred to as GraphView), which is the component with the richest 2D functions in the HT framework. , and its related class libraries are under the ht.graph package. GraphView has basic graphics presentation and editing functions, topological node connection and automatic layout functions, predefined objects in industries such as electric power and telecommunications, and special effects such as animation rendering. Therefore, it has a wide range of applications and can be used as a drawing tool and human resource in the monitoring field. It has a machine interface and can be used as a general graphical editing tool and can be expanded into enterprise applications such as workflow and organization charts. To put it simply: topology diagram is a generalized term. Network topology diagram of telecommunications network management, power grid topology diagram, industrial control monitoring diagram, work flow diagram, thinking brain map, etc. Simply put, it is composed of node connections. These are the topological diagrams referred to here.
It is very easy to develop a network topology diagram using HT. It only takes a few lines of code to complete a simple server and client topology diagram:
This example is very basic and almost completes all the topological functions of the server and client. Without further ado, guess how many lines of code it took to include all parts of the HTML tags in this example? There are only 50 lines minus the blank lines. I also did a lot of style design. After all, the example for everyone can’t be too ugly~
You can download the code by yourself at tuputu_jb51.rar, please note that there is json File, there will be cross-domain problems with images, and you need to use Firefox or a local server to run it.
Let us explain at the beginning that HT is a one-stop solution for enterprise application graphical interface based on the HTML5 standard. It includes a rich graphical interface development class library such as general components, topology components and 3D rendering engines. Users only need to introduce ht.js, and it does not conflict with anything else at all, because HT only declares a global variable ht, nothing more.
Next, analyze the code part. First, build the topology map scene:
dm = new ht.DataModel();//数据容器 gv = new ht.graph.GraphView(dm);//拓扑组件 参数为dm 绑定的数据模型 gv.addToDOM();//将拓扑图添加进body体中
The root of all components of HT is a p, through getView() Method acquisition, we used this method in the addToDOM method:
addToDOM = function(){ var self = this, view = self.getView(), //获取组件底层 p style = view.style; document.body.appendChild(view);//将底层 p 添加进 body 体中 style.left = '0';//HT 一般将组件都设置为 absolute 的绝对定位 style.right = '0'; style.top = '0'; style.bottom = '0'; window.addEventListener('resize', function () { self.iv(); }, false); //事件监听窗口大小变化,iv 为延时刷新组件 }
Then add the "server" and "client" nodes to the topology scene:
var server = new ht.Node(); server.setName('server');//设置节点名称,显示在节点下方 server.setImage('serverImage');//设置节点图片 server.setSize(20, 60);//设置节点大小 dm.add(server);//将节点添加进数据容器dm中 server.setPosition(100, 100);//设置节点坐标(x, y) var group = new ht.Group();//组,组中可以有多个节点 group.setImage('groupImage');//设置图片 dm.add(group); var client = new ht.Node();//这个节点是添加进组中的 client.setName('client'); client.setImage('clientImage'); dm.add(client); group.addChild(client);//组添加孩子 group.setExpanded(true);//设置组为展开模式 client.setPosition(200, 100);//设置节点位置 如果组中只有一个节点,那么这个节点的位置可以为组的位置
The connection between the server and the client? 2 lines of code done! In fact, the method of adding nodes in HT is very simple. It usually only requires 2 lines of code: first declare the instance variable, and then add the instance variable to the data container.
var edge = new ht.Edge(server, client); dm.add(edge);
We are curious about how the dotted line is made? The formation of the dotted line is built on the connection line. There are three steps:
Introduce the ht-dashflow.js file;
The style attribute edge.dash.flow of the connection is set to true;
Turn on the switch of dashed line flow in the scene component, here is gv.enableDashFlow(true);
Isn’t it very simple! Next, let’s take a look at how to set it up:
edge.s({//节点设置样式属性 'edge.dash': true,//显示虚线 'edge.dash.flow': true,//开启虚线流动 'edge.dash.color': 'yellow',//虚线颜色 'edge.dash.pattern': [8, 8],//虚线样式 'label': 'flow',//节点注释 'label.background': 'pink',//节点注释背景颜色 });
In this way, all the display parts have been introduced~Wait, it seems like there is something missing? By the way, I forgot to introduce the ht.Group class in HT. As the name suggests, it means "group". A group can contain many nodes. Double-click to display or hide all nodes in the group. It is written in the above code, but I also did a little trick, that is, the display part in the upper right corner of the group is actually a mark, used to prompt instructions:
##
group.s({ 'group.background': 'rgba(255, 255, 0, 0.1)',//设置组的背景颜色 'note': "Double click me!",//标注 显示的内容 'note.position': 13,//标注位置 'note.offset.y': 10,//标注位置y轴偏移 });We can change it through note.position The position of the annotation (for specific location information, please refer to the HT for Web Position Manual), you can also use note.offset.x and note.offset.y to change the position of the annotation. All codes have been parsed! I will update as soon as possible. If you feel that the progress is slow, you can go to our official website (HT for Web) to learn by yourself. I hope you can gain more. Learning is your own business. Quickly practice and transform the content of this article into Make it your own knowledge!
Related recommendations:
Introduction to task scheduling topology diagram of directed graph
Detailed explanation of HTML5 network topology diagram integrating OpenLayers to implement GIS map application (picture)
Detailed graphic explanation of HTML5 network topology diagram performance optimization
The above is the detailed content of HTML5 network topology diagram application example explanation. For more information, please follow other related articles on the PHP Chinese website!

HTML5 brings five key improvements: 1. Semantic tags improve code clarity and SEO effects; 2. Multimedia support simplifies video and audio embedding; 3. Form enhancement simplifies verification; 4. Offline and local storage improves user experience; 5. Canvas and graphics functions enhance the visualization of web pages.

The core features of HTML5 include semantic tags, multimedia support, offline storage and local storage, and form enhancement. 1. Semantic tags such as, etc. to improve code readability and SEO effect. 2. Simplify multimedia embedding with labels. 3. Offline storage and local storage such as ApplicationCache and LocalStorage support network-free operation and data storage. 4. Form enhancement introduces new input types and verification properties to simplify processing and verification.

H5 provides a variety of new features and functions, greatly enhancing the capabilities of front-end development. 1. Multimedia support: embed media through and elements, no plug-ins are required. 2. Canvas: Use elements to dynamically render 2D graphics and animations. 3. Local storage: implement persistent data storage through localStorage and sessionStorage to improve user experience.

H5 and HTML5 are different concepts: HTML5 is a version of HTML, containing new elements and APIs; H5 is a mobile application development framework based on HTML5. HTML5 parses and renders code through the browser, while H5 applications need to run containers and interact with native code through JavaScript.

Key elements of HTML5 include,,,,,, etc., which are used to build modern web pages. 1. Define the head content, 2. Used to navigate the link, 3. Represent the content of independent articles, 4. Organize the page content, 5. Display the sidebar content, 6. Define the footer, these elements enhance the structure and functionality of the web page.

There is no difference between HTML5 and H5, which is the abbreviation of HTML5. 1.HTML5 is the fifth version of HTML, which enhances the multimedia and interactive functions of web pages. 2.H5 is often used to refer to HTML5-based mobile web pages or applications, and is suitable for various mobile devices.

HTML5 is the latest version of the Hypertext Markup Language, standardized by W3C. HTML5 introduces new semantic tags, multimedia support and form enhancements, improving web structure, user experience and SEO effects. HTML5 introduces new semantic tags, such as, ,, etc., to make the web page structure clearer and the SEO effect better. HTML5 supports multimedia elements and no third-party plug-ins are required, improving user experience and loading speed. HTML5 enhances form functions and introduces new input types such as, etc., which improves user experience and form verification efficiency.

How to write clean and efficient HTML5 code? The answer is to avoid common mistakes by semanticizing tags, structured code, performance optimization and avoiding common mistakes. 1. Use semantic tags such as, etc. to improve code readability and SEO effect. 2. Keep the code structured and readable, using appropriate indentation and comments. 3. Optimize performance by reducing unnecessary tags, using CDN and compressing code. 4. Avoid common mistakes, such as the tag not closed, and ensure the validity of the code.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version
Chinese version, very easy to use

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
