I’m currently having difficulty referencing an external .tsv file into an HTML file referencing the d3.js library. The code works, but I do not know where the reference the .tsv file, and therefore the dataset, from. Anyone encounter this problem before?
Hi,
Could you please elaborate more on what you try to build.
From what I understand you use the HTML element in order to use d3.js.
Which code doesn’t work? you don’t see the visualization you created or you can’t load data. It would be great if you add a code sample.
Shay
Hi Shay, here are the .js, .css, .html, and .csv file with the small dataset. What I dont know how to do is to reference the .csv file into the .js script (can’t load data). Any help would be appreciated. Thank you
You need to reference both files with a fully qualified URL to their location on another server. Based on the images you provided, I see that both files are on your local machine.
in the case you don’t have such a server:
-
For chartAuto.js content inline with your main code.
-
For the data.csv you could use your site database collection to manage the data and pass it to the HTML element when the page loads. See https://www.wix.com/code/reference/$w.HtmlComponent.html
Thank you Shay!
Hi Shay,
I’m super stumped. I tried hosting the website through the Microsoft Internet Information Services (IIS) on my machine, but it creates a http:// protocol, so I tried following the directions below. This didn’t work.
I then tried hosting the following URL from Mike Bostock’s website: https://bl.ocks.org/mbostock/raw/4062045/ by embedding it as a webite address. This didn’t work either.
I then tried by importing th .csv file into a database on wix, but have no idea where to start linking the dataset into the HTML code, and really don’t know where to start with the link you provided above: https://www.wix.com/code/reference/$w.HtmlComponent.html . Is there a video you can point me to that shows how to link an external dataset into a HTML?
Regarding the javascript file, you probably need to add chartAuto.js at the end of the URL. Once you paste the URL into the browser address and see the file, paste it into the code.
Regarding the data:
-
When the page loads you need to query your database for the content, see https://www.wix.com/code/reference/wix-data.html#query
-
Once you have the data you need to pass it to the HTML element, pass it to the iframe. See HtmlComponent - Velo API Reference - Wix.com for a code example.
-
Once you implemented onMessage on the iframe side and you have the data in the iframe, you’d need to dig in and look for the best API in d3.js to push the data.