• Stars
    star
    184
  • Rank 205,168 (Top 5 %)
  • Language
    JavaScript
  • Created about 9 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

jquery plugin to make graphviz svg charts responsive

jquery.graphviz.svg

jQuery plugin to make Graphviz SVG output more interactive and easier to navigate. Makes it easy to have features like:

  • Highlight nodes/edges
  • Zoom in/out
  • Graph navigation - select linked nodes
  • Fancy UI tooltips; bootstrap supported out the box
  • Move things forward/back in the graph

Have a look at the demo: https://cdn.rawgit.com/mountainstorm/jquery.graphviz.svg/master/demo.html

Documentation

Create a node where you want your SVG graph to be displayed. Typically you will want to:

  • set its size (width/height/top/bottom etc)
  • set it as a positioning root; set positioning: relative or somethign else
  • enable overflow: scroll

Something like this works pretty well: <div id="graph" style="width: 100%; height: 100%; overflow: scroll; position: relative;"></div>

Next includes the css, and javascript: <link rel="stylesheet" href="css/graphviz.svg.css">

<script type="text/javascript" src="js/graphviz.svg.js"></script>

Then init the node as a Graphviz object:

$(document).ready(function(){
    $("#graph").graphviz({
        url: "demo.svg", 
        ready: function() {
            var gv = this
        }
    });
});

Depending on the options passed this will load, adopt and setup the Graphviz generated SVG under #graph and call your supplied ready function when the setup is complete.

Options:

  • url: if present the url to fetch the svg from
  • svg: raw SVG (xml) data to adopt
  • shrink: the amount to shrink nodes by; this gives a nice gap between nodes and edges. Default '0.125pt'
  • tooltips: object containing callbacks for init, show, hide and update. Default implementation uses bootstrap
  • zoom: enable shift-scroll zoom. Default true
  • highlight: object containing callbacks for selected, unselected; Default dims color of unselected
  • ready: callback when setup is complete. Will be asyncronous if loading svg from a url

The demo (demo.html) and the source (GraphvizSvg.DEFAULTS) show how these work in detail.

There are also other methods you can call to navigate the graph, select elements, highlight, move etc. To access these you need to get the 'graphviz.svg' object from the jQuery element you initialized ($('#graph').data('graphviz.svg')); it is also supplied as this to the ready callback.

GraphvizSvg.nodes() Returns all node DOM elements

GraphvizSvg.edges() Returns all edge DOM elements

GraphvizSvg.nodesByName() Returns an object mapping graphviz node names to its DOM element

GraphvizSvg.edgesByName() Returns an object mapping graphviz edge names to its DOM element

GraphvizSvg.linkedTo(node, includeEdges) Returns a jQuery set of DOM elements linked to node; if includeEdges is true if also includes the edges

GraphvizSvg.linkedFrom(node, includeEdges) Returns a jQuery set of DOM elements linked from node; if includeEdges is true if also includes the edges

GraphvizSvg.linked(node, includeEdges) Returns a jQuery set of DOM elements linked with node (in an undirected graph); if includeEdges is true if also includes the edges

GraphvizSvg.tooltip($elements, show) Show/hide tooltips on the SOM elements in the $elements set

GraphvizSvg.bringToFront($elements) Brings the DOM elements in the jQuery set to the front

GraphvizSvg.sendToBack($elements) Sends the DOM elements in the jQuery set to the back

GraphvizSvg.highlight($nodesEdges, tooltips) Highlight the DOM elements in $nodesEdges, if tooltips is true also show tooltips. If no nodes are passed it unselects all nodes/edges

Dependencies

  • jquery-2.1.3.js; for everything
  • Bootstrap; for default tooltips - not needed if you disable/dont use your own tooltips
  • jquery.color.js; for default highligh coloring - not needed it you supply your own
  • jquery.mousewheel.js; for scrolling - not needed if you turn it off

Keywords

jQuery, Graphviz, dot, svg

License

Copyright (c) 2015 Mountainstorm Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

MobileDevice

A python package, and command line tool, which wraps Apple's MobileDevice API - providing access to iOS devices.
Python
194
star
2

CoreSymbolication

Reverse engineered headers for Apples CoreSymbolication private framework; plus the set of test cases I used to validate it
Objective-C
89
star
3

Flow

Flow control tracer/debugger for OSX; provides a complete trace of all instructions executed by a process. Perfect if you want to know exactly what a process did/does
C
21
star
4

llaudio

An old piece of work to reverse engineer the Mac OSX user/kernel audio interface. Shows how to read audio straight out of the kernel as you would on Darwin (where most the OSX goodness is missing)
C++
20
star
5

wormxattr

A write once, read many filesystem OSX kext. It uses the security policy module support within xnu; hooking filesystem operations to provide WORM functionality based on an extended attribute.
C
11
star
6

Squall

lldb UI for OSX; like the gui command ... but better
Objective-C
10
star
7

mt_urwid

urwid (python console librarys) wigets; scrollview, tabview ...
Python
8
star
8

pdbfile

Python clone of the CLR PDB (debug symbol) parsing library
Python
5
star
9

js.sddl

Simple Microsoft SDDL/SD/ACE parsing webpage, with nice descriptive output
HTML
5
star
10

Studio---Lightroom-Tether

A standalone application for tethering Nikon cameras to OSX; includes a lightroom2 plugin to automate download and import of images taken
Objective-C
5
star
11

FreeNas-Scripts

Various scripts to improve my HP Microserver (N54L) freenas experiance; auto wake, shutdown
Python
4
star
12

LightroomTether

Source and distro for the lua based version of Lightroom tether; this automates download and import of images form a tethered Nikon camera into Lightroom2
Lua
4
star
13

cxa_demangle

Python wrapper around the c++ library cxa_demangle function; provides access to the internal C++ name demangle parse tree, thus allowing acurate parsing of parameters, types, templates etc - used in a exported mangled symbol
C++
2
star
14

MtTheme

Simple Cocoa theme engine; think CSS for NSView
Objective-C
2
star
15

Subleq

A simple software implementation of a single instruction VM; including an assembler and debugger
Python
1
star
16

semantic.fiendish

Semantic-UI menu/sidebar template
JavaScript
1
star
17

pyproto

A simple ctypes wrapper to make it more usable for parsing network protocols
Python
1
star
18

TeapotCMS

A simple, modern, customizable CMS for small sites
PHP
1
star
19

kroll-lua

An extension module for the kroll microkernel (used in Titanium and TideSDK) which adds support for lua
Objective-C
1
star
20

MtUI

A simple gui library, in python, on top of pyglet 1.2, using Cocoa ideas. Provides a simple scroll view and split view but should have all the framework code to make everything else easy to add
Python
1
star