最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

mxGraph官方文档及其翻译整理

IT圈 admin 28浏览 0评论

2024年5月7日发(作者:阎希慕)

翻译

外文原文

1 Overview

The mxGraph package contains a client software, written in JavaScript, and a series of backends for various

languages. The client software is a graph component with an optional application wrapper that is integrated

into an existing web interface. The client requires a webserver to deliver the required files to the client or can

be run from the local filesystem without a webserver. The backends may be used as is, or they may be

embedded into an existing server application in one of the supported languages.

If a backend exists, then the client may be configured to use this backend in various ways, such as:

Creating images

Storing and loading diagrams

Creating an object representation of a graph

Sharing diagrams with other clients

The above scenarios maybe combined in various ways, such as sending an XML description of each change

to the backend as it happens, or autosaving of the diagram to avoid loss of data on the client. The client can

also operate in offline mode, where it does not require a backend or a webserver.

Please have a look at the index files in the respective directories for information on the various backends.

Java

.NET

PHP

2 Hello, World!

The Hello, World! example of mxGraph ships in a single HTML file, which contains the required

namespaces, the mxGraph library script and the example code. The example can be viewed by pointing Firefox

or Internet Explorer to the link above either on the local filesystem or on a webserver. To display the source of

the example press Control-U in Firefox or click Page, View Source in Internet Explorer.

2.1 Library

The HEAD part of the page contains the JavaScript code and dependencies. The library is loaded using the

following code. The mxBasePath variable is used to define the path where the library loads its resources from.

This variable must be defined prior to loading the library code and should not include a trailing slash.

contains all required code in a single file. Note that the source code only ships with the

commercial distributions. In the evaluation version, the source code is loaded from a server using a special

URL. You should not make local copies of the evaluation source code.

2.2 Browser Check

The next script tag in the HEAD part of the page contains the Hello, World! example code. The first part of

the code checks if the browser that is displaying the page is supported by the library. It is recommended to do

this as the first step of the program and display an error message if the browser is not supported. In your

document you may also want to include a NOSCRIPT directive for browsers that have JavaScript disabled,

however, in our examples this directive is not used.

There is no convention for the name of the main function. The function is invoked from the onload handler

in the page and may have any name and arguments. In this case, the argument is a DOM node that will contain

the graph. Note that the DOM node may have any ID and that the code is independent of this ID.

contains all required code in a single file. Note that the source code only ships with the

commercial distributions. In the evaluation version, the source code is loaded from a server using a special

URL. You should not make local copies of the evaluation source code.

2.2 Browser Check

The next script tag in the HEAD part of the page contains the Hello, World! example code. The first part of

the code checks if the browser that is displaying the page is supported by the library. It is recommended to do

this as the first step of the program and display an error message if the browser is not supported. In your

document you may also want to include a NOSCRIPT directive for browsers that have JavaScript disabled,

however, in our examples this directive is not used.

There is no convention for the name of the main function. The function is invoked from the onload handler

in the page and may have any name and arguments. In this case, the argument is a DOM node that will contain

the graph. Note that the DOM node may have any ID and that the code is independent of this ID.