Created
July 25, 2016 19:12
-
-
Save classiemilio/9a422290b9f29c7beccd3d9cd591e5b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Implementation */ | |
function getXScale(dimensions, data) { | |
var range = [0, dimensions.width]; | |
var domain = [0, data.length - 1]; | |
return d3.scale.linear().domain(domain).range(range); | |
} | |
/* Test */ | |
describe('#getXScale', function() { | |
it('returns the correct domain and range', function() { | |
var data = [0, 5, 10, 30, 50]; | |
var dimensions = { | |
width: 100, | |
height: 300 | |
}; | |
var scale = getXScale(dimensions, data); | |
assert.deepEqual(scale.range(), [0, 100]); | |
assert.deepEqual(scale.domain(), [0, 4]); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment