D3: .scaleBand, .rangeRound, .padding: Ordinal Scale with Range Bands including Padding

Forked script below was converted from D3.js v3 to v4.

nick3499
1 min readMar 2, 2017
Fig.1

Comparing the two gists below:

  • v4’s .scaleBand() replaced v3's .scale.ordinal().
  • v4’s .rangeRound() and .padding() replaced v3’s rangeRoundBands().
  • .padding() is a convenience method which sets both paddingInner and paddingOuter values to the same value, see Fig.1.
  • v4’s console.log(bands.bandwidth()) replaced v3’s console.log(bands.rangeband()).

Forked v4 script above. Original v3 script below.

D3.js 3.5.17 seems to have a similar existence to Python 2.7.13. Maintained to avoid alienating v3 users.

--

--

nick3499
nick3499

Written by nick3499

coder of JavaScript and Python

No responses yet