Published
Edited
Sep 21, 2020
Insert cell
md`# Day Twenty Three (Task 9-2), 2020-09-16`
Insert cell
md`
- 9-1. \`return "rgb(0, 0, " + Math.round(d*10) + ")"\`. You are not allowed to have space between \`rgb\` and \`(\`.
`
Insert cell
md` ## Task 9-2

- 9-2-1. Make changes so that every time you click, new data will show up with transitions. The new data will be an array of random **integers** with values between 0 and 24. Let the new array have the same length as the original one (the one before any updates). *Hint* : Use a \`for\` loop.

- 9-2-2. Add extra logical to set the vertical placement and style of labels. "When the data value is less than or equal to 1, place the label up above the bar and set its fill to black. Otherwise, place and style the label normally"(p. 167).

- 9-2-3. We earlier used \`Math.random() * 25\`. Repalce \`25\` with a variable \`maxValue\`. Set the \`maxValue\` to be \`100\`. Remember to update the \`yScale\`.

**Note** : \`Math.random()\` generate random number from 0 up to, but not including 1.
`
Insert cell
md`
- 9-2-4. Based on the results we got from Task 8, do the following: 1. Delete the CSS for .axis path, line, and text; 2. Let the radius of each circle be a constant: 2 px. Then, do the following:
1. Rename the class of xAxis as \`x axis\` and that of yAxis as \`y axis\`.
2. When people click on the text "Click here for new data", a new pair of 50 integers between 0 and 100 will show up. Make transitions to these changes and set the duration to be 1 second. Make sure that scales, and both the axes are also updated. *Hint* : to update the axes, first select the axis, and make a transition, set the transition's duration, and call the axis generator.

- 9-2-5. Make changes to the code so that when you click the trigger, the fill of all the circles changes to magenta, and the radius becomes 3 px. When the transition is over, the fill changes to black and the radii become 2px.
- *Hint* : Within circle-updating code, use two \`.on()\` statements, whithin which you need to first specify whether it's \`start\` or \`end\`, and then use an anonymous function to first select the current element and set the attributions.

- 9-2-6. Add a transition (which lasts for 1 second) to the start of the transtion and see what happend.
`
Insert cell
md`
Go to [Day 24](https://observablehq.com/@hongtaoh/untitled).
`
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more