forked from null2/circular-migration-plot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (32 loc) · 736 Bytes
/
index.js
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
/*
* Circular Migration Plot
*
* Copyright (c) 2014 null2 GmbH Berlin
* Licensed under the MIT license.
*/
var d3 = require('d3');
var chart = require('./lib/chart');
var timeline = require('./lib/timeline');
module.exports = function(options) {
if (!options.data) {
throw('I need a data url!');
}
if (!options.chart) {
throw('I need a chart node!');
}
if (typeof options.chart === 'string') {
options.chart = {
element: options.chart
};
}
if (typeof options.timeline === 'string') {
options.timeline = {
element: options.timeline
};
}
d3.json(options.data, function(json) {
var c = chart(json, options.chart);
timeline(c, options.timeline);
c.draw();
});
};