Skip to content
This repository was archived by the owner on Nov 7, 2018. It is now read-only.
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
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "d3-plugins",
"version": "0.1.0",

"peerDependencies": {
"d3": "^3.5.0"
},

"main": "pluginloader.js"
}
39 changes: 39 additions & 0 deletions pluginloader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

;(function() {
/* jshint node:true, asi:true, eqnull:true */
"use strict";
var has_require = typeof require !== 'undefined';

var d3 = this.d3;
if( typeof d3 === 'undefined' ) {
if( has_require ) {
d3 = require('d3');
}
else throw new Error('d3 plugins require d3');
}

var pluginloader = function(obj) {
if (obj instanceof pluginloader) {
return obj;
}
if (!(this instanceof pluginloader)) {
return new pluginloader(obj);
}
this._wrapped = obj;
};

if( typeof exports !== 'undefined' ) {
if( typeof module !== 'undefined' && module.exports ) {
exports = module.exports = pluginloader;
} else {
exports.pluginloader = pluginloader;
}
}

pluginloader.load = function(pluginname) {
if ( has_require ) {
require('./' + pluginname + '/' + pluginname);
}
}

}).call(this);
13 changes: 13 additions & 0 deletions sankey/sankey.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@

;(function() {
var has_require = typeof require !== 'undefined';

var d3 = this.d3;
if( typeof d3 === 'undefined' ) {
if( has_require ) {
d3 = require('d3');
}
else throw new Error('d3 plugins require d3');
}

d3.sankey = function() {
var sankey = {},
nodeWidth = 24,
Expand Down Expand Up @@ -292,3 +304,4 @@ d3.sankey = function() {

return sankey;
};
}).call(this);