Test driving your visualization – SVG rendering

Now we have the basic skeleton of our bar chart object created, and we feel that we are ready to try to render something, so in this second iteration we will try to generate the svg:svg element.

How to do it...

Rendering the svg:svg element should not only simply add the svg:svg element to the HTML body, but also translate the width and height setting on our chart object to proper SVG attributes. Here is how we express our expectation in our test cases:

describe('.render', function () { describe('svg', function () { it('should generate svg', function () { chart.render(); expect(svg()).not.toBeEmpty(); }); it('should set default svg height and width', function () { chart.render(); expect(svg().attr('width')).toBe('500'); ...

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.