d3.js like scale in Swift