Test driving your visualization – pixel-perfect bar rendering

In this iteration we will finally generate the bars using the data we have. Through our test cases we will make sure all bars are not only rendered but rendered with pixel-perfect precision.

How to do it...

Let's see how we test it:

describe('chart body', function () { it('should create body g', function () { chart.render(); expect(chartBody()).not.toBeEmpty(); }); it('should translate to (left, top)', function () { chart.render(); expect(chartBody().attr('transform')).toBe('translate(30,10)') }); }); describe('bars', function () { beforeEach(function () { chart.data(data).width(100).height(100) .x(d3.scale.linear().domain([0, 3])) .y(d3.scale.linear().domain([0, 6])) .render(); }); it('should ...

Get Data Visualization with D3.js Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.