dagrejs / dagre-d3

A D3-based renderer for Dagre
MIT License
2.87k stars 592 forks source link

Demo pages in bower package not working #109

Closed whitelynx closed 10 years ago

whitelynx commented 10 years ago

After doing bower install dagre-d3, the demo pages included in the bower package do not function. For instance, when opening demo/interactive-demo.html in Chromium, I get no graph, and see these errors in the console (Firefox gets errors too, but they're different ones):

GET http://localhost:8081/build/dagre-d3.js                       interactive-demo.html:8
Uncaught ReferenceError: dagreD3 is not defined                 interactive-demo.html:141
Uncaught TypeError: Cannot read property 'apply' of undefined                d3.v3.js:897

Looking closer, it's trying to pull in ../build/dagre-d3.js, which no longer exists:

<script src="http://d3js.org/d3.v3.js"></script>
<script src="http://cpettitt.github.io/project/graphlib-dot/v0.5.2/graphlib-dot.js"></script>
<script src="../build/dagre-d3.js"></script>

Changing the <script> tag to reference the correct path (../dist/dagre-d3.core.js), I then see these errors instead:

Uncaught TypeError: Cannot read property 'layout' of undefined       dagre-d3.core.js:764
Uncaught ReferenceError: dagreD3 is not defined                 interactive-demo.html:141
Uncaught TypeError: Cannot read property 'apply' of undefined                d3.v3.js:897

Since the bower package only includes the dagre-d3.core.* files (which are built with browserify --no-bundle-external), we need to include dagre and lodash as well:

<script src="http://d3js.org/d3.v3.js"></script>
<script src="http://cpettitt.github.io/project/graphlib-dot/v0.5.2/graphlib-dot.js"></script>
<script src="http://cpettitt.github.io/project/dagre/v0.6.2/dagre.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js"></script>
<script src="../dist/dagre-d3.core.js"></script>

After making that change, it works as expected.

Possibly related to #100.

cpettitt commented 10 years ago

Ahh, the demo files aren't meant to be in the bower package. I'll remove them.