0

http://jsfiddle.net/amanminhas16/KUf7f/

var root = {
    "name"    : "Total Number Of Users",
    "size"    : 50000,
    "children": [{
        "name":"user A"
    },
    {
        "name":"user B"
    },
    {
        "name":"user C"
    },
    {
        "name":"user D"
    },
      ]
};

this was inspired by

http://jsfiddle.net/augburto/YMa2y/

But even if i get the exact code, i do not get a graph output. If i copy my code into his jsfiddle, it gives me my desired result. can you tell me what could be the issue ?

i am using WAMP + Zend.

Thank you in adv.

Aman
  • 623
  • 1
  • 11
  • 23
  • 1
    For one thing, you need to add D3 to the fiddle...dropbox on left titled Frameworks & Extensions...pick D3. – FernOfTheAndes Feb 24 '14 at 18:29
  • FernOfTheAndes. Great, that worked, but still it does not work on my localhost. :-/ . the exact same code, copy pasted with this additional line : – Aman Feb 24 '14 at 18:37
  • what is the error message you get? – FernOfTheAndes Feb 24 '14 at 18:39
  • Uncaught ReferenceError: d3 is not defined tree:472 Failed to load resource: net::ERR_CONNECTION_REFUSED I thought this err would go away with this : – Aman Feb 24 '14 at 18:40
  • try with the http protocol added: `` – FernOfTheAndes Feb 24 '14 at 18:45
  • That did not work either, i read online that may be chrome has a problem with the http and https, i tried both, none worked. I also tried on mozilla firefox. but no success there either. – Aman Feb 24 '14 at 18:52
  • In the meantime, you could resort to downloading D3 to your machine and just pointing to the local copy. – FernOfTheAndes Feb 24 '14 at 18:54
  • Also I found this online . But the solution they came up with was to download the zip file. I would rather not do that and use the CDN in an effective way. :/ – Aman Feb 24 '14 at 19:00
  • d3 is defined now, when i type d3 in console it gives me : Object {version: "3.4.2", ascending: function, descending: function, min: function, max: function…}. But now : Uncaught TypeError: Object [object Object] has no method 'live'. All i did is remove charsef = "utf-8" – Aman Feb 24 '14 at 19:22
  • I have not yet used version 3.4.2. But not having the utf-8 has created problems in the past, particularly with the non-minimized version. See [this useful entry](https://github.com/mbostock/d3/issues/1195). – FernOfTheAndes Feb 24 '14 at 19:55
  • May b i could use an older version, where can i find the CDN for it if you know. Also i find this very strange that the same code works in jsfiddle but not on my machine :/ aah.. – Aman Feb 24 '14 at 20:03
  • but at the moment the error im trying to fight is this one : Uncaught TypeError: Object [object Object] has no method 'live' – Aman Feb 24 '14 at 20:04
  • FernOfTheAndes - You were much help, I cannot thank you enough. I found the solution. I just had to place my js code within $(document).ready(dunction(){ // here }) .:D .Thank you again my friend. – Aman Feb 24 '14 at 20:15
  • Ah...an unsuspecting reason, as it can often happen. Re. help, YMW :) – FernOfTheAndes Feb 24 '14 at 20:21

2 Answers2

0

The documentation page explains quite well how to setup d3 in your localhost.

You have to:

  • include d3.js in your page using: <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>

  • start a python server if you want to access local files using: python -m SimpleHTTPServer 8888 &

Christopher Chiche
  • 15,075
  • 9
  • 59
  • 98
0

Thanks a lot for your suggestion.

But actually, The problem was that i did not put my javascript code in

$(document).ready(function(){//here})

It works great now :) ..

Thank you Christopher and FernOfTheAndes for all the help

Aman
  • 623
  • 1
  • 11
  • 23