Skip to content
Advertisement

d3.scaleBand not a function

Shouldn’t it work with this library? <script src="https://d3js.org/d3.v4.js"> I’ve tried all the libraries that I can find about this and none of them get rid of this error. Any help would be great.

var x = d3.scaleBand().rangeRound([10, width]).padding(0.4),
    y = d3.scaleLinear().rangeRound([height, 20]);

Advertisement

Answer

Instead of

var x = d3.scaleBand().rangeRound([10, width]).padding(0.4),
y = d3.scaleLinear().rangeRound([height, 20]);

Change .padding to .paddingInner like such

var x = d3.scaleBand().rangeRound([10, width]).paddingInner(0.4),
y = d3.scaleLinear().rangeRound([height, 20]);

Thanks to Darren Sweeney for the answer.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement