g9.js

Automatically Interactive Graphics

README

g9.js


g9 is a javascript library for creating automatically interactive graphics.

With g9, interactive visualization is as easy as visualization that isn't. Just write a function which draws shapes based on data, and g9 will automatically figure out how to manipulate that data when you drag the shapes around.


For example, the following code:
  1. ```javascript
  2. g9({
  3.     x: 0,
  4.     y: 0
  5. }, function(data, ctx){
  6.     ctx.point(data.x, data.y)
  7.     ctx.point(data.y, data.x)
  8. })
  9. .insertInto('#container')
  10. ```

draws two dots at (x,y) and (y,x). With no additional effort, it's interactive - dragging either of the dots changes the value of x and y, and moves the other dot:

basic demo

This automatic interactivity makes it trivial to manipulable complex visualizations like this fractal:

dragon demo

You can see (and play with!) more examples on the website, or head to the docs for a full treatment of the API.


Installation

You can use g9 with npm (if your're using webpack or browserify) or with a script tag:




npm


  1. ```
  2. npm install g9
  3. ```

  1. ```javascript
  2. var g9 = require('g9')
  3. // or
  4. import g9 from 'g9'
  5. ```



## `