Comments (3)
Great, i got it working.
first defining, almost exactly as you suggested
collection = {type: "FeatureCollection", features: thecarto.features};
topology = topojson.topology({collection: collection});
then drawing/coloring the regions
mapg.selectAll(".subunit2").data(thecarto.features).enter().append("path") .attr("class","subunit2") .attr("d", carto.path) .attr('fill',function(d){return getcolor(coldata[d.id]);});
then i loop over all countries, merging the regions, and drawing the country borders
// countrylist Array [ "AT", "BE", "BG", "CY", "CZ", "DE", "DK", "EE", "ES", "FI", 18 more⦠]
countrylist.forEach(function(d) {
var ctr = topojson.mergeArcs(topology,topology.objects.collection.geometries.filter(function(z) {return (z.id.substring(0,2) == d);}));
mapg.append("path").datum(topojson.mesh(topology,ctr)).attr("d", carto.path).attr("class", "cartoctrborder").style("stroke", "black").style("stroke-width", bordersize_ctr).style("fill", "none");
});
thanks a bunch!
from topogram.
Yeah, I think the problem is that TopoJSON won't work with the plain old Feature objects that topogram returns. You should be able to recreate a topology with something like:
var collection = {type: 'FeatureCollection', features: features};
var topology = topojson.topology(collection);
And then you can run topojson.merge()
and/or topojson.mesh()
on the resulting topology. Let me know if that works!
from topogram.
No problem!
from topogram.
Related Issues (20)
- Cartogram of countries of the world display error HOT 16
- Does anyone know if this would enable nvd3 in IE8? HOT 1
- page starts out with no attribute selected HOT 1
- Comment Example Doesn't Have Correct Number of Variables HOT 6
- How can make d3-cartogram works on a NULL projection? HOT 1
- Area Scaling HOT 1
- Feature? Absolute scaling of cartogram regions HOT 3
- Uncaught TypeError: Cannot read property '0' of null HOT 1
- cartogram.js receive help to coordinate directly.
- I'm trying to read data not from .csv, but i have no idea. HOT 2
- Make this repo a d3-plugin
- Publish to npm HOT 2
- example is not working: pointing to wrong file HOT 1
- can't find build/topogram.js HOT 2
- Cartogram does not seem to load
- Needs modification to work with d3 v3 HOT 7
- debugger can not pause code
- sum() routine is wrong HOT 1
- Needs modification to work with topojson.v1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from topogram.