NOTE: This answer was written for version 2 of d3. Version 3 is out now, and it has awesome new features that create better geometry segmentation and solve the fill issue mentioned below. Also, the interface for setting up projections _may_ have changed in V3 (not sure bc I haven't tried).
There is a json file available for the entire world, and you can render it equivalently to the us-states.json coropleth (using an Albers equal area projection) – assuming you understand (and are ok with) the fact that an Albers-projected world map looks like this, which is not quite how most people recognize a world map.
Then you need to render the world json data using a customized Albers projection:
scale() values can be tweaked to get different results.
There's a problem with Antartica, which – due to the nature of this projection – gets "flipped" and is not a closed shape, so its fill covers the whole world. You either have to remove it from the json, or don't apply fill to it.
Also for some reason Brazil (and couple of others) didn't get rendered properly when I tried this. Dunno why. You'd have to examine the svg and the data to figure out why.
- How to create a choropleth of the world using d3?
- How to create correlogram using D3 as in the example picture
- How do I create a minimap of an SVG using D3 v5 and show the current viewport dimensions?
- Using d3 in meteor on windows 8.1, how can I display a world map, zoomed in on the US, with country borders and US state borders?
- Using d3, how can I create a histogram or bar plot where the last bar is the count of all values greater than some number?
- How to create a new array using the data from the old one?
- How to Create different kinds of grid lines using D3 in the same graph
- How do I get the width of an svg element using d3js?
- How do I create a tree layout using JSON data in d3.v4 - without stratify()
- how to create labels for data in donut chart using d3.js
- how to create multiline chart using dc.js
- How to get the vertically-oriented tree using d3.js
- How to create a reusable component in D3 with an API that manipulates each instance of the component?
- Reusable charts in d3: how do the create and update selections work?
- How do I create a <dl> using d3.js
- How to update elements of an HTML that the elements are created using data from a CSV file?
- how to add legend to a pie chart using D3js? And how to centralise the pie chart?
- How to set circle at the right end of the last bar / item using D3
- How can I achieve the R kernel density estimate plot using D3.js?
- How to group by multiple keys at the same time using D3?
- How to create a responsive map using d3
- How to place text on the circle when using D3.js force layout?
- How to plot animated line chart using d3 while the data table is required to be updated every 1 second?
- How can I remove a line from the 110m TopoJson world map?
- How to create a histogram using d3.js and crossfilter data?
- How can i get the startAngle and endAngle of each arc in the sunburst example using d3.js?
- How to assign the center of d3.forceRadial dynamically using functions?
- How to get value from the element using selection in d3
- How to visualize the graph using d3Network in R
- mpld3: How to change the location of the toolbar using a plugin?
More Query from same tag
- focus+context graph in d3
- d3.js inner bubble chart
- D3 adding to multiple divs (Data Binding JSON)
- D3.js adding/removing data pie chart slices
- C3js chart lines hides after grunt build
- topoJSON on D3: map doesn't show (but it works on www.mapshaper.org)
- How to select text on onClick event of pie chart?
- D3 V4, How can I have a tick mark at every data point, but a label at only select data points
- d3 chord diagram on angular2
- Minimap for D3JS
- Basic question about accessing an array column
- Sorting large CSV in D3.js
- Wrapping words in d3 to get one word in one line
- d3 graph - How do I make the JS get the JSON from PHP script and then select axes and plot?
- Replacing chart datasets with d3.js / c3.js
- d3+crossfilter: Date-axis renders pixelthin bars
- Append svg from file in D3
- How build a sunburst diagram that responds to a slider
- Apply mapping to attached data
- What does .html() mean?
- How to import and use a modified npm library packages dynamically
- d3 adding drag and drop to packed circles
- How do I create a D3.js tree layout with custom child nodes?
- Dynamically resize a div when it is used as a node in a d3 force-directed graph
- How to setup svg to change position when resizing the window?
- D3.js abort transition and prevent end event
- D3.js Bubble Chart from csv
- Create color range with radial gradients using d3.js
- Draw curve between two points using diagonal function in d3 js