Search code examples
javascriptrequirejstopojson

require.js error (topojson not loading)


Can anyone help me understand/fix this error?

Uncaught ReferenceError: topojson is not defined

I am new to requireJS and don't fully understand it.

Thank you in advance!

require.config({
  paths: {
  	d3: "//cdnjs.cloudflare.com/ajax/libs/d3/3.5.3/d3.min",
  	geo: "//d3js.org/d3.geo.projection.v0.min",
  	topo: "//d3js.org/topojson.v1.min"
 },
 shim: {
 	geo: {
 		deps: ["d3"]
 	},
 	topo:{
 		deps: ["d3","geo"]
 	}
 }

 
});

require(["d3","geo","topo"],function(){
	$(document).ready(RecruitingData.ondomready);
	$(document).bind('framework.resize',RecruitingData.scalescharts());
	$(document).bind('framework.resize',RecruitingData.scalescharts1());	
	$(document).bind('framework.resize',RecruitingData.linechart());	
	$(document).bind('framework.resize',RecruitingData.mapchart());	
})


Solution

  • I don't know anything about require.js but looking at the api, you are missing the arguments to your require callback:

    require(["d3","geo","topo"],function(d3,geo,topojson){
        // you can now use topojson!
    });
    

    Example here.