Permalink
Browse files

add better support for node

  • Loading branch information...
1 parent 02b0501 commit cedf9d02162488c69f50b8f6cb37c8850e079704 @dchester dchester committed Sep 13, 2012
View
@@ -0,0 +1,12 @@
+{
+ "name": "rickshaw",
+ "version": "1.1.2",
+ "dependencies": {
+ "d3": ">= 2.10.1"
+ },
+ "keywords": ["d3", "charts", "rickshaw", "svg", "graph"],
+ "main": "./rickshaw",
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+}
@@ -125,7 +125,7 @@ Rickshaw.Compat.ClassList = function() {
elemCtrProto.__defineGetter__(classListProp, classListGetter);
}
- }(self));
+ }(window));
}
};
View
@@ -1,13 +1,10 @@
-Rickshaw = {
+var Rickshaw = {
namespace: function(namespace, obj) {
var parts = namespace.split('.');
- // for rudimentary compatibility w/ node
- var root = typeof global != 'undefined' ? global : window;
-
- var parent = root.Rickshaw;
+ var parent = Rickshaw;
for(var i = 1, length = parts.length; i < length; i++) {
currentPart = parts[i];
@@ -32,3 +29,8 @@ Rickshaw = {
}
};
+if (typeof module !== 'undefined' && module.exports) {
+ var d3 = require('d3');
+ module.exports = Rickshaw;
+}
+
View
@@ -1,5 +1,4 @@
-require('../src/js/Rickshaw');
-require('../src/js/Rickshaw.Class');
+var Rickshaw = require('../rickshaw');
exports.load = function(test) {
View
@@ -0,0 +1,41 @@
+var fs = require('fs');
+
+exports.svg = function(test) {
+
+ var jsdom = require("jsdom").jsdom;
+ global.document = jsdom("<html><head></head><body></body></html>");
+ global.window = global.document.createWindow();
+
+ var Rickshaw = require('../rickshaw');
+ new Rickshaw.Compat.ClassList();
+
+ var el = document.createElement("div");
+
+ var graph = new Rickshaw.Graph({
+ element: el,
+ width: 960,
+ height: 500,
+ renderer: 'scatterplot',
+ series: [{
+ color: 'steelblue',
+ data: [
+ { x: 0, y: 40 },
+ { x: 1, y: 49 },
+ { x: 2, y: 38 },
+ { x: 3, y: 30 },
+ { x: 4, y: 32 } ]
+ }]
+ } );
+
+ graph.renderer.dotSize = 6;
+ graph.render();
+
+ var generatedSVG = el.innerHTML;
+
+ var exampleSVGFilename = __dirname + '/data/simple.svg';
+ var exampleSVG = fs.readFileSync(exampleSVGFilename, 'utf8').trim();
+
+ test.equal(generatedSVG, exampleSVG, "simple graph svg content matches");
+
+ test.done();
+}
@@ -1,9 +1,4 @@
-require('../src/js/Rickshaw');
-require('../src/js/Rickshaw.Class');
-require('../src/js/Rickshaw.Fixtures.Color');
-require('../src/js/Rickshaw.Color.Palette');
-require('../src/js/Rickshaw.Series');
-require('../src/js/Rickshaw.Series.FixedDuration');
+var Rickshaw = require("../rickshaw");
function seriesData() {
return {
View
@@ -1,8 +1,4 @@
-require('../src/js/Rickshaw');
-require('../src/js/Rickshaw.Class');
-require('../src/js/Rickshaw.Series');
-require('../src/js/Rickshaw.Fixtures.Color');
-require('../src/js/Rickshaw.Color.Palette');
+var Rickshaw = require("../rickshaw");
function seriesData() {
return {
@@ -85,7 +81,7 @@ exports.dump = function(test) {
series.dump(),
{
"timeBase":0,
- "timeInterval": undefined,
+ "timeInterval": 1,
"items":[{
"color":"red",
"name":"series1",
View
@@ -0,0 +1 @@
+<svg width="960" height="500"><circle cx="9.41084207430644" cy="95.87795514245306" r="6" fill="steelblue"></circle><circle cx="244.68189393196744" cy="4.950495049505037" r="6" fill="steelblue"></circle><circle cx="479.9529457896284" cy="116.08405738533042" r="6" fill="steelblue"></circle><circle cx="715.2239976472895" cy="196.90846635683977" r="6" fill="steelblue"></circle><circle cx="950.4950495049504" cy="176.70236411396246" r="6" fill="steelblue"></circle></svg>

0 comments on commit cedf9d0

Please sign in to comment.