0

I tried to modify from this sample . https://bl.ocks.org/mbostock/1346395

I build a index.html and data.tsv with those codes inside .

Then ,I change <script src="//d3js.org/d3.v3.min.js"></script> to <script src="https://d3js.org/d3.v3.min.js"></script>

As a result , no charts are shown on index.html

Whats wrong with it?

I put index.html and data.tsv in same directory

the code I have made changes

<script src="//d3js.org/d3.v3.min.js"></script>
<script>....

to

<script src="https://d3js.org/d3.v3.js"></script>
<script>..... 

Result:

Console : enter image description here

Community
  • 1
  • 1
evalwt
  • 105
  • 1
  • 8

1 Answers1

0

I guess the problem is - you need a local server to test it with your local data. d3.tsv() - makes ajax call so it needs a server.

kurumkan
  • 2,635
  • 3
  • 31
  • 55
  • yes , I didn't host on my localhost. I just treat as simple html and js. Can I use xmapp to perform it ? Or any simple methods which don't require local server – evalwt Apr 30 '17 at 01:49
  • Anything that can return you that file after a request - is actually a server. I believe you can go with xampp as well. – kurumkan Apr 30 '17 at 01:59
  • may I change tsv file to dom file ,so that I no need to run server? – evalwt Apr 30 '17 at 02:07
  • what do you mean `dom file`? You will need a server anyway. Remote or local. It's up to you. It will not work over `file://` – kurumkan Apr 30 '17 at 02:19
  • I try running a local server .I put the index.html along with data.tsv .That is still not working . – evalwt Apr 30 '17 at 02:23
  • how do you require the file? url please – kurumkan Apr 30 '17 at 02:27
  • I just put two file index.html & data.tsv under the htdoc .And I make change to `` in `index.html` .What url you refer to ?my server? – evalwt Apr 30 '17 at 02:31
  • what url you put in parenthesis in tsv() – kurumkan Apr 30 '17 at 02:33
  • `d3.tsv("data.tsv", type, function(error, data) {` Just follow the sample code – evalwt Apr 30 '17 at 02:43
  • Should be my typo. Thanks anyway .One more last question .There are two items and subpages :apple & oranges in the sample .What place should I make changes in codes if I want to add new items – evalwt Apr 30 '17 at 02:48
  • for the `data.tsv`, can I just add a new column with the notepad – evalwt Apr 30 '17 at 02:51
  • Yes you can add new entries right in to data.tsv - and if no mistakes - the visualization will change accordingly. Yes you can use notepad app. – kurumkan Apr 30 '17 at 03:00