UNPKG

mxgraph-map-fix

Version:

mxGraph is a fully client side JavaScript diagramming library that uses SVG and HTML for rendering.

68 lines (56 loc) 2.22 kB
<!-- Copyright (c) 2008, Gaudenz Alder Template example for mxGraph. This is used as a template HTML file by the backends to demonstrate the deployment of the client with a graph embedded in the page as XML data (see graph variable in the onload-handler). *** THIS FILE MUST BE DEPLOYED BY ONE OF THE BACKENDS! *** --> <html> <head> <title>Hello, World! example for mxGraph</title> <!-- Sets the basepath for the library if not in same directory --> <script type="text/javascript"> mxBasePath = '../../javascript/src'; </script> <!-- Loads and initializes the library --> <script type="text/javascript" src="../../javascript/src/js/mxClient.js"></script> <!-- Example code --> <script type="text/javascript"> // Program starts here. Creates a sample graph in the // DOM node with the specified ID. This function is invoked // from the onLoad event handler of the document (see below). function main(container, xml) { // Checks if the browser is supported if (!mxClient.isBrowserSupported()) { // Displays an error message if the browser is not supported. mxUtils.error('Browser is not supported!', 200, false); } else { // Creates the graph inside the given container var graph = new mxGraph(container); // Adds rubberband selection to the graph new mxRubberband(graph); var doc = mxUtils.parseXml(xml); var codec = new mxCodec(doc); codec.decode(doc.documentElement, graph.getModel()); } // Adds button for saving image via PHP backend document.body.appendChild(mxUtils.button('Save Image', function() { var node = mxUtils.getViewXml(graph, 1); var xml = mxUtils.getXml(node); new mxXmlRequest('deployment.php', 'xml=' + encodeURIComponent(xml)).simulate(document, '_blank'); })); }; </script> </head> <!-- Page passes the container for the graph to the program --> <body onload="main(document.getElementById('graphContainer'), '%graph%');"> <!-- Creates a container for the graph with a grid wallpaper --> <div id="graphContainer" style="overflow:hidden;width:321px;height:241px;background:url('../../javascript/examples/editors/images/grid.gif')"> </div> </body> </html>