In the intro class, you made bar charts by writing plain <svg>
tags. Imagine
having to do that for lots and lots of data points! No way.
This week, your learning task is to learn how to utilize a template engine to automate the creation of svg-based data visualization. Fortunately, gitbook has a template engine built-in already, which is nunjuncks. Below are working examples how to utilize the for tag to render a whole bunch of elements.
The rectangles below are also generated using the tag.
Now it's your team's turn to work together to complete the challenges below.
Draw negative numbers in red and positive numbers in green.
(Hint: use the if tag)
<table>
, <tr>
, <td>
10 | 15 |
20 | 12 |
31 | 42 |
12 | 52 |
33 | 24 |
<circle>
to represent each data point.Now each data point has three values. Extend the previous solution. Use size of the circle to represent the third value.