Skip to content

Nymphium/lua-graphviz

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

Lua-Graphviz

Graphviz for Lua

usage

local Graphviz = require("graphviz")

local graph = Graphviz()

install

luarocks install graphviz or git clone https://github.com/nymphium/lua-graphviz && cd lua-graphviz && luarocks make

function

graph:node(nodename, label)

add a node

graph:edge(...)

add a edges

args[1] -> args[2]
args[1] -> args[3]
...
args[1] -> args[n]

graph:source()

return graph as string

digraph {
	graph []
	node []
	edge []
		a [label="hoge"]
		b [label="huga"]
			a -> b
}

graph:write(filename)

write dot file to (filename)

graph:compile(filename, format = "pdf", generated_filename = ("%s.%s"):format(filename, format))

write dot file to (filename) and compile the file (dot -T format filename generated_filename)

graph:render(filename, format = "pdf", generated_filename = ("%s.%s"):format(filename, format))

write dot file to (filename), compile the dot file as format, and open the generated file

it only calls graph:write(filename), graph:compile(filename, format, generated_file) and io.pcall(()"xdg-open %s &"):format(generated_filename))

graph:render("file", "pdf")

graph.nodes.style:update(styles), graph.edges.style:update(styles, graph.graph.style:update(styles)

update each style

graph.nodes.style:update{
	fontname = "Inconsolata Regular",
	shape = "rectangle"
}

LICENSE

MIT

Releases

No releases published

Packages

No packages published

Languages