Comments (7)
👍 I don't mind working on a pull request if anyone can hint about a possible cause.
from topogram.
The problem seems to be that v3's projection functions work differently than v2's. @mbostock, can you provide a hint?
from topogram.
https://github.com/mbostock/d3/wiki/3.0
https://github.com/mbostock/d3/wiki/Upgrading-to-3.0
from topogram.
Thanks for the hints. Every 32nd point (with a few exceptions), the algorithm seems to insert a diagonally offset coordinate:
Point 1: M738.6410891318739,288.6117802470147
18.64099944406587,-71.38842446507579
18.640909754354652,-71.38862917712373
[...]
-1.089590636644175,-84.48670347140757
-1.090580345942044,-84.48688700598365
Point 33: 718.9084298790658,275.5129294610754
-1.0919136122784039,-84.48703876147886
-1.0922570996749528,-84.48700698383607
[...]
Point 65: 702.9690598895354,277.89646070245584
-17.030943323429927,-82.10357075652627
-17.030946536420732,-82.1036022155083
[...]
Point 97: 702.6845670620858,275.83483610874566
I haven't been able to find the solution yet but will look deeper into the mapping of arcs to screen space:
Row 38: // project the arcs into screen space
var tf = transformer(topology.transform),
projectedArcs = topology.arcs.map(function(arc) {
var x = 0, y = 0;
return arc.map(function(coord) {
coord[0] = (x += coord[0]);
coord[1] = (y += coord[1]);
return projection(tf(coord));
});
});
@shawnbot: What do you think?
from topogram.
I would probably use the browser's debugger to step through the code as it is running to understand what is happening. There could be many reasons why this isn't working, and without being familiar with the code it's difficult for me to say what the problem is.
I suspect it might be caused by d3.geo's adaptive resampling of the projection, which detects areas of distortion. When you pass in a bare function as the projection to d3.geo.path, it gets wrapped in a resampling projection stream (see d3_geo_pathProjectStream); an instance of d3.geo.projection in contrast adds rotation and clipping, in addition to resampling, to the projection stream.
Adaptive resampling requires that the geometry being transform is expressed in spherical coordinates, so if you pass in Cartesian coordinates, you're going to have a bad time. If you want to use the identity projection (i.e., pass projected Cartesian coordinates to d3.geo.path and disable resampling), then in V3 you should set path.projection(null) rather than passing in the identity function. Otherwise the adaptive resampling will introduce intermediate points in your geometry using great-arc interpolation, because it assumes each polygonal segment is a great arc.
from topogram.
Thanks @mbostock! Passing null instead of the identity was all it took. Have submitted the fix.
from topogram.
💥
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
- topojson.merge topojson.mesh HOT 3
- 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
- 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.