Home

Awesome

Nyaplotjs

alt text

Nyaplotjs is a back-end library for Nyaplot. Its goal is to allow Ruby and other language users to create interactive plots in their favorite styles. Nyaplotjs provides useful interface to generate plots based on JSON object.

This software has been developed as a product in Google Summer of Code 2014 (GSoC2014). Please visit a website of SciRuby project to see the progress of this project.

Nyaplotjs and Nyaplot will be merged into one library before the end of GSoC 2014 term.

Demos

How to use

General use

First, prepare an array as a data source.

var data = [{name:'type1',val:48}, {name:'type2',val:20}, {name:'type3',val:4}, {name:'type4',val:12}, {name:'type5',val:22}];

Next create plot.

var models = {data:data},panes: [{diagrams:[{type: 'bar', data: 'data1', options: {x:'name', y:'val1'}}],options:{width:500, height:500, xrange: ['type1','type2','type3','type4','type5'], yrange: [0,50]}}]};

Then load models into Nyaplotjs and it will begin to parse them and generate plot.

Nyaplot.core.parse(models, '#vis');

Click here to see the result.

Interactivity among panes

In order to enable this types of interactivity, you do not have to add any special attributes or lines. Creating multiple diagrams from one data source is enough.

This data includes 2 columns and one is for Histogram and the other is for Bar chart.

var mutation_types = ['c->a', 'g->a', 't->a'];
var values = d3.range(100).map(function(val){return {val1: d3.random.bates(10)(val), mutation_type: (val>50? mutation_types[0] : mutation_types[1])};});

Then create 2 diagrams from one data source.

var model1 = {data:{data1: values},panes: [{diagrams:[{type: 'histogram', data: 'data1', options: {value:'val1'}}], options:{xrange: [0,1], yrange: [0,30]}}]};
var model2 = {data:{},panes:[{diagrams:[{type:'bar', data: 'data1', options: {value:'mutation_type'}}],options:{xrange:['c->a', 'g->a', 't->a'], yrange: [0,100]}]};

If you want to filter data based on values mapped into x axis, add 'filter' attribute to 'options' in a pane.

var model1 = {data:{data1: values},panes: [{diagrams:[{type: 'histogram', data: 'data1', options: {value:'val1'}}], filter: {target: 'x'}, options:{xrange: [0,1], yrange: [0,30]}}]};

Click here to see the result.

Building

You need to install npm before building Nyaplotjs.

cd Nyaplotjs
npm install
grunt release

Dependency

License

Copyright (C) 2014 by Naoki Nishida
This version of Nyaplotjs is licensed under the MIT license.