You don't go into the details of how you're calling the different methods, but here's a few general tips on how to work with them:
fitExtent or the short hand version
fitSize should definitely make your object appear on the SVG if you're not applying any other transformations. A minimum working example would be:
const proj = d3.geoAlbers() .fitSize([width, height], wisconsin)
That should result in a nicely fitted, albeit not correctly rotated Wisconsin. If it doesn't,
wisconsin is not a valid GeoJSON object, ie not a
Feature or geometric object.
The next question is how to fix the rotation. For conic projections, as I understand, you generally want to find the center of your object of interest and rotate by the inverse of the longitude. A very friendly StackOverflow user explained the details here: https://stackoverflow.com/a/41133970/4745643
In the case of Wisconsin the center of the state has a longitude of almost exactly -90°, so we do this:
const proj = d3.geoAlbers() .rotate([90, 0, 0]) .fitSize([width, height], wisconsin)
Note that we're rotating the map before we fit the object into our SVG. As a general rule of thumb, you should apply spherical transforms before zooming and fitting your map (I shall follow up with a more detailed explanation in a moment).
That should leave you with a nicely rotated and fitted state:
- Center and Rotate Projection in d3 v4
- How can I use SVG translate to center a d3.js projection to given latitude and longitude values?
- How to compute projection rotate and graticule extend for d3.js satellite projection
- rotate and center globe on click
- Combining translate and rotate with D3
- Circle clip and projection with D3 orthographic
- How to rotate an object around the center in d3.js
- nvd3.js-Line Chart with View Finder: rotate axis labels and show line values when mouse over
- Map with d3.js and TopoJSON, Albers Siberia projection
- d3.js: How to rotate an SVG around its center while translating?
- How do I rotate or scale (transform) an SVG path relative to its center point?
- Scale and Center D3-Graphviz Graph
- How can I rotate d3 chart and how can I start pie chart from angle -90?
- D3.js: Set fitExtent or fitSize (or center and scale programmatically) for map with multiple geoJSON files
- d3 center tick and x-axis label when single value
- Drawing different colored "strokes" between center and different nodes in a D3.js tree
- D3 - Center and scale sector on map
- What is the proper way to both rotate and translate text in d3?
- My cities are being plotted with the wrong projection (quite small and to the left). Using d3.geo.albersUSA()
- How to drag and rotate orthographic map (globe) using d3.js
- How to apply rotate transformation and don't change the coordinates system in D3.js?
- Multiple maps with d3.js: change values of scale and center
- d3 bar chart with fixed bar width and fixed spacing to align in center axis line
- Given latitude and longitude, plotting points on D3 geo projection
- How to center and scale using geoPath
- Placing elements on circle line and rotating them towards the center using D3.js
- How to rotate and change font size on x axis
- D3 force layout change links into paths and place arrows on node edge instead of center
- What kind of projection to use for D3 and topojson maps of Mexican cities?
- geoJSON projection with d3.js and dc.js for South Africa and provinces
More Query from same tag
- Drawing a simple graph using projected lines
- Merging nodes in D3.js
- creating drop shadow on a rectangle and a circle on top of it
- How to correctly update the text value of an input element in a d3.js transition
- How to show full text when zoom in & truncate it when zoom out
- Mouseover is not working in d3.js by attaching it to circles
- d3 bar chart y axis ticks and grid lines above max value
- How do I position tooltips to follow a data point to which it is attached in D3?
- Marimekko chart cell titles not updating
- Using D3 with Shiny - Collapsible Tree?
- Alternating tick padding in d3.js
- How to get the axis ticks of Plotly's scatter plot to be shown in Latex using Python? --- [Python, Plotly, Latex Representation]
- Find the maximum value in an object where the keys are arrays?
- In D3 bar graph, y-axis ordinal scale is not aligning properly with bars
- Remove or clear previously drawn dimple chart
- Get d3 to show correct dates based on timestamp
- set initial zoom level at d3.js tree (dynamically)
- I want to use charts and graphs for visualizing data.Need some recommendation as D3js that I am using is not responsive
- Large gap between columns in D3js column chart
- dc.js Stacked Bar Chart having only one column and with elastic X Axis is not rendered properly
- Date ticks for lineplusbar nvd3
- Updating force-graph on D3. Graph duplicates instead of updating
- Passing data to d3.svg.line()
- D3 descending scale
- multi-ring pie chart using d3js
- How do I display a diagram created with rcharts within my R shiny app?
- Issues with x and y axis of a bar chart with d3
- d3.js and dashcode: anyone tried and won?
- How to select existing chart and update it in NVD3.js