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

Require d3 directly to better support Node usage #107

Merged
merged 1 commit into from
Jan 20, 2015
Merged
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
17,251 changes: 12,993 additions & 4,258 deletions dist/mermaid.full.js

Large diffs are not rendered by default.

28 changes: 16 additions & 12 deletions dist/mermaid.full.min.js

Large diffs are not rendered by default.

17,241 changes: 12,988 additions & 4,253 deletions dist/mermaid.slim.js

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions dist/mermaid.slim.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"license": "MIT",
"dependencies": {
"chalk": "^0.5.1",
"d3": "~3.4.13",
"dagre-d3": "~0.3.2",
"he": "^0.5.0",
"minimist": "^1.1.0",
Expand Down Expand Up @@ -71,6 +72,7 @@
"mock-browser": "^0.90.27",
"path": "^0.4.9",
"phantomjs": "^1.9.12",
"proxyquire": "^1.3.1",
"rewire": "^2.1.3",
"rimraf": "^2.2.8",
"semantic-ui": "^1.4.1",
Expand Down
15 changes: 15 additions & 0 deletions src/diagrams/sequenceDiagram/d3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* global window */

var d3;

if (require) {
try {
d3 = require("d3");
} catch (e) {}
}

if (!d3) {
d3 = window.d3;
}

module.exports = d3;
20 changes: 10 additions & 10 deletions src/diagrams/sequenceDiagram/sequenceDiagram.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
/**
* Created by knut on 14-11-18.
*/
var proxyquire = require('proxyquire');

var newD3;
var d3 = {
select:function(){
return new newD3();
}
};
var sq = require('./parser/sequenceDiagram').parser;
var sd = require('./sequenceRenderer');
var sd = proxyquire('./sequenceRenderer', { './d3': d3 });

var str;
describe('when parsing a sequenceDiagram',function() {
Expand Down Expand Up @@ -480,7 +488,7 @@ describe('when rendering a sequenceDiagram',function() {
};
sq.yy.parseError = parseError;

function newD3() {
newD3 = function() {
var o = {
append: function (type) {
return newD3();
Expand Down Expand Up @@ -508,16 +516,8 @@ describe('when rendering a sequenceDiagram',function() {
};

return o;
}

var _d3 = {
select:function(){
return new newD3();
}
};

d3 = _d3;

conf = {
diagramMarginX:50,
diagramMarginY:10,
Expand Down
2 changes: 1 addition & 1 deletion src/diagrams/sequenceDiagram/sequenceRenderer.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* globals d3 */
/**
* Created by knut on 14-11-23.
*/

var sq = require('./parser/sequenceDiagram').parser;
sq.yy = require('./sequenceDb');
var svgDraw = require('./svgDraw');
var d3 = require('./d3');
var conf = {

diagramMarginX:50,
Expand Down