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.
CSS Tutorial: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_started
Draw negative numbers in red and positive numbers in green. RED
<span style="color:green">43</span>
// <positive>43</positive>
<span style="color:green">21</span>
// <positive>21</positive>
<span style="color:red">-13</span>
// <negative>-13</negative>
<span style="color:green">32</span>
// <positive>32</positive>
<span style="color:green">20</span>
// <positive>20</positive>
<span style="color:green">5</span>
// <positive>5</positive>
<span style="color:red">-8</span>
// <negative>-8</negative>
<span style="color:green">29</span>
// <positive>29</positive>
<span style="color:green">9</span>
// <positive>9</positive>
(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.