Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
/* 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