0

Probably there is something really simple that I'm missing but my question is this:

I am new to d3 and nvd3, and am trying to use them to plot a graph. However, everytime I open the browser console it says: "Reference Error: nv not defined".

This is what I am doing:

<html>
<head>
  <meta charset="utf-8">
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
  <script src="https://d3js.org/d3.v3.min.js"></script>
  <script src="C:/Users/mou1av/Desktop/novus-nvd3-v1.8.2-168-g254a7b3/novus-nvd3-254a7b3/build/nv.d3.js"></script>
  <script src="C:/Users/mou1av/Desktop/novus-nvd3-v1.8.2-168-g254a7b3/novus-nvd3-254a7b3/build/nv.d3.min.js"></script>
 <link rel="stylesheet" type="text/css" href="C:\Users\mou1av\Desktop\novus-nvd3-v1.8.2-168-g254a7b3\novus-nvd3-254a7b3\build\nv.d3.css">

</head>

<script>

 nv.addGraph(function(){
 ... //graph code

 </script>

 <body>
 </body>
 </html>

I tried all the steps in this question: NVD3.js: ReferenceError: nv is not defined

but I believe I am using all the right paths to my nvd3.js and nvd3.min.js. Can someone tell me what's wrong? Thank you.

Community
  • 1
  • 1
manuel mourato
  • 801
  • 1
  • 12
  • 36
  • Why are you including both nv.d3.js and its minified version (nv.d3.min.js)? Try removing one of them. Also check if all the files are actually loaded (in Chrome: developer console -> sources) – Luc Apr 12 '16 at 10:54
  • @Luc already tried that, first removed one and then the other, same error. – manuel mourato Apr 12 '16 at 10:57
  • Could you try to reference files from a cdn instead? (e.g. https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.2/nv.d3.min.css and https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.2/nv.d3.min.js) – Luc Apr 12 '16 at 11:01
  • @Luc, it worked! Thank you so much. I'm still curious about the reason why it didn't work the way I was doing it, but still, fantastic. – manuel mourato Apr 12 '16 at 11:09
  • 1
    You're welcome! I think it's similar to this problem: http://stackoverflow.com/questions/4090712/why-cant-i-do-img-src-c-localfile-jpg . You could try prepending "file://" to your local file paths. I also believe that directory separators should always be regular slashes (not backslashes like in your path to your css file). – Luc Apr 12 '16 at 11:16

0 Answers0