Comparing version 0.1.2 to 0.1.3
import './build'; | ||
import d3bind from './root'; | ||
export default d3bind; | ||
export { d3bind }; | ||
export * from './root'; | ||
@@ -5,0 +6,0 @@ export * from './selection'; |
@@ -7,2 +7,3 @@ "use strict"; | ||
var root_1 = require('./root'); | ||
exports.d3bind = root_1.default; | ||
if (typeof window !== 'undefined') { | ||
@@ -9,0 +10,0 @@ window.d3bind = root_1.default; |
{ | ||
"name": "d3bind", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Observable data bindings for d3.js", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
D3bind | ||
====== | ||
D3bind is a library that brings model-view separation and observables to d3.js. | ||
D3bind is a library that brings model-view separation and observables to <b>d3.js</b>. | ||
Build of the initial release: [d3bind.js](https://github.com/ggmod/d3bind/releases/download/v0.1.1/d3bind.js) | ||
You can use the bundled library: [d3bind.js](https://github.com/ggmod/d3bind/releases/download/v0.1.1/d3bind.js), or install it with `npm install d3bind --save` | ||
Examples can be found here: [code](https://github.com/ggmod/d3bind-demo), [demo](https://ggmod.github.io/d3bind-demo) | ||
Hello world example: | ||
[See the wiki](https://github.com/ggmod/d3bind/wiki) for more explanation. | ||
#### Hello world example | ||
```javascript | ||
@@ -22,2 +24,29 @@ var model = d3bind.observable({ name: '' }); | ||
#### Data binding | ||
Instead of the data join mechanism of d3.js with the data, enter and exit functions, this library offers an alternative that uses an observable array model, and view bindings that automatically react to the changes in it. | ||
```javascript | ||
var data = d3bind.observable([4, 8, 15, 16]); | ||
var view = d3bind.select('body'); | ||
view.append('ul').bindRepeat(data, function(d, $i) { | ||
var li = this.append('li'); | ||
li.append('span').bindText($i); | ||
li.append('span').text(d); | ||
}); | ||
view.append('button').text('Insert random').on('click', function() { | ||
data.push(Math.floor(Math.random()*100)); | ||
}); | ||
view.append('button').text('Remove random').on('click', function() { | ||
data.splice(Math.floor(Math.random()*data.length), 1); | ||
}); | ||
view.append('div').bindText(data.$length); | ||
``` | ||
#### Logging | ||
To debug the cascading changes of observables, switch on logging: | ||
@@ -28,2 +57,3 @@ ```javascript | ||
#### Licensing | ||
Released under The MIT License. |
@@ -10,4 +10,4 @@ import './build'; | ||
export default d3bind; | ||
export {d3bind}; | ||
export * from './root'; | ||
@@ -14,0 +14,0 @@ export * from './selection'; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
783848
10945
58