1

I want to embed some d3 visualizations into my Wix.com website using Add > html.

I found an awesome geojson file with all of the coordinates of the Chicago community areas that I need. Its perfect. http://www.chicagohealthatlas.org/map/healthcare_providers_dentists.json

So the next step I wanted to achieve was to create a script for this geodata in the website to make an interactive map where I will display information for each community depending on which one was selected. However, wix.com does not support d3, and I am only receiving a blank html text box. Here is the code I tried:

<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> 
<script> 
var width= 960, height = 500; 
var path = d3.geo.path().projection(projection);

var svg = d3.select("Chicago_b&w.jpg").append("svg").attr("width",width).attr("height", height); 

d3.json("http://www.chicagohealthatlas.org/map/healthcare_providers_dentists.json",
function(json))
{
     svg.selectAll("path").data(json.features).enter().append("path").attr("d", path); 

     var projection = d3.geo.mercator()
     .center([0, 5 ])
     .scale(900)
     .rotate([-180,0]);
     var g = svg.append("g");  
});
</script>

I think part of the problem is that I am not using iframes. But even before that, it this the way to do such a thing? Would this also work if the geodata was in a text file that I cannot connect to the Wix server?

I would really appreciate help, I am quite lost.

Also, Chicago_b&w.jpg is an image that I have imported to my wix website and am using on a few pages.

3
  • Where do you want the SVG? You can't select the image like this, and appending an SVG to the image won't work either. You probably want to append it to the body of the page? Also, you can't load data from a different URL like this because of browser security restrictions. Host the file on your website. Sep 21, 2014 at 15:08
  • With the restrictions of wix, i cant host the file on my website. Wix is a website that creates everything for you and then publishes it. It gives you the option of adding small html scripts but not to the main frame of code. But the svg is supposed to be in the body. Sep 21, 2014 at 15:13
  • From my own use of Wix, I can tell you that it really doesn't like you using your own scripts. Their websites are entirely JS-dependent: they don't even display if JS is disabled, so using your own scripts could clash with this so they don't like it. At all.
    – ArtOfCode
    Sep 21, 2014 at 18:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.