I'm converting a D3 script from V3 and V5.
In the V3 script, it uses rangeBands
like this
width = 510
height = 570
var grpcnts = {
met: { '1960': 0, '1970': 0, '2010': 0, label: "First Met", x: 1, y: 1 },
romantic: { '1960': 0, '1970': 0, '2010': 0, label: "Romantic", x: 2, y: 1 },
lived: { '1960': 0, '1970': 0, '2010': 0, label: "Live Together", x: 3, y: 1 },
married: { '1960': 0, '1970': 0, '2010': 0, label: "Married", x: 4, y: 3 },
}
var x = d3.scale.ordinal()
.domain([1950, 1970, 1980, 2010])
.rangeBands([0, width]);
var y = d3.scale.ordinal()
.domain(d3.keys(grpcnts))
.rangeBands([height, 0]);
I tried to replace it with bandwidth()
according to this thread, but that served this error.
Uncaught TypeError: d3.scaleOrdinal(...).domain(...).bandwidth is not a function
I also tried range
, but that didn't do it either. What's the right replacement for rangeBands
in V5?
Please see the section right above this for reasons why this is not a duplicate.