Redesign drawing API
- Dominant language
- JavaScript
- Stars
- 779
- Forks
- 178
- PR merge metrics
- No merged PRs in 30d
Description
There currently is only the `draw` function which is like a one-of black box. It's not possible to make changes to the drawing config (without completely redrawing the graph), to extend it to support different kinds of visualization or different layouts.
I already started working on rewriting this part a long time ago and think that it's a good opportunity to introduce it with the next release.
The drawing API will be evolve around an abstract `Visualization` class which exposes an API that allows easily update an existing visualization. This class can be subclassed to provide different implements. I already have one for SVG output (with D3) and WebGL (experimental, with Three.js). The configuration options will mostly stay the same, but the API is richer.
Usage will look something like this:
``` js
var v = jsnx.draw(G, container, {/* some config here */}); // defaults to SVG visualization
// now or later
v.labels(true); // show labels
// or
v.labels(function(d) { return d.data.name; }); // show labels and use node data "name"
v.nodeStyle({style: {fill: 'red' }}); // style options depend on visualization
```
An implementation might not support every method. E.g. the WebGL implementation currently doesn't support labels, so calling `v.labels()` will just do nothing. On the other hand, implementations might offer additional methods, e.g. the WebGL implementation provides `v.camera` to the set the camera to be used.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.