Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update README, add data/example.js, format data/sample-data.json #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,111 @@ Force plot for **Lightning**
Documentation and examples at [lightning-viz.org](http://lightning-viz.org/documentation)

[![force](https://raw.githubusercontent.com/lightning-viz/lightning-default-index/master/images/force.png)](https://github.com/lightning-viz/lightning-force)

## Usage options

### Lightning server

The Lightning server provides API-based access to reproducible, web-based visualizations. It can be deployed in many ways, including Heroku, Docker, a public server, a local app for OS X — and even a server-less version well-suited to notebooks like Jupyter. It comes bundled with a core set of visualizations, but is built to support custom ones.

[Read more about getting started with a Lightning server](http://lightning-viz.org/documentation/)

You can create an adjacency visualization using Python, Scala, JavaScript, or R by using API clients for making requests to a Lightning server.

#### Clients

Take a look at each client for installation and usage examples:

- [Python](https://github.com/lightning-viz/lightning-python)
- [Scala](https://github.com/lightning-viz/lightning-scala)
- [JavaScript](https://github.com/lightning-viz/lightning.js)
- [R](https://github.com/Ermlab/lightning-rstat)

#### Python adjacency example

```python
from lightning import Lightning
from numpy import random

lgn = Lightning()

mat = random.rand(10,10)
mat[mat>0.75] = 0
group = (random.rand(10) * 5).astype('int')

lgn.force(mat, group=group)
```

#### Scala adjacency example

```scala
import org.viz.lightning._
import scala.util.Random

val lgn = Lightning()

val mat = Array.fill(10)(Array.fill(10)(Random.nextDouble()).map{ d =>
if (d < 0.75) {
d
} else {
0.0
}
})
val group = Array.fill(10)(Random.nextInt)

lgn.force(mat, group=group)
```

## JavaScript module via npm

`lightning-force` is an npm module that can be used on its own.

### Install as JavaScript module

```
npm i --save lightning-force
```

### Example

```js
var Force = require('lightning-force');

var el = document.createElement('div');
document.body.appendChild(el);

var data = {
nodes: [0, 1, 2, 3, 4],
group: [0, 0, 1, 1, 2],
labels: ["a", "b", "c", "d", "e"],
links:[[0, 1, 1], [0, 2, 6], [0, 3, 1], [0, 4, 5]]
};

var options = {
zoom: false
};

var force = new Force(el, data, options);

```

### API

#### `var Force = require("lightning-force");`

#### `var force = new Force(selector, data, options);`

**Arguments:**
- **selector** – css selector or dom node that will act as parent node of the visualization
- **data** – the required data for the Visualization
- **nodes** – array representing nodes in the visualization
- **group** – array representing groups
- **links** – array of arrays describing the links between nodes
- **labels** – array of strings
- **options**
- **width** – *Number* – the width of the visualization
- **height** – *Number* – the height of the visualization
- **zoom** – *Boolean* – determines whether the user can zoom the visualization in and out

## License
[MIT](LICENSE)
17 changes: 17 additions & 0 deletions data/example.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions data/sample-data.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[

{ "name": "miserables",
"data": {"nodes": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76], "group": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 5, 4, 0, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 4, 6, 4, 4, 5, 0, 0, 7, 7, 8, 5, 5, 5, 5, 5, 5, 8, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 4, 4, 4, 4, 5, 10, 10, 4, 8], "labels": ["Myriel", "Napoleon", "Mlle.Baptistine", "Mme.Magloire", "ContessdeLo", "Geborand", "Champtercier", "Cravatte", "Cont", "OldMan", "Labarre", "Valjean", "Margerite", "Mme.deR", "Isabea", "Gervais", "Tholomyes", "Listolier", "Fameil", "Blacheville", "Favorite", "Dahlia", "Zephine", "Fantine", "Mme.Thenardier", "Thenardier", "Cosette", "Javert", "Fachelevent", "Bamatabois", "Perpete", "Simplice", "Scafflaire", "Woman1", "Jdge", "Champmathie", "Brevet", "Chenildie", "Cochepaille", "Pontmercy", "Bolatrelle", "Eponine", "Anzelma", "Woman2", "MotherInnocent", "Gribier", "Jondrette", "Mme.Brgon", "Gavroche", "Gillenormand", "Magnon", "Mlle.Gillenormand", "Mme.Pontmercy", "Mlle.Vabois", "Lt.Gillenormand", "Maris", "BaronessT", "Mabef", "Enjolras", "Combeferre", "Provaire", "Feilly", "Corfeyrac", "Bahorel", "Bosset", "Joly", "Grantaire", "MotherPltarch", "Gelemer", "Babet", "Claqesos", "Montparnasse", "Tossaint", "Child1", "Child2", "Brjon", "Mme.Hchelop"], "links":[[1, 0, 1], [2, 0, 8], [3, 0, 10], [3, 2, 6], [4, 0, 1], [5, 0, 1], [6, 0, 1], [7, 0, 1], [8, 0, 2], [9, 0, 1], [11, 10, 1], [11, 3, 3], [11, 2, 3], [11, 0, 5], [12, 11, 1], [13, 11, 1], [14, 11, 1], [15, 11, 1], [17, 16, 4], [18, 16, 4], [18, 17, 4], [19, 16, 4], [19, 17, 4], [19, 18, 4], [20, 16, 3], [20, 17, 3], [20, 18, 3], [20, 19, 4], [21, 16, 3], [21, 17, 3], [21, 18, 3], [21, 19, 3], [21, 20, 5], [22, 16, 3], [22, 17, 3], [22, 18, 3], [22, 19, 3], [22, 20, 4], [22, 21, 4], [23, 16, 3], [23, 17, 3], [23, 18, 3], [23, 19, 3], [23, 20, 4], [23, 21, 4], [23, 22, 4], [23, 12, 2], [23, 11, 9], [24, 23, 2], [24, 11, 7], [25, 24, 13], [25, 23, 1], [25, 11, 12], [26, 24, 4], [26, 11, 31], [26, 16, 1], [26, 25, 1], [27, 11, 17], [27, 23, 5], [27, 25, 5], [27, 24, 1], [27, 26, 1], [28, 11, 8], [28, 27, 1], [29, 23, 1], [29, 27, 1], [29, 11, 2], [30, 23, 1], [31, 30, 2], [31, 11, 3], [31, 23, 2], [31, 27, 1], [32, 11, 1], [33, 11, 2], [33, 27, 1], [34, 11, 3], [34, 29, 2], [35, 11, 3], [35, 34, 3], [35, 29, 2], [36, 34, 2], [36, 35, 2], [36, 11, 2], [36, 29, 1], [37, 34, 2], [37, 35, 2], [37, 36, 2], [37, 11, 2], [37, 29, 1], [38, 34, 2], [38, 35, 2], [38, 36, 2], [38, 37, 2], [38, 11, 2], [38, 29, 1], [39, 25, 1], [40, 25, 1], [41, 24, 2], [41, 25, 3], [42, 41, 2], [42, 25, 2], [42, 24, 1], [43, 11, 3], [43, 26, 1], [43, 27, 1], [44, 28, 3], [44, 11, 1], [45, 28, 2], [47, 46, 1], [48, 47, 2], [48, 25, 1], [48, 27, 1], [48, 11, 1], [49, 26, 3], [49, 11, 2], [50, 49, 1], [50, 24, 1], [51, 49, 9], [51, 26, 2], [51, 11, 2], [52, 51, 1], [52, 39, 1], [53, 51, 1], [54, 51, 2], [54, 49, 1], [54, 26, 1], [55, 51, 6], [55, 49, 12], [55, 39, 1], [55, 54, 1], [55, 26, 21], [55, 11, 19], [55, 16, 1], [55, 25, 2], [55, 41, 5], [55, 48, 4], [56, 49, 1], [56, 55, 1], [57, 55, 1], [57, 41, 1], [57, 48, 1], [58, 55, 7], [58, 48, 7], [58, 27, 6], [58, 57, 1], [58, 11, 4], [59, 58, 15], [59, 55, 5], [59, 48, 6], [59, 57, 2], [60, 48, 1], [60, 58, 4], [60, 59, 2], [61, 48, 2], [61, 58, 6], [61, 60, 2], [61, 59, 5], [61, 57, 1], [61, 55, 1], [62, 55, 9], [62, 58, 17], [62, 59, 13], [62, 48, 7], [62, 57, 2], [62, 41, 1], [62, 61, 6], [62, 60, 3], [63, 59, 5], [63, 48, 5], [63, 62, 6], [63, 57, 2], [63, 58, 4], [63, 61, 3], [63, 60, 2], [63, 55, 1], [64, 55, 5], [64, 62, 12], [64, 48, 5], [64, 63, 4], [64, 58, 10], [64, 61, 6], [64, 60, 2], [64, 59, 9], [64, 57, 1], [64, 11, 1], [65, 63, 5], [65, 64, 7], [65, 48, 3], [65, 62, 5], [65, 58, 5], [65, 61, 5], [65, 60, 2], [65, 59, 5], [65, 57, 1], [65, 55, 2], [66, 64, 3], [66, 58, 3], [66, 59, 1], [66, 62, 2], [66, 65, 2], [66, 48, 1], [66, 63, 1], [66, 61, 1], [66, 60, 1], [67, 57, 3], [68, 25, 5], [68, 11, 1], [68, 24, 1], [68, 27, 1], [68, 48, 1], [68, 41, 1], [69, 25, 6], [69, 68, 6], [69, 11, 1], [69, 24, 1], [69, 27, 2], [69, 48, 1], [69, 41, 1], [70, 25, 4], [70, 69, 4], [70, 68, 4], [70, 11, 1], [70, 24, 1], [70, 27, 1], [70, 41, 1], [70, 58, 1], [71, 27, 1], [71, 69, 2], [71, 68, 2], [71, 70, 2], [71, 11, 1], [71, 48, 1], [71, 41, 1], [71, 25, 1], [72, 26, 2], [72, 27, 1], [72, 11, 1], [73, 48, 2], [74, 48, 2], [74, 73, 3], [75, 69, 3], [75, 68, 3], [75, 25, 3], [75, 48, 1], [75, 41, 1], [75, 70, 1], [75, 71, 1], [76, 64, 1], [76, 65, 1], [76, 66, 1], [76, 63, 1], [76, 62, 1], [76, 48, 1], [76, 58, 1]]}
}


{
"name": "miserables",
"data": {
"nodes": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76],
"group": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 5, 4, 0, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 4, 6, 4, 4, 5, 0, 0, 7, 7, 8, 5, 5, 5, 5, 5, 5, 8, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 4, 4, 4, 4, 5, 10, 10, 4, 8],
"labels": ["Myriel", "Napoleon", "Mlle.Baptistine", "Mme.Magloire", "ContessdeLo", "Geborand", "Champtercier", "Cravatte", "Cont", "OldMan", "Labarre", "Valjean", "Margerite", "Mme.deR", "Isabea", "Gervais", "Tholomyes", "Listolier", "Fameil", "Blacheville", "Favorite", "Dahlia", "Zephine", "Fantine", "Mme.Thenardier", "Thenardier", "Cosette", "Javert", "Fachelevent", "Bamatabois", "Perpete", "Simplice", "Scafflaire", "Woman1", "Jdge", "Champmathie", "Brevet", "Chenildie", "Cochepaille", "Pontmercy", "Bolatrelle", "Eponine", "Anzelma", "Woman2", "MotherInnocent", "Gribier", "Jondrette", "Mme.Brgon", "Gavroche", "Gillenormand", "Magnon", "Mlle.Gillenormand", "Mme.Pontmercy", "Mlle.Vabois", "Lt.Gillenormand", "Maris", "BaronessT", "Mabef", "Enjolras", "Combeferre", "Provaire", "Feilly", "Corfeyrac", "Bahorel", "Bosset", "Joly", "Grantaire", "MotherPltarch", "Gelemer", "Babet", "Claqesos", "Montparnasse", "Tossaint", "Child1", "Child2", "Brjon", "Mme.Hchelop"],
"links":[[1, 0, 1], [2, 0, 8], [3, 0, 10], [3, 2, 6], [4, 0, 1], [5, 0, 1], [6, 0, 1], [7, 0, 1], [8, 0, 2], [9, 0, 1], [11, 10, 1], [11, 3, 3], [11, 2, 3], [11, 0, 5], [12, 11, 1], [13, 11, 1], [14, 11, 1], [15, 11, 1], [17, 16, 4], [18, 16, 4], [18, 17, 4], [19, 16, 4], [19, 17, 4], [19, 18, 4], [20, 16, 3], [20, 17, 3], [20, 18, 3], [20, 19, 4], [21, 16, 3], [21, 17, 3], [21, 18, 3], [21, 19, 3], [21, 20, 5], [22, 16, 3], [22, 17, 3], [22, 18, 3], [22, 19, 3], [22, 20, 4], [22, 21, 4], [23, 16, 3], [23, 17, 3], [23, 18, 3], [23, 19, 3], [23, 20, 4], [23, 21, 4], [23, 22, 4], [23, 12, 2], [23, 11, 9], [24, 23, 2], [24, 11, 7], [25, 24, 13], [25, 23, 1], [25, 11, 12], [26, 24, 4], [26, 11, 31], [26, 16, 1], [26, 25, 1], [27, 11, 17], [27, 23, 5], [27, 25, 5], [27, 24, 1], [27, 26, 1], [28, 11, 8], [28, 27, 1], [29, 23, 1], [29, 27, 1], [29, 11, 2], [30, 23, 1], [31, 30, 2], [31, 11, 3], [31, 23, 2], [31, 27, 1], [32, 11, 1], [33, 11, 2], [33, 27, 1], [34, 11, 3], [34, 29, 2], [35, 11, 3], [35, 34, 3], [35, 29, 2], [36, 34, 2], [36, 35, 2], [36, 11, 2], [36, 29, 1], [37, 34, 2], [37, 35, 2], [37, 36, 2], [37, 11, 2], [37, 29, 1], [38, 34, 2], [38, 35, 2], [38, 36, 2], [38, 37, 2], [38, 11, 2], [38, 29, 1], [39, 25, 1], [40, 25, 1], [41, 24, 2], [41, 25, 3], [42, 41, 2], [42, 25, 2], [42, 24, 1], [43, 11, 3], [43, 26, 1], [43, 27, 1], [44, 28, 3], [44, 11, 1], [45, 28, 2], [47, 46, 1], [48, 47, 2], [48, 25, 1], [48, 27, 1], [48, 11, 1], [49, 26, 3], [49, 11, 2], [50, 49, 1], [50, 24, 1], [51, 49, 9], [51, 26, 2], [51, 11, 2], [52, 51, 1], [52, 39, 1], [53, 51, 1], [54, 51, 2], [54, 49, 1], [54, 26, 1], [55, 51, 6], [55, 49, 12], [55, 39, 1], [55, 54, 1], [55, 26, 21], [55, 11, 19], [55, 16, 1], [55, 25, 2], [55, 41, 5], [55, 48, 4], [56, 49, 1], [56, 55, 1], [57, 55, 1], [57, 41, 1], [57, 48, 1], [58, 55, 7], [58, 48, 7], [58, 27, 6], [58, 57, 1], [58, 11, 4], [59, 58, 15], [59, 55, 5], [59, 48, 6], [59, 57, 2], [60, 48, 1], [60, 58, 4], [60, 59, 2], [61, 48, 2], [61, 58, 6], [61, 60, 2], [61, 59, 5], [61, 57, 1], [61, 55, 1], [62, 55, 9], [62, 58, 17], [62, 59, 13], [62, 48, 7], [62, 57, 2], [62, 41, 1], [62, 61, 6], [62, 60, 3], [63, 59, 5], [63, 48, 5], [63, 62, 6], [63, 57, 2], [63, 58, 4], [63, 61, 3], [63, 60, 2], [63, 55, 1], [64, 55, 5], [64, 62, 12], [64, 48, 5], [64, 63, 4], [64, 58, 10], [64, 61, 6], [64, 60, 2], [64, 59, 9], [64, 57, 1], [64, 11, 1], [65, 63, 5], [65, 64, 7], [65, 48, 3], [65, 62, 5], [65, 58, 5], [65, 61, 5], [65, 60, 2], [65, 59, 5], [65, 57, 1], [65, 55, 2], [66, 64, 3], [66, 58, 3], [66, 59, 1], [66, 62, 2], [66, 65, 2], [66, 48, 1], [66, 63, 1], [66, 61, 1], [66, 60, 1], [67, 57, 3], [68, 25, 5], [68, 11, 1], [68, 24, 1], [68, 27, 1], [68, 48, 1], [68, 41, 1], [69, 25, 6], [69, 68, 6], [69, 11, 1], [69, 24, 1], [69, 27, 2], [69, 48, 1], [69, 41, 1], [70, 25, 4], [70, 69, 4], [70, 68, 4], [70, 11, 1], [70, 24, 1], [70, 27, 1], [70, 41, 1], [70, 58, 1], [71, 27, 1], [71, 69, 2], [71, 68, 2], [71, 70, 2], [71, 11, 1], [71, 48, 1], [71, 41, 1], [71, 25, 1], [72, 26, 2], [72, 27, 1], [72, 11, 1], [73, 48, 2], [74, 48, 2], [74, 73, 3], [75, 69, 3], [75, 68, 3], [75, 25, 3], [75, 48, 1], [75, 41, 1], [75, 70, 1], [75, 71, 1], [76, 64, 1], [76, 65, 1], [76, 66, 1], [76, 63, 1], [76, 62, 1], [76, 48, 1], [76, 58, 1]]
}
}
]