Coder Social home page Coder Social logo

The world countries showing problem about vega HOT 10 CLOSED

vega avatar vega commented on May 4, 2024
The world countries showing problem

from vega.

Comments (10)

wrobstory avatar wrobstory commented on May 4, 2024

It's some sort of error in the mercator projection- try using something like equirectangular or winkel3, and the map looks a little more normal.

from vega.

tony612 avatar tony612 commented on May 4, 2024

@wrobstory thx.
I tried, it's better than mercator, but it seems there is still something wrong:
When I don't hover over on the map it is:
image
Then when I hover over:
image
The opacity of the countries should become 0.5 but not. and there is the blue background and opacity of it turns 0.5. (PS: I think the background of it should be transparent)
And the winkel3 project has the same problem.

from vega.

RutgerK avatar RutgerK commented on May 4, 2024

I had the same problem with Mercator.

@tony612, there is probably some error in the geojson geometries. I can replicate it if i use yours. When i made my own geojson by exporting the "Natural Earth 110n countries" shapefile with ogr2ogr it works as expected. In the picture i'm hovering China, all geometries seem to work fine.

vega_equi_map

from vega.

tony612 avatar tony612 commented on May 4, 2024

I used this data, global_world to show the map, it shows normally. I think there is something wrong with my data. :)

But the mercator has not been fixed.

Has someone tried to fix it?

from vega.

mbostock avatar mbostock commented on May 4, 2024

The first error is because Vega presumably inherits D3’s default projection, d3.geo.albersUsa which as you might guess is U.S.-specific. (It’s a composite projection for the 48 contiguous United States, Alaska, Hawaii and Puerto Rico.) You’ll need to specify a different projection for a world map; choose one of the many other available projections.

The other error looks like a problem with winding order in your GeoJSON file, where the polygons are not in clockwise order. I’m not sure if Vega supports TopoJSON yet, but I highly recommend it as you can get much smaller data files (as well as the useful applications of topology). Here’s an example:

Screen Shot 2013-04-24 at 9 26 17 PM

from vega.

tony612 avatar tony612 commented on May 4, 2024

@mbostock Thanks. I have tried to specify the projection as 'mercator', but it doesn't work well. Maybe there's something wrong as @wrobstory said.

I don't know if Vega support TopoJSON, this wiki only mentions the geoJSON

from vega.

jheer avatar jheer commented on May 4, 2024

As @mbostock points out above, it appears that the GeoJSON file used above has an error in it, which should explain the undesirable behavior.

In addition, commit c77bd25 fixes Vega's geopath to use mercator as the default (as stated in the spec documentation). Thanks for catching the bug! Also, Vega largely inherits D3's extensive geographic mapping facilities. TopoJSON support has not been tested, but we will do so soon.

from vega.

tony612 avatar tony612 commented on May 4, 2024

@jheer Is there something wrong with the GeoJSON file in the Vega's live editor?
In this editor, http://trifacta.github.io/vega/editor/index.html?spec=map, If you change the projection to mercator, you can see the same bug.

from vega.

jheer avatar jheer commented on May 4, 2024

The problem you are seeing is an albersUsa projection being used by accident. This was fixed in my earlier commit. However, the fix has not been posted to the live website yet. If you run the Vega editor locally using the most recent version in the repo, you'll see that geopath with mercator projection now works correctly.

from vega.

tony612 avatar tony612 commented on May 4, 2024

@jheer Thanks, it works normally. It's my mistake :)

from vega.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.