shawnbot/topogram

Cartogram does not seem to load

TomFevrier opened this issue · 0 comments

Hey there!

It seems the cartogram library is not loading... When it gets to d3.cartogram() my code simply stops there without issuing any error message. Here is my code, "test 1" is logged but not "test 2":

Cartogram.prototype.createMap = function() {

	let that = this;

	this.projection = d3.geoConicConformal()
		.center([2.454071, 46.279229])
		.scale(2600)
		.translate([this.width / 2, this.height / 2]);

	this.path = d3.geoPath()
		.projection(this.projection);

	this.map = this.svg.append('g');

	console.log("test 1")

	this.cartogram = d3.cartogram()
		.projection(this.projection)
		.properties(function(d) {
	        return that.nested[d.properties.nom];
		});

	console.log("test 2")

	this.features = this.cartogram.features(this.regions, this.regions.objects.regions.geometries);

   	this.map = this.map.data(this.features)
		.enter().append('path')
			.attr('fill', '#fafafa')
			.attr('d', that.path);

}

I imported all the necessary libraries in my index.html:

<script src='https://d3js.org/d3.v5.js'></script>
<script src="https://unpkg.com/topojson@3"></script>
<script type='text/javascript' src='lib/cartogram.js'></script>
<script type='module' src='main.js'></script>

Thanks for your help!