01.05.2017 Views

348957348957

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ased data visualizations. Vector graphics require a lot less bandwidth than images because vector<br />

graphics contain only instructions for how to draw them, as opposed to the final pixel-by-pixel<br />

raster renderings of images. If your goal is to rapidly deploy web-based graphics that also provide<br />

you lossless scaling capabilities, then SVG is a perfect solution. SVG is optimal for use in<br />

creating graphical elements such as bars, lines, and markers.<br />

You can use D3.js to select, add, modify, or remove SVG elements on a page, in just the<br />

same way you do with HTML elements. Since D3.js is most useful for working with webbased<br />

graphical elements, most of your D3.js scripting will interact with SVG elements.<br />

Bringing in the Cascading Style Sheets (CSS)<br />

The purpose of using Cascading Style Sheets (CSS) is to define the look of repeated visual<br />

elements, such as fonts, line widths, and colors. You can use CSS to specify the visual<br />

characteristics of page elements all at one time and then efficiently apply these characteristics to<br />

an entire HTML document (or to only the parts of the document defined in the DOM, if you wish).<br />

If you want to make sweeping, all-at-once changes to the look and feel of your web page elements,<br />

use CSS.<br />

If you’re building visualizations on several pages of a website, you can create a separate<br />

document .css file, and then call that document instead of putting CSS in each page. If you do<br />

this, then when you make a change to this .css document, it will be applied to the pages<br />

collectively.<br />

As an example, the basic CSS for a simple web page might include the following:<br />

<br />

p {<br />

font-family: arial, verdana, sans-serif;<br />

font-size: 12 pt;<br />

color: black;<br />

}<br />

.highlighted {<br />

color: red;<br />

}<br />

<br />

The preceding example would render the text in this HTML example:<br />

This text is black and this text is red.<br />

The preceding CSS and HTML code generates text in the tag that has a default value of black,<br />

whereas the inner object is designated as a highlighted class and generates a red-colored text.<br />

D3.js leverages CSS for drawing and styling text elements and drawn elements so that you can<br />

define and change the overall look of your visualization in one compact, easy-to-read block of<br />

code.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!