Permalink
Browse files

use rankdir=LR as default.

  • Loading branch information...
fiatjaf committed Jul 12, 2017
1 parent 9e3ccf8 commit e90dd2f76ec870055986bbe47ecf429d6d37dc3e
Showing with 18 additions and 11 deletions.
  1. +8 −7 README.md
  2. +10 −4 server.js
View
@@ -2,17 +2,18 @@
This repository dependency structure:
![](https://ndv.glitch.me/fiatjaf/node-dependencies-view.svg?ratio=0.5)
![](https://ndv.glitch.me/fiatjaf/node-dependencies-view.svg)
If you want to use one in your repo's `README.md` or anywhere else, use a link like this:
If you want to use one in your repo's `README.md` or anywhere else, use a link like these:
```
https://ndv.glitch.me/ipfs/js-ipfs.svg?ratio=0.2
```
* https://ndv.glitch.me/webtorrent/webtorrent
* https://ndv.glitch.me/cyclejs/cyclejs.svg?ratio=3
* https://ndv.glitch.me/fiatjaf/module-linker
* https://ndv.glitch.me/fiatjaf/pf?ratio=0.5&rankdir=TB
`ratio` is adjustable so you can make it more expanded (higher values, try starting at 0.1) or more compressed ("compress" is the option that takes less space). Other Graphviz configuration options may be coming soon.
The query string arguments are set in the **dot** string as properties of the graph. You can use most of them. Documentation is at http://www.graphviz.org/Documentation/dotguide.pdf.
Please don't abuse this. Since the server is a free [Glitch](https://glitch.com/edit/#!/ndv?path=server.js:33:24) instance it will fail if under heavy load or if you try to fetch a super huge project (GitHub caches images, so it is mostly safe to use it in `README.md`).
Please don't abuse this service. Since the server is a free [Glitch](https://glitch.com/edit/#!/ndv?path=server.js:33:24) instance it will fail if under heavy load or if you try to fetch a super huge project (GitHub caches images, so it is mostly safe to use it in `README.md`).
The graphs are made with [Viz.js](http://viz-js.com/).
View
@@ -22,16 +22,22 @@ app.get('/:user/:repo', (r, w) => {
graph(r.params.user, repo)
.then(dot => {
if (format === 'svg') {
let ratio = r.query.ratio || '0.1'
let lines = dot.split('\n')
dot = [lines[0], `ratio="${ratio}"`].concat(lines.slice(1)).join('\n')
// add dot parameters
r.query.rankdir = r.query.rankdir || 'LR' // default
var dotsettings = []
for (let k in r.query) {
dotsettings.push(` ${k}="${r.query[k]}"`)
}
let lines = dot.split('\n')
dot = [lines[0]].concat(dotsettings).concat(lines.slice(1)).join('\n')
if (format === 'svg') {
w.append('Content-Type', 'image/svg+xml')
w.append('Cache-Control', 'no-cache')
w.append('ETag', md5(dot))
w.send(Viz(dot))
} else if (format === 'dot') {
w.append('Content-Type', 'text/plain')
w.send(dot)
} else {
w.send('this will never happen.')

0 comments on commit e90dd2f

Please sign in to comment.