diff --git a/client/src/pages/learn/data-visualization/d3-dashboard/index.md b/client/src/pages/learn/data-visualization/d3-dashboard/index.md new file mode 100644 index 0000000000..0ceb538921 --- /dev/null +++ b/client/src/pages/learn/data-visualization/d3-dashboard/index.md @@ -0,0 +1,8 @@ +--- +title: Introduction to the D3 Dashboard Project Challenges +block: D3 Dashboard Project +superBlock: Data Visualization +--- +## Introduction to the D3 Dashboard Project Challenges + +D3 Dashboard Project Placeholder Introduction. diff --git a/client/utils/challengeTypes.js b/client/utils/challengeTypes.js index ad915c4069..47dc953ac0 100644 --- a/client/utils/challengeTypes.js +++ b/client/utils/challengeTypes.js @@ -136,5 +136,6 @@ exports.helpCategory = { 'basic-javascript-rpg-game': 'JavaScript', 'functional-programming-spreadsheet': 'JavaScript', 'intermediate-javascript-calorie-counter': - 'Intermediate JavaScript Calorie Counter' + 'Intermediate JavaScript Calorie Counter', + 'd3-dashboard-project': 'JavaScript' }; diff --git a/curriculum/challenges/_meta/d3-dashboard/meta.json b/curriculum/challenges/_meta/d3-dashboard/meta.json new file mode 100644 index 0000000000..f92c8e9ca2 --- /dev/null +++ b/curriculum/challenges/_meta/d3-dashboard/meta.json @@ -0,0 +1,602 @@ +{ + "name": "D3 Dashboard Project", + "dashedName": "d3-dashboard", + "order": 4, + "time": "5 hours", + "template": "", + "required": [ + { + "src": "https://cdnjs.cloudflare.com/ajax/libs/d3/5.9.2/d3.min.js" + } + ], + "superBlock": "data-visualization", + "superOrder": 4, + "challengeOrder": [ + [ + "5d8a4cfbe6b6180ed9a1c9de", + "Part 1" + ], + [ + "5d8a4cfbe6b6180ed9a1c9df", + "Part 2" + ], + [ + "5d8a4cfbe6b6180ed9a1c9e0", + "Part 3" + ], + [ + "5d8a4cfbe6b6180ed9a1c9e1", + "Part 4" + ], + [ + "5d8a4cfbe6b6180ed9a1c9e2", + "Part 5" + ], + [ + "5d8a4cfbe6b6180ed9a1c9e3", + "Part 6" + ], + [ + "5d8a4cfbe6b6180ed9a1c9e4", + "Part 7" + ], + [ + "5d8a4cfbe6b6180ed9a1c9e5", + "Part 8" + ], + [ + "5d8a4cfbe6b6180ed9a1c9e6", + "Part 9" + ], + [ + "5d8a4cfbe6b6180ed9a1c9e7", + "Part 10" + ], + [ + "5d8a4cfbe6b6180ed9a1c9e8", + "Part 11" + ], + [ + "5d8a4cfbe6b6180ed9a1c9e9", + "Part 12" + ], + [ + "5d8a4cfbe6b6180ed9a1c9ea", + "Part 13" + ], + [ + "5d8a4cfbe6b6180ed9a1c9eb", + "Part 14" + ], + [ + "5d8a4cfbe6b6180ed9a1c9ec", + "Part 15" + ], + [ + "5d8a4cfbe6b6180ed9a1c9ed", + "Part 16" + ], + [ + "5d8a4cfbe6b6180ed9a1c9ee", + "Part 17" + ], + [ + "5d8a4cfbe6b6180ed9a1c9ef", + "Part 18" + ], + [ + "5d8a4cfbe6b6180ed9a1c9f0", + "Part 19" + ], + [ + "5d8a4cfbe6b6180ed9a1c9f1", + "Part 20" + ], + [ + "5d8a4cfbe6b6180ed9a1c9f2", + "Part 21" + ], + [ + "5d8a4cfbe6b6180ed9a1c9f3", + "Part 22" + ], + [ + "5d8a4cfbe6b6180ed9a1c9f4", + "Part 23" + ], + [ + "5d8a4cfbe6b6180ed9a1c9f5", + "Part 24" + ], + [ + "5d8a4cfbe6b6180ed9a1c9f6", + "Part 25" + ], + [ + "5d8a4cfbe6b6180ed9a1c9f7", + "Part 26" + ], + [ + "5d8a4cfbe6b6180ed9a1c9f8", + "Part 27" + ], + [ + "5d8a4cfbe6b6180ed9a1c9f9", + "Part 28" + ], + [ + "5d8a4cfbe6b6180ed9a1c9fa", + "Part 29" + ], + [ + "5d8a4cfbe6b6180ed9a1c9fb", + "Part 30" + ], + [ + "5d8a4cfbe6b6180ed9a1c9fc", + "Part 31" + ], + [ + "5d8a4cfbe6b6180ed9a1c9fd", + "Part 32" + ], + [ + "5d8a4cfbe6b6180ed9a1c9fe", + "Part 33" + ], + [ + "5d8a4cfbe6b6180ed9a1c9ff", + "Part 34" + ], + [ + "5d8a4cfbe6b6180ed9a1ca00", + "Part 35" + ], + [ + "5d8a4cfbe6b6180ed9a1ca01", + "Part 36" + ], + [ + "5d8a4cfbe6b6180ed9a1ca02", + "Part 37" + ], + [ + "5d8a4cfbe6b6180ed9a1ca03", + "Part 38" + ], + [ + "5d8a4cfbe6b6180ed9a1ca04", + "Part 39" + ], + [ + "5d8a4cfbe6b6180ed9a1ca05", + "Part 40" + ], + [ + "5d8a4cfbe6b6180ed9a1ca06", + "Part 41" + ], + [ + "5d8a4cfbe6b6180ed9a1ca07", + "Part 42" + ], + [ + "5d8a4cfbe6b6180ed9a1ca08", + "Part 43" + ], + [ + "5d8a4cfbe6b6180ed9a1ca09", + "Part 44" + ], + [ + "5d8a4cfbe6b6180ed9a1ca0a", + "Part 45" + ], + [ + "5d8a4cfbe6b6180ed9a1ca0b", + "Part 46" + ], + [ + "5d8a4cfbe6b6180ed9a1ca0c", + "Part 47" + ], + [ + "5d8a4cfbe6b6180ed9a1ca0d", + "Part 48" + ], + [ + "5d8a4cfbe6b6180ed9a1ca0e", + "Part 49" + ], + [ + "5d8a4cfbe6b6180ed9a1ca0f", + "Part 50" + ], + [ + "5d8a4cfbe6b6180ed9a1ca10", + "Part 51" + ], + [ + "5d8a4cfbe6b6180ed9a1ca11", + "Part 52" + ], + [ + "5d8a4cfbe6b6180ed9a1ca12", + "Part 53" + ], + [ + "5d8a4cfbe6b6180ed9a1ca13", + "Part 54" + ], + [ + "5d8a4cfbe6b6180ed9a1ca14", + "Part 55" + ], + [ + "5d8a4cfbe6b6180ed9a1ca15", + "Part 56" + ], + [ + "5d8a4cfbe6b6180ed9a1ca16", + "Part 57" + ], + [ + "5d8a4cfbe6b6180ed9a1ca17", + "Part 58" + ], + [ + "5d8a4cfbe6b6180ed9a1ca18", + "Part 59" + ], + [ + "5d8a4cfbe6b6180ed9a1ca19", + "Part 60" + ], + [ + "5d8a4cfbe6b6180ed9a1ca1a", + "Part 61" + ], + [ + "5d8a4cfbe6b6180ed9a1ca1b", + "Part 62" + ], + [ + "5d8a4cfbe6b6180ed9a1ca1c", + "Part 63" + ], + [ + "5d8a4cfbe6b6180ed9a1ca1d", + "Part 64" + ], + [ + "5d8a4cfbe6b6180ed9a1ca1e", + "Part 65" + ], + [ + "5d8a4cfbe6b6180ed9a1ca1f", + "Part 66" + ], + [ + "5d8a4cfbe6b6180ed9a1ca20", + "Part 67" + ], + [ + "5d8a4cfbe6b6180ed9a1ca21", + "Part 68" + ], + [ + "5d8a4cfbe6b6180ed9a1ca22", + "Part 69" + ], + [ + "5d8a4cfbe6b6180ed9a1ca23", + "Part 70" + ], + [ + "5d8a4cfbe6b6180ed9a1ca24", + "Part 71" + ], + [ + "5d8a4cfbe6b6180ed9a1ca25", + "Part 72" + ], + [ + "5d8a4cfbe6b6180ed9a1ca26", + "Part 73" + ], + [ + "5d8a4cfbe6b6180ed9a1ca27", + "Part 74" + ], + [ + "5d8a4cfbe6b6180ed9a1ca28", + "Part 75" + ], + [ + "5d8a4cfbe6b6180ed9a1ca29", + "Part 76" + ], + [ + "5d8a4cfbe6b6180ed9a1ca2a", + "Part 77" + ], + [ + "5d8a4cfbe6b6180ed9a1ca2b", + "Part 78" + ], + [ + "5d8a4cfbe6b6180ed9a1ca2c", + "Part 79" + ], + [ + "5d8a4cfbe6b6180ed9a1ca2d", + "Part 80" + ], + [ + "5d8a4cfbe6b6180ed9a1ca2e", + "Part 81" + ], + [ + "5d8a4cfbe6b6180ed9a1ca2f", + "Part 82" + ], + [ + "5d8a4cfbe6b6180ed9a1ca30", + "Part 83" + ], + [ + "5d8a4cfbe6b6180ed9a1ca31", + "Part 84" + ], + [ + "5d8a4cfbe6b6180ed9a1ca32", + "Part 85" + ], + [ + "5d8a4cfbe6b6180ed9a1ca33", + "Part 86" + ], + [ + "5d8a4cfbe6b6180ed9a1ca34", + "Part 87" + ], + [ + "5d8a4cfbe6b6180ed9a1ca35", + "Part 88" + ], + [ + "5d8a4cfbe6b6180ed9a1ca36", + "Part 89" + ], + [ + "5d8a4cfbe6b6180ed9a1ca37", + "Part 90" + ], + [ + "5d8a4cfbe6b6180ed9a1ca38", + "Part 91" + ], + [ + "5d8a4cfbe6b6180ed9a1ca39", + "Part 92" + ], + [ + "5d8a4cfbe6b6180ed9a1ca3a", + "Part 93" + ], + [ + "5d8a4cfbe6b6180ed9a1ca3b", + "Part 94" + ], + [ + "5d8a4cfbe6b6180ed9a1ca3c", + "Part 95" + ], + [ + "5d8a4cfbe6b6180ed9a1ca3d", + "Part 96" + ], + [ + "5d8a4cfbe6b6180ed9a1ca3e", + "Part 97" + ], + [ + "5d8a4cfbe6b6180ed9a1ca3f", + "Part 98" + ], + [ + "5d8a4cfbe6b6180ed9a1ca40", + "Part 99" + ], + [ + "5d8a4cfbe6b6180ed9a1ca41", + "Part 100" + ], + [ + "5d8a4cfbe6b6180ed9a1ca42", + "Part 101" + ], + [ + "5d8a4cfbe6b6180ed9a1ca43", + "Part 102" + ], + [ + "5d8a4cfbe6b6180ed9a1ca44", + "Part 103" + ], + [ + "5d8a4cfbe6b6180ed9a1ca47", + "Part 104" + ], + [ + "5d8a4cfbe6b6180ed9a1ca48", + "Part 105" + ], + [ + "5d8a4cfbe6b6180ed9a1ca49", + "Part 106" + ], + [ + "5d8a4cfbe6b6180ed9a1ca4a", + "Part 107" + ], + [ + "5d8a4cfbe6b6180ed9a1ca4b", + "Part 108" + ], + [ + "5d8a4cfbe6b6180ed9a1ca4c", + "Part 109" + ], + [ + "5d8a4cfbe6b6180ed9a1ca4d", + "Part 110" + ], + [ + "5d8a4cfbe6b6180ed9a1ca4e", + "Part 111" + ], + [ + "5d8a4cfbe6b6180ed9a1ca4f", + "Part 112" + ], + [ + "5d8a4cfbe6b6180ed9a1ca50", + "Part 113" + ], + [ + "5d8a4cfbe6b6180ed9a1ca51", + "Part 114" + ], + [ + "5d8a4cfbe6b6180ed9a1ca52", + "Part 115" + ], + [ + "5d8a4cfbe6b6180ed9a1ca53", + "Part 116" + ], + [ + "5d8a4cfbe6b6180ed9a1ca54", + "Part 117" + ], + [ + "5d8a4cfbe6b6180ed9a1ca55", + "Part 118" + ], + [ + "5d8a4cfbe6b6180ed9a1ca56", + "Part 119" + ], + [ + "5d8a4cfbe6b6180ed9a1ca57", + "Part 120" + ], + [ + "5d8a4cfbe6b6180ed9a1ca58", + "Part 121" + ], + [ + "5d8a4cfbe6b6180ed9a1ca59", + "Part 122" + ], + [ + "5d8a4cfbe6b6180ed9a1ca5a", + "Part 123" + ], + [ + "5d8a4cfbe6b6180ed9a1ca5b", + "Part 124" + ], + [ + "5d8a4cfbe6b6180ed9a1ca5c", + "Part 125" + ], + [ + "5d8a4cfbe6b6180ed9a1ca5d", + "Part 126" + ], + [ + "5d8a4cfbe6b6180ed9a1ca5e", + "Part 127" + ], + [ + "5d8a4cfbe6b6180ed9a1ca5f", + "Part 128" + ], + [ + "5d8a4cfbe6b6180ed9a1ca60", + "Part 129" + ], + [ + "5d8a4cfbe6b6180ed9a1ca61", + "Part 130" + ], + [ + "5d8a4cfbe6b6180ed9a1ca62", + "Part 131" + ], + [ + "5d8a4cfbe6b6180ed9a1ca63", + "Part 132" + ], + [ + "5d8a4cfbe6b6180ed9a1ca64", + "Part 133" + ], + [ + "5d8a4cfbe6b6180ed9a1ca65", + "Part 134" + ], + [ + "5d8a4cfbe6b6180ed9a1ca66", + "Part 135" + ], + [ + "5d8a4cfbe6b6180ed9a1ca67", + "Part 136" + ], + [ + "5d8a4cfbe6b6180ed9a1ca68", + "Part 137" + ], + [ + "5d8a4cfbe6b6180ed9a1ca6a", + "Part 138" + ], + [ + "5d8a4cfbe6b6180ed9a1ca6b", + "Part 139" + ], + [ + "5d8a4cfbe6b6180ed9a1ca6c", + "Part 140" + ], + [ + "5d8a4cfbe6b6180ed9a1ca6d", + "Part 141" + ], + [ + "5d8a4cfbe6b6180ed9a1ca6e", + "Part 142" + ], + [ + "5d8a4cfbe6b6180ed9a1ca6f", + "Part 143" + ], + [ + "5d8a4cfbe6b6180ed9a1ca70", + "Part 144" + ], + [ + "5d8a4cfbe6b6180ed9a1ca71", + "Part 145" + ], + [ + "5d8a4cfbe6b6180ed9a1ca72", + "Part 146" + ] + ], + "helpRoom": "Help", + "fileName": "04-data-visualization/d3-dashboard.json" +} \ No newline at end of file diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-1.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-1.english.md new file mode 100644 index 0000000000..ea9ea73448 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-1.english.md @@ -0,0 +1,50 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9de +title: Part 1 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Welcome to the dashboard project! You will be using the JavaScript data visualization library, D3, to build a visualization of your social media followers. It will consist of a line graph, a pie chart, and a legend. + +First, you need to create the HTML file. Start by adding the `` declaration at the top of the file to tell the browser what type of document it's reading. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(//gi.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html +``` + +
+
+ + +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-10.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-10.english.md new file mode 100644 index 0000000000..51dbc8c8e3 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-10.english.md @@ -0,0 +1,95 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9e7 +title: Part 10 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Give the container some space by adding a `padding` of `100px 10px` to the `body` element. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const body = code.match(/body\s*{[\s\S]+?[^}]}/g)[0]; assert(/padding\s*:\s*100px\s*10px\s*(;|})/g.test(body)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-100.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-100.english.md new file mode 100644 index 0000000000..52ccff216d --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-100.english.md @@ -0,0 +1,392 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca41 +title: Part 100 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The pie graph is being drawn at the `0, 0` coordinates of the SVG. Back on your `pieGraphData` variable, add an attribute that changes the `transform` to `translate(100, 100)`. + +Since the pie chart has a radius of 100, and the SVG is 200 by 200, this will move it so it is centered. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const transform = $('.dashboard div svg g')[0].getAttribute('transform'); assert(/translate\s*\(\s*100\s*,\s*100\s*\)/g.test(transform)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-101.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-101.english.md new file mode 100644 index 0000000000..0bdbcb3390 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-101.english.md @@ -0,0 +1,397 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca42 +title: Part 101 +challengeType: 0 +isBeta: true +--- + +## Description + +
+ +Back at the bottom, where you draw the chart. Use the `attr` function to set the `fill` to a "d function". In the "d function", use your `pieColors` scale to get the color value for the platform(`d.data.key`). So when each platform is passed to your scale, is will get the appropriate color to use as the fill from the scales range. +
+ +## Instructions + +
+
+ +## Tests + +
+ +```yml +tests: + - text: test-text + testString: const pathsArr = $('.dashboard div svg g path'); assert(pathsArr[0].getAttribute('fill') === '#7cd9d1' && pathsArr[1].getAttribute('fill') === '#f6dd71' && pathsArr[2].getAttribute('fill') === '#fd9b98'); + +``` + +
+ +## Challenge Seed + +
+
+ +```html + + +``` + +
+ +### Before Test + +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ +## Solution + +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-102.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-102.english.md new file mode 100644 index 0000000000..f6f1f5fa99 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-102.english.md @@ -0,0 +1,381 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca43 +title: Part 102 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Next, set the `stroke` to `white` and the `stroke-width` to `2`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const pathsArr = $('.dashboard div svg g path'); assert(pathsArr[0].getAttribute('stroke') === 'white' && pathsArr[0].getAttribute('stroke-width') == 2); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-103.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-103.english.md new file mode 100644 index 0000000000..ea52ee66a6 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-103.english.md @@ -0,0 +1,386 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca44 +title: Part 103 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Your chart needs some labels in each slice. On a new line, append `text` elements to your `pieGraphData` variable. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/pieGraphData\s*\.\s*append\s*\((`|'|")text\1\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-104.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-104.english.md new file mode 100644 index 0000000000..96185c6b15 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-104.english.md @@ -0,0 +1,403 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca47 +title: Part 104 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Chain a `text` function to set the text of each pie slice to a percentage. Set the value to a "d function" with curly brackets and leave the function empty for now. It should look like this: + +```js +.text(d => { + +}) +``` + +The method for getting the percent of each slice will take a few steps: + +1. Find the total number of followers for the displayed year +2. Divide the followers of a single platform by that total +3. Turn it into a string to display + +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/\.append\('text'\)\s*\.text\s*\(\s*d\s*=>\s*\{\s*\}\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-105.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-105.english.md new file mode 100644 index 0000000000..c38504f669 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-105.english.md @@ -0,0 +1,400 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca48 +title: Part 105 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +In the function you just created, create a `const` named `values`. Use the `d3.values` function to get the values of the 2020 followers and set the result to your `values` variable. Here's how to get the values: + +```js +d3.values(data[8].followers) +``` + +It will be an array with the values of the followers for the three platforms in 2020. + +Note that this "d function" has curly brackets. So you could `console.log(values)` in there to see it's value. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const\s*values\s*=\s*d3\s*\.\s*values\s*\(\s*data\s*\[\s*8\s*\]\s*\.\s*followers\s*\);?/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-106.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-106.english.md new file mode 100644 index 0000000000..f4894aee01 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-106.english.md @@ -0,0 +1,393 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca49 +title: Part 106 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Since you want to find what percent each of those `values` is, you first need to add them all up. `d3.sum` will do that for you. Create a new `const` named `sum` and set it equal to `d3.sum(values)`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const\s*sum\s*=\s*d3\s*\.\s*sum\s*\(\s*values\s*\)\s*;?/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-107.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-107.english.md new file mode 100644 index 0000000000..a8219f25ba --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-107.english.md @@ -0,0 +1,395 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca4a +title: Part 107 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Create another variable named `percent` and set it equal to `d.data.value` divided by your `sum` variable. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const\s*percent\s*=\s*d\s*\.\s*data\s*\.\s*value\s*\/\s*sum;?/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-108.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-108.english.md new file mode 100644 index 0000000000..b2218674f2 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-108.english.md @@ -0,0 +1,405 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca4b +title: Part 108 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Your percent values are numbers less than one. You will need to multiply it by 100, round of the decimals, and add a `%` sign. Use a template literal to return this to the `text` function: + +```js +${Math.round(percent * 100)}% +``` + +Don't forget that you need a `return` statement here since you aren't using an implicit return. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/return\s*`\$\{\s*Math\s*\.\s*round\s*\(\s*percent\s*\*\s*100\s*\)\s*\}%`;?\s*\}\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-109.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-109.english.md new file mode 100644 index 0000000000..3e742957ba --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-109.english.md @@ -0,0 +1,404 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca4c +title: Part 109 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The text elements are at the center of the pie graph, you need to use the `centroid` from the D3 arc API to tell them where to go. Add an `attr` function to set the `transform` to a `d` function that returns this template literal: `translate(${ pieArc.centroid(d) })` + +The `centroid` function will find the midpoint of each slice for each text element. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const transform = $('.dashboard div svg g text')[0].getAttribute('transform').replace('translate(','').replace(')','').split(','); assert(transform[0] < 39 && transform[1] > 31); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-11.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-11.english.md new file mode 100644 index 0000000000..e848b11cb2 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-11.english.md @@ -0,0 +1,98 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9e8 +title: Part 11 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Later on, you will be adding more elements to the dashboard container. Set the `display` to `flex` and the `align-items` to `center` so those items will be vertically centered. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const dashboard = $(".dashboard"); assert(dashboard.css("display") === "flex" && dashboard.css("align-items") === "center"); + +``` + +
+ +## Challenge Seed +
+
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-110.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-110.english.md new file mode 100644 index 0000000000..2a0c0e5c3c --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-110.english.md @@ -0,0 +1,406 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca4d +title: Part 110 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The function you just added, placed the start of the text at the midpoint of each slice. Change the `style` of the text to give it a `text-anchor` of `middle` so the middle of the text is in the middle of the slice. + +After that, set the `font` to `10px verdana`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const text = $('.dashboard div svg g text')[0]; assert(text.style.textAnchor === 'middle' && text.style.font.toLowerCase() === '10px verdana'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-111.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-111.english.md new file mode 100644 index 0000000000..32408e80e7 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-111.english.md @@ -0,0 +1,408 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca4e +title: Part 111 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The last component you are going to add is a legend to display the name of each platform and the number of followers for the year. Create a new `const` named `legend` and use it to `append` a `table` to your `rightDashboard` variable. This looks similar to the code where you created your `pieGraph` variable. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const\s*legend\s*=\s*rightDashboard\s*\.\s*append\s*\(\s*('|"|`)\s*table\s*\1\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-112.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-112.english.md new file mode 100644 index 0000000000..0ee8c3f032 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-112.english.md @@ -0,0 +1,412 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca4f +title: Part 112 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Give the table a `width` of `200` and a `height` of `120` using `attr`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const table = $('.dashboard div table')[0]; assert(table.getAttribute('width') == 200 && table.getAttribute('height') == 120); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-113.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-113.english.md new file mode 100644 index 0000000000..f399e98efb --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-113.english.md @@ -0,0 +1,415 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca50 +title: Part 113 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Set the `font` to `12px verdana` using the `style` function. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.dashboard div table')[0].style.font.toLowerCase() === '12px verdana'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-114.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-114.english.md new file mode 100644 index 0000000000..fb8d204726 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-114.english.md @@ -0,0 +1,418 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca51 +title: Part 114 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Create a new `const` named `legendTitle` and use it to `append` a `thead` to your `legend` variable. `thead` is used with the HTML table element and is for the top row of the table. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const\s*legendTitle\s*=\s*legend\s*\.\s*append\s*\(\s*('|"|`)\s*thead\s*\1\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-115.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-115.english.md new file mode 100644 index 0000000000..4311f55c36 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-115.english.md @@ -0,0 +1,422 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca52 +title: Part 115 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +`append` a `tr` element to the selection and then append a `th` element right after it. `tr` is for defining a row of the table, and `th` is for defining the header cells of the table. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.dashboard div table thead tr th').length === 1); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-116.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-116.english.md new file mode 100644 index 0000000000..f3b7a70202 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-116.english.md @@ -0,0 +1,425 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca53 +title: Part 116 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Use the `text` function to set the text of the selection to `2020 followers`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.dashboard div table thead tr th').text() === '2020 followers'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-117.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-117.english.md new file mode 100644 index 0000000000..bf708b8874 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-117.english.md @@ -0,0 +1,427 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca54 +title: Part 117 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Your table is going to have three columns, one for the platform name, one for the color it is using on your dashboard, and a third to display the number of followers. So you want the title to take up all three columns. Set the `colspan` attribute of the `th` to `3` so it spans all three of these columns. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.dashboard div table thead tr th')[0].getAttribute('colspan') == 3); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-118.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-118.english.md new file mode 100644 index 0000000000..d02cc61a37 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-118.english.md @@ -0,0 +1,429 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca55 +title: Part 118 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Create a new `const` named `legendRows` and use it to `append` a `tbody` element to your `legend` variable similar to how you added the `thead`. `tbody` is for the main content of an HTML table. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const\s*legendRows\s*=\s*legend\s*\.\s*append\s*\(\s*('|"|`)\s*tbody\s*\1\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-119.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-119.english.md new file mode 100644 index 0000000000..fdc74b8c47 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-119.english.md @@ -0,0 +1,434 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca56 +title: Part 119 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add a `selectAll` function to the selection and pass it the string `tr`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const legendRows = legend\.append\('tbody\s*'\)\s*\.\s*selectAll\s*\(\s*('|"|`)\s*tr\s*\1\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-12.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-12.english.md new file mode 100644 index 0000000000..f981d95595 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-12.english.md @@ -0,0 +1,99 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9e9 +title: Part 12 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Back in the HTML file, add a `script` tag at the bottom of the head element and give it a `src` attribute of `./d3-5.9.2.min.js`. Don't forget the closing tag. This will add the D3 library to your project from a downloaded copy. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const script = code.match(/]>\s*<\/script\s*>/gi)[0]; assert(/src\s*=\s*('|")\s*(\.\/)?d3-5.9.2.min.js\s*\1/gi.test(script)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + + + D3 Dashboard + + + + + + +
+ + +``` + +
+ + +### Before Test +
+ +```html + +``` + +
+
+ + +## Solution +
+ +```html + + + + D3 Dashboard + + + + + + + +
+ + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-120.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-120.english.md new file mode 100644 index 0000000000..3210912a14 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-120.english.md @@ -0,0 +1,434 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca57 +title: Part 120 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Use the `data` function to set the data for the rows to an array of your 2020 followers. To get the array use `d3.entries(data[8].followers)`. Remember, this will create an array of key/value pairs of your followers for that year. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/\.selectAll\('tr'\)\s*\.\s*data\s*\(\s*d3\s*\.\s*entries\s*\(\s*data\s*\[\s*8\s*\]\s*\.\s*followers\s*\)\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-121.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-121.english.md new file mode 100644 index 0000000000..1b7c1fdde8 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-121.english.md @@ -0,0 +1,439 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca58 +title: Part 121 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add the `enter` and `append` functions to the selection. Pass the string `tr` to the append function to add three table row elements. These elements will be for displaying each platform's name. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.dashboard div table tbody tr').length === 3); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-122.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-122.english.md new file mode 100644 index 0000000000..e60aa86106 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-122.english.md @@ -0,0 +1,443 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca59 +title: Part 122 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +On a new line, `append` a `td` to your `legendRows` variable. `td` is for an individual cell in the row of the table. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.dashboard div table tbody tr td').length === 3); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-123.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-123.english.md new file mode 100644 index 0000000000..7657174b06 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-123.english.md @@ -0,0 +1,445 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca5a +title: Part 123 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Use the `text` function to set the text of each `td` to the `key` of each data point by using a "d function" to return `d.key`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.dashboard div table tbody tr td').text() === 'twittertumblrinstagram'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-124.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-124.english.md new file mode 100644 index 0000000000..912be90346 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-124.english.md @@ -0,0 +1,448 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca5b +title: Part 124 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +This is the first column of your table. Set the `align` attribute to `right` to align the text to the right of each cell. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.dashboard div table tbody tr td')[0].getAttribute('align').toLowerCase() === 'right'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-125.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-125.english.md new file mode 100644 index 0000000000..92efdf7e92 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-125.english.md @@ -0,0 +1,451 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca5c +title: Part 125 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +On a new line, append another `td` element to your `legendRows` variable. This will be for colored squares in the center column. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.dashboard div table tbody tr td').length === 6); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-126.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-126.english.md new file mode 100644 index 0000000000..36a92d5d87 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-126.english.md @@ -0,0 +1,454 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca5d +title: Part 126 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Set the `align` attribute to `center`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.dashboard div table tbody tr td')[1].getAttribute('align').toLowerCase() === 'center'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-127.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-127.english.md new file mode 100644 index 0000000000..79ef2da62a --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-127.english.md @@ -0,0 +1,456 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca5e +title: Part 127 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Append a `div` element to the selection. Each `div` will be a small square for each color. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.dashboard div table tbody tr td div').length === 3); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-128.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-128.english.md new file mode 100644 index 0000000000..c5f5672a31 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-128.english.md @@ -0,0 +1,458 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca5f +title: Part 128 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Set the `width` to `16px` and the `height` to `16px` using the `style` function. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const div = $('.dashboard div table tbody tr td div')[0]; assert(div.style.width == '16px' && div.style.height === '16px'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-129.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-129.english.md new file mode 100644 index 0000000000..8d7b682ebc --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-129.english.md @@ -0,0 +1,461 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca60 +title: Part 129 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Using the `style` function again, set the `background-color` of each div to a "d function". Using the "d function", pass the key(`d.key`) of each data point to your `pieColors` scale so it knows what color to use. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.dashboard div table tbody tr td div')[0].style.backgroundColor === 'rgb(124, 217, 209)'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-13.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-13.english.md new file mode 100644 index 0000000000..53ea256e6c --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-13.english.md @@ -0,0 +1,116 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9ea +title: Part 13 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add another `script` below the one you just added. Give it a `src` attribute of `./data.js`. + +This adds a `data` variable to your project that contains your number of social media followers, it is an array of objects. Each object has the year and your followers for three different platforms. You will see what it looks like shortly. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const script = code.match(/]>\s*<\/script\s*>/gi)[1]; assert(/src\s*=\s*('|")\s*(\.\/)?data.js\s*\1/gi.test(script)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + + + D3 Dashboard + + + + + + + +
+ + +``` + +
+ + +### Before Test +
+ +```html + + +``` + +
+
+ + +## Solution +
+ +```html + + + + D3 Dashboard + + + + + + +
+ + + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-130.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-130.english.md new file mode 100644 index 0000000000..c35b62c631 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-130.english.md @@ -0,0 +1,464 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca61 +title: Part 130 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +On a new line, append another `td` to the `legendRows` variable for the last group of items. It will display the number of followers for each platform. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.dashboard div table tbody tr td').length === 9); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-131.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-131.english.md new file mode 100644 index 0000000000..07e091dc9b --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-131.english.md @@ -0,0 +1,467 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca62 +title: Part 131 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Set the `text` to a "d function" that returns the value(`d.value`) for each data point. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.dashboard div table tbody tr td')[2].innerHTML === '2845'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-132.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-132.english.md new file mode 100644 index 0000000000..626236350d --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-132.english.md @@ -0,0 +1,467 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca63 +title: Part 132 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Set the `align` attribute to `left` for this selection. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.dashboard div table tbody tr td')[2].getAttribute('align').toLowerCase() === 'left'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-133.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-133.english.md new file mode 100644 index 0000000000..f89f67654c --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-133.english.md @@ -0,0 +1,468 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca64 +title: Part 133 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The legend has all the information is needs, but the title looks a little misaligned. Go to where you created your `legendTitle` variable and set the `position` to `relative` and the `left` to `20px` using `style` functions. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const th = $('.dashboard div table thead tr th')[0]; assert(th.style.position === 'relative' && th.style.left === '20px'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-134.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-134.english.md new file mode 100644 index 0000000000..30747572c5 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-134.english.md @@ -0,0 +1,473 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca65 +title: Part 134 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The legend and pie graph look a little off as well. Go to where you created your `legend` variable and add a `position` of `relative` and a `top` of `30px` using `style` functions. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const table = $('.dashboard div table')[0]; assert(table.style.position === 'relative' && table.style.top === '30px'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-135.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-135.english.md new file mode 100644 index 0000000000..1343d06b5a --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-135.english.md @@ -0,0 +1,482 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca66 +title: Part 135 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Lastly, where you created your `pieGraph` variable, add a `position` of `relative` and a `left` of `20px` using `style` functions. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const pieGraph = $('.dashboard div svg')[0]; assert(pieGraph.style.position === 'relative' && pieGraph.style.left === '20px'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-136.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-136.english.md new file mode 100644 index 0000000000..6084fda77a --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-136.english.md @@ -0,0 +1,491 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca67 +title: Part 136 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Finally! You have all the elements displayed and they look good. The last thing you will do is make it so you can see the data from whatever year you want. + +Wrap all the code in the script you've been working with in a function named `drawDashboard` and give it a parameter named `year`. Then, at the bottom of the script, call the function you created and pass it the number `2020`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(typeof(drawDashboard) === 'function' && /<\/script>\s* + +``` + + + + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-137.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-137.english.md new file mode 100644 index 0000000000..f53d02999c --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-137.english.md @@ -0,0 +1,500 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca68 +title: Part 137 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +At the top of the function create a new `const` named `index`. You are going to use it to find the item in the `data` array with the year that is passed to the function. + +Use JavaScript's `findIndex` function to set your `index` variable to the index of the item in the `data` array where the year is the same as the year passed to your `drawDashboard` function. Here's an example: + +```js +array.findIndex(d => + // find the index where the year passed to + // drawDashboard equals the year of the array +) +``` + +After this, you will be able to use `data[index]` to get that item in the array. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const script = $('.dashboard').siblings('script')[1].innerHTML; assert(/var index = data.findIndex\(function \(d\) \{\s*return (year === d\.year|d.year === year);\s*\}\);/g.test(script)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-138.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-138.english.md new file mode 100644 index 0000000000..bc37e88f5e --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-138.english.md @@ -0,0 +1,499 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca6a +title: Part 138 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +There are four places in the file where you used `data[8]` to set data to the year 2020. Change all five of them to `data[index]` so you can pass in any year to the function to display the data from that year. + +The five spots are: + +1. The `domain` for `pieColors`. +2. The `data` for `pieGraphData`. +3. The `text` for your pie slice text. +4. The `data` for your `legendRows`. + +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(!/data\[8\]/g.test(code) && code.match(/data\s*\[\s*index\s*\]/g).length === 4); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-139.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-139.english.md new file mode 100644 index 0000000000..9ced59cc20 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-139.english.md @@ -0,0 +1,501 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca6b +title: Part 139 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Go to where you `call` the `xAxis` and create a `mouseover` event for the labels. Chain the `on` function to them, pass it the string `mouseover`, and give it a value of a "d function" that calls `drawDashboard` with `d` as the argument. It will look like this: + +```js +.on('mouseover', d => drawDashboard(d)) +``` + +So now, when you hover a label, the function will be called with the year that is being hovered. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const script = $('.dashboard').siblings('script')[1].innerHTML; assert(/\.on\(('|"|`)mouseover\1, function \(d\) \{\s*return drawDashboard\(d\);\s*\}\)/g.test(script)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-14.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-14.english.md new file mode 100644 index 0000000000..854b929af4 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-14.english.md @@ -0,0 +1,115 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9eb +title: Part 14 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add a third script just before the closing body tag. It will be the JavaScript file you will use to create the rest of the dashboard. Give the script a `src` of `./dashboard.js`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const script = code.match(/]>\s*<\/script\s*>/gi)[2]; assert(/src\s*=\s*('|")\s*(\.\/)?dashboard.js\s*\1/gi.test(script)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + + + D3 Dashboard + + + + + + +
+ + + + +``` + +
+ + +### Before Test +
+ +```html + + +``` + +
+
+ + +## Solution +
+ +```html + + + + D3 Dashboard + + + + + + +
+ + + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-140.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-140.english.md new file mode 100644 index 0000000000..b6fc211053 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-140.english.md @@ -0,0 +1,498 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca6c +title: Part 140 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +There's a problem, each time you hover a label it adds all the elements to the container again. If you empty the container at the top of the function, it will redraw them where they need to be. + +Go back to the top of the function and use `d3.select` to select the `.dashboard` element and chain the `html` function to it with an empty string as it parameter. Empty means no spaces. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const script = $('.dashboard').siblings('script')[1].innerHTML; assert(/d3\.select\(('|"|`)\.dashboard\1\)\.html\(('|"|`)\2\)/g.test(script)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-141.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-141.english.md new file mode 100644 index 0000000000..a353919072 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-141.english.md @@ -0,0 +1,507 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca6d +title: Part 141 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now when you hover a label, you can see the data for the different years. + +Where you created the `text` elements for the x-axis labels, change the `font` to `bold 10px verdana` for the currently displayed year. + +To do this, create a "d function" in the `font` value area and return the above sting if `d` equals `year`. Otherwise, return the string that is currently there (`10px verdana`). It's easiest to use a ternary operator for this. + +Here's a hint: + +```js +.style('font', d => d === year ? ) +``` + +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(Object.values($('.dashboard svg g text')).filter(el => el.style && el.style.font.toLowerCase() === 'bold 10px verdana').length === 1); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-142.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-142.english.md new file mode 100644 index 0000000000..3d4516d9ae --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-142.english.md @@ -0,0 +1,497 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca6e +title: Part 142 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Create another `mouseover` event for when you hover one of the `twitter-circles`. It will look like the other `mouseover` event you created except the `drawDashboard` function will take `d.year` instead of `d`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const script = $('.dashboard').siblings('script')[1].innerHTML; assert(/\.on\(('|"|`)mouseover\1, function \(d\) \{\s*return drawDashboard\(d\.year\);\s*\}\)/g.test(script)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-143.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-143.english.md new file mode 100644 index 0000000000..e90154dfe6 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-143.english.md @@ -0,0 +1,500 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca6f +title: Part 143 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Similar to how you made the text bold for the label of the displayed year; change the `fill` of the `twitter-circles` to your `twitterColor` for the currently displayed year. To do this, use a "d function" that returns the `twitterColor` when `d.year` equals `year`, and leave it `white` if it doesn't. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(Object.values($('.dashboard svg circle')).filter(el => el.getAttribute && el.getAttribute('fill') === '#7cd9d1').length === 1); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-144.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-144.english.md new file mode 100644 index 0000000000..f57b50d821 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-144.english.md @@ -0,0 +1,506 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca70 +title: Part 144 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add a `mouseover` event to the `tumblr-circles` and `instagram-circles` in the same way that you did for the `twitter-circles`. + +After that, you will be able hover any of the circles or year labels to get the information for that year. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const script = $('.dashboard').siblings('script')[1].innerHTML; assert(script.match(/\.on\(('|"|`)mouseover\1, function \(d\) \{\s*return drawDashboard\(d\.year\);\s*\}\)/g).length === 3); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-145.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-145.english.md new file mode 100644 index 0000000000..b1ea603c8d --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-145.english.md @@ -0,0 +1,506 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca71 +title: Part 145 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Change the `fill` of the `tumblr-circles` and `instagram-circles` to use a "d function" that returns their respective color variables when `d.year` equals `year`, leave it `white` when they don't. This is similar to how you set the fill of the Twitter circles. + +Then, all of the circles will get filled in for the currently displayed year. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const circles = Object.values($('.dashboard svg circle')); assert(circles.filter(el => el.getAttribute && (el.getAttribute('fill') === '#7cd9d1' || el.getAttribute('fill') === '#f6dd71' || el.getAttribute('fill') === '#fd9b98')).length === 3); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-146.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-146.english.md new file mode 100644 index 0000000000..53d22087fb --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-146.english.md @@ -0,0 +1,504 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca72 +title: Part 146 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The last thing is that the legend title always shows 2020. Change the `text` of the `legendTitle` to a template literal that shows the currently displayed year followed by a space and `followers`. + +That's it, your dashboard is finished! Don't forget to admire your hard work. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/\.text\s*\(\s*`\s*\$\{\s*year\s*\} followers`\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-15.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-15.english.md new file mode 100644 index 0000000000..ad459fcb14 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-15.english.md @@ -0,0 +1,124 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9ec +title: Part 15 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The script at the top is the `data.js` file you added. I have placed it here so you can see the data and recommend taking a look at it. The second script is the one you just added and where you will build the rest of the project. + +In the second script, create three `const` variables; `svgMargin` with a value of `70`, `svgWidth` with a value of `700`, and `svgHeight` equal to `500`. The first part of the dashboard will be a line graph. It will use these variables as its dimensions. + +The line graph will have the years from your data variable across the bottom, and a scale on the left to show the numbers of followers. Each platform will have a line going across the graph that shows how many followers you had for each year. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(svgMargin === 70 && svgWidth === 700 && svgHeight === 500); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-16.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-16.english.md new file mode 100644 index 0000000000..8d69c38ce4 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-16.english.md @@ -0,0 +1,125 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9ed +title: Part 16 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add three more variables; `twitterColor` with a value of `#7cd9d1`, `tumblrColor` equal to `#f6dd71`, and `instagramColor` at `#fd9b98`. Make sure those Hex values are strings. These will be colors used to represent the different platforms throughout the project. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(twitterColor === '#7cd9d1' && tumblrColor === '#f6dd71' && instagramColor === '#fd9b98'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-17.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-17.english.md new file mode 100644 index 0000000000..47bf9b3e7d --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-17.english.md @@ -0,0 +1,135 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9ee +title: Part 17 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +When you added the D3 library earlier, it put an object named `d3` in your project with a bunch of functions. One of them is `select`; you can use dot notation to access this and the other functions from the object. Create a new variable named `lineGraph` and use `d3.select` to select the `.dashboard` element. Here's an example of something similar: + +```js +const variableName = d3.select('.className') +``` + +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(lineGraph._groups[0][0] === $(".dashboard")[0]); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-18.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-18.english.md new file mode 100644 index 0000000000..b75c8df4b2 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-18.english.md @@ -0,0 +1,140 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9ef +title: Part 18 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Your dashboard element is now "selected". D3 has a number of functions for working with a selection; one of them is `append`. It is used to add an element. Chain the `append` function to your selection and use it to add an `svg` element. Here's an example of how that might be done: + +```js +const variableName = d3.select('selectedElement') + .append('elementToAdd') +``` + +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(lineGraph._groups[0][0] === $("svg")[0]); + + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-19.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-19.english.md new file mode 100644 index 0000000000..2f83629293 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-19.english.md @@ -0,0 +1,145 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9f0 +title: Part 19 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +You can't see it, but there is now an `svg` element nested in your dashboard container. When you appended it, it became the "selection" for this area of code. Any functions you chain after it will be used on this selection. + +`attr` is a function to set attributes. You need to pass it the attribute you want to set, and the value you want to give it. Here's an example of how to chain `attr` to a selection: + +```js +const variableName = d3.select('element') + .append('element') + .attr('attribute', 'value') +``` + +Chain an `attr` function to the selection that sets the `width` as the `svgWidth` variable you created earlier. When using a variable as a value, you do not need to put it in any kind of quotations. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($("svg")[0].attributes.width.value === "700"); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-2.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-2.english.md new file mode 100644 index 0000000000..294940968e --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-2.english.md @@ -0,0 +1,56 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9df +title: Part 2 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Next, add opening and closing `html`, `head` and `body` tags below the doctype. Be sure to nest them properly. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/\s*\s*\s*<\/head\s*>\s*\s*<\/body\s*>\s*<\/html\s*>/gi.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + +``` + +
+
+ + +## Solution +
+ +```html + + + + + + + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-20.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-20.english.md new file mode 100644 index 0000000000..57a7b9262a --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-20.english.md @@ -0,0 +1,137 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9f1 +title: Part 20 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Chain another `attr` function that sets the `height` as the `svgHeight` variable you created. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($("svg")[0].attributes.height.value === "500"); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-21.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-21.english.md new file mode 100644 index 0000000000..46b194168c --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-21.english.md @@ -0,0 +1,142 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9f2 +title: Part 21 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Your line graph needs some scales so it knows how to translate the data into visual distances. The first one is the scale for the y-axis. It will be to show the number of followers. D3 has many utilities for creating scales. You want to use it's `scaleLinear` method for this scale. + +Create a new `const` named `yScale`, and set it equal to `d3.scaleLinear()`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(typeof(yScale) === "function" && /yScale\s*=\s*d3\.scaleLinear/.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-22.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-22.english.md new file mode 100644 index 0000000000..acb1709aff --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-22.english.md @@ -0,0 +1,143 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9f3 +title: Part 22 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +D3 has a bunch of functions for working with scales as well. One of them is `domain`. It takes an array that is used to describe the highest and lowest values of the data for this scale. After a quick look at the data, the values of the "followers" go from about 0 to 5000. Chain the `domain` function to the `yScale` and pass it the array `[0, 5000]`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const domain = yScale.domain(); assert(domain.length === 2 && domain[0] === 0 && domain[1] === 5000); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-23.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-23.english.md new file mode 100644 index 0000000000..cf133d9cf3 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-23.english.md @@ -0,0 +1,148 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9f4 +title: Part 23 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `range` function describes how to map the domain values for display on the graph. For example, a value of 5000 followers can't use 5000 as it y-coordinate on the SVG or it would be off the graph. You need to tell the range where the top and bottom of the graph is so the scale can give appropriate values for the y-coordinate. + +Chain the `range` function below the `domain` and pass it an array with `svgHeight - svgMargin` and `svgMargin` as the values. That will translate to `[430, 70]`. This is where the top and bottom of the graph are. So a data point of 5000 followers will map to a value of 430 to use as its y-coordinate and 0 followers will use 70 as its y-coordinate. Any value in between will scale linearly. + +Your graph will have a margin around it for things like axes and labels. The actual line data will display on the inside of this margin area, which is why you use those values. This will become more clear as you progress through the project. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const range = yScale.range(); assert(range.length === 2 && range[0] === 430 && range[1] === 70); +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-24.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-24.english.md new file mode 100644 index 0000000000..dd0fe50410 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-24.english.md @@ -0,0 +1,148 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9f5 +title: Part 24 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Create a new `const` named `xScale`. Use it to create another linear scale like you did for the y-scale. This will be the horizontal or "x" axis. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(typeof(xScale) === "function" && /xScale\s*=\s*d3\.scaleLinear/.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-25.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-25.english.md new file mode 100644 index 0000000000..2d71f94541 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-25.english.md @@ -0,0 +1,151 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9f6 +title: Part 25 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The `year` values of your data will be used for the x-scale. Chain the `domain` function to `xScale` and pass it an array with the first and last years of your data. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const domain = xScale.domain(); assert(domain.length === 2 && domain[0] === 2012 && domain[1] === 2020); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-26.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-26.english.md new file mode 100644 index 0000000000..9d605d2239 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-26.english.md @@ -0,0 +1,153 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9f7 +title: Part 26 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The range for this scale will go from the left of your graph to the right, with 2012 on the left and 2020 on the right. Add the `range` function to the `xScale` and pass it an array with the values: `svgMargin` and `svgWidth - svgMargin`. This will translate to `[70, 630]`. So 2012 will use 70 as is x-coordinate and 2020 will use 630 as its x-coordinate. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const range = xScale.range(); assert(range.length === 2 && range[0] === 70 && range[1] === 630); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-27.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-27.english.md new file mode 100644 index 0000000000..089186d8c5 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-27.english.md @@ -0,0 +1,156 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9f8 +title: Part 27 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The two scales you defined will be used to create the axes and lines. First is the y-axis, it will be a line with some labels on the left of the graph. Create a new `const` named `yAxis` and set it equal to `d3.axisLeft(yScale)`. This will use the information from the `yScale` variable to build the axis. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(typeof(yAxis) === "function" && /yAxis\s*=\s*d3\.axisLeft\(\s*yScale\)/.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-28.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-28.english.md new file mode 100644 index 0000000000..90efe7c53e --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-28.english.md @@ -0,0 +1,160 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9f9 +title: Part 28 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Create a new `const` named `xAxis` and set the value equal to `d3.axisBottom(xScale)`. This will create another axis for the bottom of the graph using the information from `xScale`. Although the axes do not display yet, they have the information they need to display correctly. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(typeof(xAxis) === "function" && /xAxis\s*=\s*d3\.axisBottom\(\s*xScale\)/.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-29.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-29.english.md new file mode 100644 index 0000000000..4adf19fff4 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-29.english.md @@ -0,0 +1,164 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9fa +title: Part 29 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +On a new line, append a new `g` element to your `lineGraph` variable. `lineGraph.append('g')` will do that for you. This will add a `g` to your SVG and be for displaying the y-axis. `g` is an SVG element that stands for "group". +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($("svg")[0].children[0] === $("g")[0] && $("g").length === 1); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-3.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-3.english.md new file mode 100644 index 0000000000..9d64d8cb58 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-3.english.md @@ -0,0 +1,66 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9e0 +title: Part 3 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +In the head, add a `title` of `D3 Dashboard`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/\s*D3 Dashboard<\/title\s*>\s*<\/head\s*>/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + + + + + + + + + +``` + +
+
+ + +## Solution +
+ +```html + + + + D3 Dashboard + + + + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-30.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-30.english.md new file mode 100644 index 0000000000..0dec13f837 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-30.english.md @@ -0,0 +1,168 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9fb +title: Part 30 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +`call` is another function to use with selections. Chain a `call` function to the selection and pass your `yAxis` variable to it. This will draw your y-axis on the SVG. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($(".tick").length === 11 && /\.call\(\s*yAxis\s*\)/.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-31.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-31.english.md new file mode 100644 index 0000000000..e51cbcd0cf --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-31.english.md @@ -0,0 +1,172 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9fc +title: Part 31 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +After all that work, something is finally displayed on the graph. It's the y-axis and all the numbers are hidden on the left. + +Move the axis your `svgMargin` to the right by chaining an `attr` function to the selection. Use it to set the `transform` to `translate(${svgMargin}, 0)`. Use a template literal (backticks) to set the value so you can put your variable in there. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($("g")[0].attributes.transform.nodeValue === "translate(70, 0)"); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-32.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-32.english.md new file mode 100644 index 0000000000..0ab74e0956 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-32.english.md @@ -0,0 +1,171 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9fd +title: Part 32 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +`style` is a function similar to `attr`, but is more for manipulating CSS styles rather than element attributes. Add a `style` function to the selection that sets the `font` to `10px verdana`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: 'assert($("g")[0].attributes.style.nodeValue === "font: 10px verdana;");' + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-33.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-33.english.md new file mode 100644 index 0000000000..241422c07a --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-33.english.md @@ -0,0 +1,174 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9fe +title: Part 33 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +On a new line, append another `g` element to your `lineGraph` variable like you did before. This one will be for the x-axis. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($("g").length === 13); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-34.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-34.english.md new file mode 100644 index 0000000000..4b903d8be9 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-34.english.md @@ -0,0 +1,177 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9ff +title: Part 34 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Use the `call` function to draw the x-axis onto the SVG like you did for the y-axis. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('g').length === 22); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-35.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-35.english.md new file mode 100644 index 0000000000..6107fe6f4a --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-35.english.md @@ -0,0 +1,179 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca00 +title: Part 35 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The axis has the right size and labels, but needs to be moved down. Use the `attr` function to set the `transform` like you did before. This time move it down your `svgHeight` minus the `svgMargin`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($("svg > g")[1].attributes.transform.nodeValue === "translate(0, 430)"); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-36.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-36.english.md new file mode 100644 index 0000000000..bed37fa3a8 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-36.english.md @@ -0,0 +1,186 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca01 +title: Part 36 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The axis labels are `text` elements within the `g`, you can use the `selectAll` function to select them. Chain the `selectAll` function to select the `text` elements in this group. You can do that like this: + +```js +.selectAll('element') +``` + +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/\.attr\('transform', `translate\(0, \$\{svgHeight - svgMargin\}\)`\)\s*\.selectAll\s*\(\s*('|"|`)text\1\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-37.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-37.english.md new file mode 100644 index 0000000000..e11f6a21af --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-37.english.md @@ -0,0 +1,183 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca02 +title: Part 37 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +I want the text elements to be rotated slightly. Chain the `style` function to set the `transform` to `translate(-12px, 0) rotate(-50deg)`. This will put them at an angle. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.tick > text').filter((node, index) => index.style.transform === 'translate(-12px) rotate(-50deg)' || index.style.transform === 'translate(-12px, 0px) rotate(-50deg)').length === 9); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-38.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-38.english.md new file mode 100644 index 0000000000..e248f57d99 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-38.english.md @@ -0,0 +1,185 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca03 +title: Part 38 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add another `style` function to set the `text-anchor` to `end`. This will change the spot that each text element rotates around to the `end` of the element so they will align better. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.tick > text').filter((node, index) => index.style['text-anchor'] === 'end').length === 9); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-39.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-39.english.md new file mode 100644 index 0000000000..fc92952869 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-39.english.md @@ -0,0 +1,189 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca04 +title: Part 39 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add two more `style` functions; one to set the `cursor` to `pointer`, and another to set the `font` to `10px verdana`. + +You will add some hover effects later, so the pointer will make for a better experience. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.tick > text').filter((node, index) => index.style.cursor === 'pointer' && index.style.font === '10px verdana').length === 9); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-4.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-4.english.md new file mode 100644 index 0000000000..f92dd6aa58 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-4.english.md @@ -0,0 +1,68 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9e1 +title: Part 4 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Below the title, link to your external stylesheet by adding a `link` element with a `rel` attribute of `stylesheet` and an `href` attribute of `./dashboard.css`. Remember that link elements do not need a closing tag. You will be adding some styles to this file shortly. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const link = code.match(/]>/gi)[0]; assert(/rel\s*=\s*('|")\s*stylesheet\s*\1/gi.test(link) && /href\s*=\s*('|")\s*(.\/)?dashboard\.css\s*\1/gi.test(link)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + + + D3 Dashboard + + + + + + + +``` + +
+
+ + +## Solution +
+ +```html + + + + D3 Dashboard + + + + + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-40.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-40.english.md new file mode 100644 index 0000000000..9261b4fe9d --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-40.english.md @@ -0,0 +1,191 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca05 +title: Part 40 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +There are a number of D3 functions to work with how the "ticks" or your axis labels are displayed; one of them is `ticks`. Go back to where you defined the `yAxis` variable and chain a `ticks` function to it and pass it these two arguments: `6, '~s'`. + +The `6` will set the number of ticks used to 6, and the `~s` will make the labels display the number of thousands followed by a `k`. For example, `4000` will become `4k`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const ticks = $('.tick > text'); assert(ticks[0].innerHTML === '0k' && ticks[1].innerHTML === '1k' && ticks[2].innerHTML === '2k' && ticks[3].innerHTML === '3k' && ticks[4].innerHTML === '4k' && ticks[5].innerHTML === '5k'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-41.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-41.english.md new file mode 100644 index 0000000000..04fd6d2e27 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-41.english.md @@ -0,0 +1,191 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca06 +title: Part 41 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Go back to where you defined your `xAis` variable and chain the `tickFormat` function to it. Pass it `d3.format('')`. This will remove the commas in the year labels of the x-axis. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const ticks = $('.tick > text'); assert(ticks[6].innerHTML === '2012' && ticks[14].innerHTML === '2020'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-42.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-42.english.md new file mode 100644 index 0000000000..5f0ad05a98 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-42.english.md @@ -0,0 +1,195 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca07 +title: Part 42 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +In the same spot, chain the `tickPadding` function to the `xAxis` and pass it `10`. This will add a little padding to the ticks so the labels are better aligned. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/\.tickFormat\(d3\.format\((''\)\)\s*\.tickPadding\s*\(\s*10\s*\))/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-43.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-43.english.md new file mode 100644 index 0000000000..4c89000eae --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-43.english.md @@ -0,0 +1,199 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca08 +title: Part 43 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The axes and labels are looking good. Next, you will start to add some of the lines for the data. First is the line for the Twitter data. On a new line, create a new `const` named `twitterLine` and set it equal to `d3.line()`. `line` is a D3 function for creating a line. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const\s*twitterLine\s*=\s*d3\s*\.\s*line\s*\(\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-44.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-44.english.md new file mode 100644 index 0000000000..1e75e2db44 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-44.english.md @@ -0,0 +1,209 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca09 +title: Part 44 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The line needs x and y values for each point of data. Chain `x` to the line and pass it a "d function". Here's how that will look: + +```js +.x(d => d.year) +``` + +You will be passing your `data` array to this line function, where it will go through each item in the array(`d`) and create an x value based on the year(`d.year`). + +This is the first place you have seen a "d function". These are common in D3 and that is how I will refer to them throughout this project. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const twitterLine = d3\.line\(\)\s*\.x\s*\(\s*d\s*=>\s*d\.year\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-45.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-45.english.md new file mode 100644 index 0000000000..deb1ad16d1 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-45.english.md @@ -0,0 +1,204 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca0a +title: Part 45 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Instead of simply using the year(`d.year`) for the x-coordinate, you need to pass each year to the `xScale` so it can set the appropriate coordinate based on your scale. + +In the "d function" you created, return `xScale(d.year)` instead of `d.year`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/\.x\s*\(d\s*=>\s*xScale\s*\(\s*d\.year\s*\)\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-46.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-46.english.md new file mode 100644 index 0000000000..547d10bd8a --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-46.english.md @@ -0,0 +1,208 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca0b +title: Part 46 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Chain the `y` function to the line and pass it a "d function" that returns your `yScale` with `d.followers.twitter` as its argument. + +This is similar to how you set the x values. It will use the values of your Twitter followers and your `yScale` to set the y coordinate for each item. + +These "d functions" use implicit returns. But if you add curly brackets and a return statement, you can put any JavaScript in there that you want. Including `console.log` statements that can be useful for debugging. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/\.y\s*\(\s*d\s*=>\s*yScale\s*\(\s*d\.followers.twitter\s*\)\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-47.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-47.english.md new file mode 100644 index 0000000000..32bbdb114e --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-47.english.md @@ -0,0 +1,207 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca0c +title: Part 47 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The first line is created and ready to be displayed, which will take a couple steps. On a new line, `append` a `path` element to your `lineGraph` variable. This is similar to how you appended the `g` before. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg path').length === 3 && /lineGraph\.append\((`|'|")path\1\)/gi.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-48.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-48.english.md new file mode 100644 index 0000000000..7321a24e28 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-48.english.md @@ -0,0 +1,214 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca0d +title: Part 48 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Tell the path what data to use. Add an `attr` function and set the `d` to `twitterLine(data)`. This will the build the path using the `twitterLine` function you created and your data variable. + +Note that the `d` in this case is a path attribute for drawing a line and is different from a "d function". + +After you have added your code, take a look at the data flow to help understand what is happening. You pass the data array to your `twitterLine` function where it sets the x and y values using your "d functions". The "d functions" go through each item in the array, passing part of the item to each scale to find the appropriate coordinates. When it's done, the value you are setting here is created and sent back. The result ends up being a confusing string of numbers and coordinates to tell the path how to be drawn. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg path')[2].getAttribute('d').length === 151); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-49.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-49.english.md new file mode 100644 index 0000000000..c40f650fd9 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-49.english.md @@ -0,0 +1,215 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca0e +title: Part 49 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add three more `attr` functions to the path; one to set the `stroke` to your `twitterColor` variable, another to set the `stroke-width` to `3`, and a third to set the `fill` to `transparent`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const twitterPath = $('svg path')[2]; assert(twitterPath.getAttribute('stroke') === '#7cd9d1' && twitterPath.getAttribute('stroke-width') == '3' && twitterPath.getAttribute('fill') === 'transparent'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-5.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-5.english.md new file mode 100644 index 0000000000..912cce4bb9 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-5.english.md @@ -0,0 +1,72 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9e2 +title: Part 5 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Next, add a container for the dashboard. Put an empty `div` element in the body with class of `dashboard`. You will be appending all the dashboard elements to this div. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($("div.dashboard").length === 1); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + + + D3 Dashboard + + + + + + + + +``` + +
+
+ + +## Solution +
+ +```html + + + + D3 Dashboard + + + + + + +
+ + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-50.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-50.english.md new file mode 100644 index 0000000000..347ed7e6dd --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-50.english.md @@ -0,0 +1,219 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca0f +title: Part 50 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +On a new line, create a new `const` named `tumblrLine` and set it equal to `d3.line()`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const\s*tumblrLine\s*=\s*d3\s*\.\s*line\s*\(\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-51.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-51.english.md new file mode 100644 index 0000000000..1e1153a83e --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-51.english.md @@ -0,0 +1,221 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca10 +title: Part 51 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Set the `x` values for `tumblrLine` using another "d function". Use your `xScale` and the `d.year` to calculcate their values just like you did for the Twitter line. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const tumblrLine = d3\.line\(\)\s*\.x\s*\(\s*d\s*=>\s*xScale\s*\(\s*d\.year\s*\)\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-52.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-52.english.md new file mode 100644 index 0000000000..1f6d658b4a --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-52.english.md @@ -0,0 +1,226 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca11 +title: Part 52 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Set the `y` values for `tumblrLine` using a "d function" again. Use your `yScale` and `d.followers.tumblr` to calculcate their values just like you did for the Twitter line. + +The x values for each line will be the same, but the y values will use the data from the different platforms. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/\.y\s*\(\s*d\s*=>\s*yScale\s*\(\s*d\.followers.tumblr\s*\)\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-53.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-53.english.md new file mode 100644 index 0000000000..db9a51f3f5 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-53.english.md @@ -0,0 +1,227 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca12 +title: Part 53 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +On a new line, `append` a `path` element to the `lineGraph` variable. This one will be for displaying the `tumblrLine`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg path').length === 4 && code.match(/lineGraph\.append\((`|'|")path\1\)/gi).length === 2); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-54.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-54.english.md new file mode 100644 index 0000000000..4fdd6e1e66 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-54.english.md @@ -0,0 +1,230 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca13 +title: Part 54 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Tell the new path how to be drawn by setting the `d` attribute to `tumblrLine(data)` using the `attr` function. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg path')[3].getAttribute('d').length === 115); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-55.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-55.english.md new file mode 100644 index 0000000000..089b2c517c --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-55.english.md @@ -0,0 +1,234 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca14 +title: Part 55 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add three `attr` functions to the selection; one to set the `stroke` to your `tumblrColor` variable, another to set the `stroke-width` to `3`, and a third to set the `fill` to `transparent`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const tumblrPath = $('svg path')[3]; assert(tumblrPath.getAttribute('stroke') === '#f6dd71' && tumblrPath.getAttribute('stroke-width') == '3' && tumblrPath.getAttribute('fill') === 'transparent'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-56.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-56.english.md new file mode 100644 index 0000000000..8670b7b519 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-56.english.md @@ -0,0 +1,239 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca15 +title: Part 56 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Two lines down, only one more to add for the Instagram followers. On a new line, create a new `const` named `instagramLine` and use the D3 `line` function to create another line like you did for the other two. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const\s*instagramLine\s*=\s*d3\s*\.\s*line\s*\(\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-57.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-57.english.md new file mode 100644 index 0000000000..61f79c8148 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-57.english.md @@ -0,0 +1,243 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca16 +title: Part 57 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Appropriately set the `x` values for `instagramLine` like you did for the other two lines. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const instagramLine = d3\.line\(\)\s*\.x\s*\(\s*d\s*=>\s*xScale\s*\(\s*d\.year\s*\)\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-58.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-58.english.md new file mode 100644 index 0000000000..7038b5c30a --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-58.english.md @@ -0,0 +1,246 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca17 +title: Part 58 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Appropriately set the `y` values for `instagramLine` like you did for the other two lines. Use the Instagram followers data this time. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/\.y\s*\(\s*d\s*=>\s*yScale\s*\(\s*d\.followers.instagram\s*\)\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-59.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-59.english.md new file mode 100644 index 0000000000..838dee7a4e --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-59.english.md @@ -0,0 +1,249 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca18 +title: Part 59 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +On a new line, `append` a new `path` for the Instagram line like you did for the other two lines. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg path').length === 5 && code.match(/lineGraph\.append\((`|'|")path\1\)/gi).length === 3); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-6.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-6.english.md new file mode 100644 index 0000000000..e25c5126cc --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-6.english.md @@ -0,0 +1,75 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9e3 +title: Part 6 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +You are now looking at the stylesheet that you linked to earlier. At the top of this file, target the `body` of the HTML document and give it a `background-color` of `#ccc`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const body = code.match(/body\s*{[\s\S]+?[^}]}/g)[0]; assert(/background-color\s*:\s*#ccc\s*(;|})/gi.test(body)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-60.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-60.english.md new file mode 100644 index 0000000000..a238f3691b --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-60.english.md @@ -0,0 +1,251 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca19 +title: Part 60 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Use your `instagramLine` variable and your data to set the `d` attribute for this path like you did for the other two. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg path')[4].getAttribute('d').length === 171); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-61.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-61.english.md new file mode 100644 index 0000000000..576ea44ea5 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-61.english.md @@ -0,0 +1,255 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca1a +title: Part 61 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Set the `stroke`, `stroke-width`, and `fill` attributes to their appropriate values for this line. The `stroke-width` and `fill` are the same as the other two. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const instagramPath = $('svg path')[4]; assert(instagramPath.getAttribute('stroke') === '#fd9b98' && instagramPath.getAttribute('stroke-width') == '3' && instagramPath.getAttribute('fill') === 'transparent'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-62.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-62.english.md new file mode 100644 index 0000000000..8767060ec2 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-62.english.md @@ -0,0 +1,267 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca1b +title: Part 62 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Okay, your graph is coming along. All the lines are drawn, but they look a little plain. The next series of code additions will add circles to each point on each line. First is the Twitter line. On a new line, use the `selectAll` function on your `lineGraph` variable and pass it the string `twitter-circles`. It will look like this: + +```js +lineGraph.selectAll('twitter-circles') +``` + + +`twitter-circles` don't exist and this selection will be an empty array, but it's needed. For now, you can just think of this string as a reference, similar to a variable name, so you know what elements you are working with. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/lineGraph\s*\.\s*selectAll\s*\((`|'|")\s*twitter-circles\1\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-63.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-63.english.md new file mode 100644 index 0000000000..785102ccf5 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-63.english.md @@ -0,0 +1,268 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca1c +title: Part 63 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add the D3 `data` function to your selection and pass it the data array like this: + +```js +.data(data) +``` + +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/\.data\s*\(\s*data\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-64.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-64.english.md new file mode 100644 index 0000000000..c5e941d946 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-64.english.md @@ -0,0 +1,269 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca1d +title: Part 64 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Next, chain the `enter()` function to the selection. + +The enter function identifies elements that need to be added when the data array is longer than the selection array. This is why you wanted the `selectAll` to be an empty array before. + +In this case, the `twitter-circles` selection has a length of 0, and the data array has a length of 9. So nine elements will be added when you use `append` in the next step. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/\.data\(data\)\s*\.enter\s*\(\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-65.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-65.english.md new file mode 100644 index 0000000000..9ba98ab22a --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-65.english.md @@ -0,0 +1,267 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca1e +title: Part 65 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add the `append` function to the selection, and use it to add `circle` elements. This will add the nine `circle` elements for your Twitter circles. They will be invisible to start, but the elements are there. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg circle').length === 9); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-66.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-66.english.md new file mode 100644 index 0000000000..c714179706 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-66.english.md @@ -0,0 +1,271 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca1f +title: Part 66 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Each circle needs a `cx` and `cy` attribute so it knows where to display on the SVG. These are similar to the x and y coordinates for the lines and will be calculated in the same way. The difference is that, for circles, the `cx` and `cy` are attributes, so you need to use the `attr` function. + +Use the `attr` function to set the `cx` to `d => xScale(d.year)`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg circle')[0].getAttribute('cx') == '70'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-67.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-67.english.md new file mode 100644 index 0000000000..b9e5d6e012 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-67.english.md @@ -0,0 +1,273 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca20 +title: Part 67 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Next, set the `cy` attribute to `d => xScale(d.followers.twitter)`. + +As a reminder, this will pass each value of your Twitter followers to the `xScale` function where it will determine the y coordinate to use. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg circle')[0].getAttribute('cy') == '243.232'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-68.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-68.english.md new file mode 100644 index 0000000000..5611776700 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-68.english.md @@ -0,0 +1,273 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca21 +title: Part 68 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Circles also need an `r` (radius) attribute so they know how big to be. Use the `attr` function to set the `r` to `6`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg circle')[0].getAttribute('r') == '6'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-69.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-69.english.md new file mode 100644 index 0000000000..b9de62be31 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-69.english.md @@ -0,0 +1,276 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca22 +title: Part 69 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The circles are now visible, but I don't like the color. Use the appropriate function to set the `fill` to `white` and the `stroke` to your `twitterColor` variable. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg circle')[0].getAttribute('fill') === 'white' && $('svg circle')[0].getAttribute('stroke') === '#7cd9d1'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-7.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-7.english.md new file mode 100644 index 0000000000..8417ac7480 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-7.english.md @@ -0,0 +1,84 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9e4 +title: Part 7 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Next, target the `dashboard` class you created and give it a `width` of `980px` and a `height` of `500px`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const dashboard = $(".dashboard"); assert(dashboard.css("width") === "980px" && dashboard.css("height") === "500px"); + +``` + +
+ +## Challenge Seed +
+
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-70.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-70.english.md new file mode 100644 index 0000000000..95b77f659d --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-70.english.md @@ -0,0 +1,279 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca23 +title: Part 70 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Use the `style` function to set the `cursor` to `pointer`. Like your year labels, this will be an indicator for a hover effect you will add later. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg circle')[0].style.cursor === 'pointer'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-71.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-71.english.md new file mode 100644 index 0000000000..1b160b965c --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-71.english.md @@ -0,0 +1,282 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca24 +title: Part 71 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +On a new line, use the `selectAll` function on your `lineGraph` variable again and pass it the string `tumblr-circles` this time. The next few steps will be for adding circles to the Tumblr line. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/lineGraph\s*\.\s*selectAll\s*\((`|'|")\s*tumblr-circles\1\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-72.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-72.english.md new file mode 100644 index 0000000000..c42ef95cef --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-72.english.md @@ -0,0 +1,289 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca25 +title: Part 72 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add the same `data`, `enter`, and `append` functions here that you added for the `twitter-circles`, passing in the same arguments. Make sure they are in the same order. + +Remember that this will take the difference in length between the `tumblr-circles` selection(0) and the data array(9) and append that many circle elements. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg circle').length === 18); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-73.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-73.english.md new file mode 100644 index 0000000000..6f8138c0c4 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-73.english.md @@ -0,0 +1,292 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca26 +title: Part 73 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Set the `cx` and `cy` attributes for the Tumblr circles to their appropriate values. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg circle')[9].getAttribute('cx') == '70' && $('svg circle')[9].getAttribute('cy') == '401.128'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-74.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-74.english.md new file mode 100644 index 0000000000..5d93de7ade --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-74.english.md @@ -0,0 +1,297 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca27 +title: Part 74 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Use the `attr` function to set the `r` to `6`, the `fill` to `white`, and the `stroke` to your `tumblrColor` variable. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg circle')[9].getAttribute('r') == '6' && $('svg circle')[9].getAttribute('fill') === 'white' && $('svg circle')[9].getAttribute('stroke') === '#f6dd71'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-75.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-75.english.md new file mode 100644 index 0000000000..bac00b3dcc --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-75.english.md @@ -0,0 +1,301 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca28 +title: Part 75 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Set the `cursor` to `pointer` using the `style` function. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg circle')[9].style.cursor === 'pointer'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-76.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-76.english.md new file mode 100644 index 0000000000..bbbe313a45 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-76.english.md @@ -0,0 +1,304 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca29 +title: Part 76 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The circles have been added to two of the lines and look good, on to the last one. On a new line, create another empty selection like you did before. Use the string: `instagram-circles` this time. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/lineGraph\s*\.\s*selectAll\s*\((`|'|")\s*instagram-circles\1\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-77.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-77.english.md new file mode 100644 index 0000000000..52046c9781 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-77.english.md @@ -0,0 +1,309 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca2a +title: Part 77 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add the three functions necessary to append the new circle elements. Remember that they won't actually be visible yet. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg circle').length === 27); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-78.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-78.english.md new file mode 100644 index 0000000000..e1f4d2f92e --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-78.english.md @@ -0,0 +1,314 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca2b +title: Part 78 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Appropriately set the `cx` and `cy` attributes for the Instagram circles. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg circle')[18].getAttribute('cx') == '70' && $('svg circle')[18].getAttribute('cy') == '424.024'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-79.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-79.english.md new file mode 100644 index 0000000000..d6f7298da1 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-79.english.md @@ -0,0 +1,319 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca2c +title: Part 79 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Appropriately set the radius (`r`), `fill`, and `stroke` for these circles. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg circle')[18].getAttribute('r') == '6' && $('svg circle')[18].getAttribute('fill') === 'white' && $('svg circle')[18].getAttribute('stroke') === '#fd9b98'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-8.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-8.english.md new file mode 100644 index 0000000000..c5bdd30039 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-8.english.md @@ -0,0 +1,90 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9e5 +title: Part 8 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Give the dashboard a `background-color` of `white` and a `box-shadow` of `5px 5px 5px 5px #888` to give it a little depth. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const dashboard = $(".dashboard"); assert(dashboard.css("background-color") === "rgb(255, 255, 255)" && dashboard.css("box-shadow") === "rgb(136, 136, 136) 5px 5px 5px 5px"); + +``` + +
+ +## Challenge Seed +
+
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-80.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-80.english.md new file mode 100644 index 0000000000..dbf29da9a0 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-80.english.md @@ -0,0 +1,323 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca2d +title: Part 80 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Apply the appropriate `cursor` style for these circles. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg circle')[18].style.cursor === 'pointer'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-81.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-81.english.md new file mode 100644 index 0000000000..244bb57f60 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-81.english.md @@ -0,0 +1,326 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca2e +title: Part 81 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The line graph is looking good. All the empty space to the right will be for the pie graph and legend. Create a new `const` named `rightDashboard` and set equal to `d3.select('.dashboard')`. This will select your dashboard container again which currently only has the SVG element as a child. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const\s*rightDashboard\s*=\s*d3\.select\s*\((`|'|")\.dashboard\1\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-82.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-82.english.md new file mode 100644 index 0000000000..e3d264a9ed --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-82.english.md @@ -0,0 +1,329 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca2f +title: Part 82 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Use `append` to add a `div` element to the selection. This will put a div as another child of the dashboard container to hold the pie graph and legend. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const rightDashboard = d3\.select\((`|'|")\.dashboard\1\)\s*\.append\s*\(\s*(`|'|")div\2\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-83.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-83.english.md new file mode 100644 index 0000000000..ec88d0b4e0 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-83.english.md @@ -0,0 +1,332 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca30 +title: Part 83 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Create a new `const` named `pieGraph` and set it equal to `rightDashboard.append('svg')`. This will add an SVG element for the pie graph as a child of the div you just added. The pie graph will have three slices, one for each platform. It will display a percentage of how many followers each platform has for the displayed year. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const\s*pieGraph\s*=\s*rightDashboard\s*\.\s*append\s*\((`|'|")svg\1\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-84.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-84.english.md new file mode 100644 index 0000000000..33e5fb521a --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-84.english.md @@ -0,0 +1,336 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca31 +title: Part 84 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add two `attr` functions that set the `width` and `height` of the new SVG to `200`. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg')[1].getAttribute('width') == '200' && $('svg')[1].getAttribute('height') == '200'); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-85.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-85.english.md new file mode 100644 index 0000000000..be8086adea --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-85.english.md @@ -0,0 +1,340 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca32 +title: Part 85 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Create a new `const` named `pieArc` and set it equal to `d3.arc()`. This will be used to create the angles for the lines of the pie chart using the D3 arc generator. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const\s*pieArc\s*=\s*d3\s*\.\s*arc\s*\(\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-86.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-86.english.md new file mode 100644 index 0000000000..3dd480445b --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-86.english.md @@ -0,0 +1,343 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca33 +title: Part 86 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Chain the function `outerRadius(100)` to the arc. This will set the outer radius of the pie chart to 100. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const pieArc = d3\.arc\(\)\s*\.\s*outerRadius\s*\(\s*100\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-87.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-87.english.md new file mode 100644 index 0000000000..9f945dc626 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-87.english.md @@ -0,0 +1,345 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca34 +title: Part 87 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Chain `innerRadius` to the arc and pass it `0` (zero). This is set to zero to make a traditional pie chart, you would use a larger inner radius to create a doughnut chart. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const pieArc = d3\.arc\(\)\s*\.outerRadius\(100\)\s*\.\s*innerRadius\s*\(\s*0\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-88.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-88.english.md new file mode 100644 index 0000000000..1c2b155cd3 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-88.english.md @@ -0,0 +1,350 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca35 +title: Part 88 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +The pie chart needs a new scale to set the colors. Create a new `const` named `pieColors` and set it equal to `d3.scaleOrdinal()`. An ordinal scale is for a set of data that will have exactly one item in the range specifically for it. + +In this case, each platform of followers you have will map directly to a single color with nothing in between. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const\s*pieColors\s*=\s*d3\s*\.\s*scaleOrdinal\s*\(\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-89.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-89.english.md new file mode 100644 index 0000000000..0e4b4cbca6 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-89.english.md @@ -0,0 +1,351 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca36 +title: Part 89 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Set the `domain` of the scale to `data[8].followers`. This will be three items, one for each platform. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const pieColors = d3\.scaleOrdinal\(\)\s*\.\s*domain\s*\(\s*data\s*\[\s*8\s*\]\s*\.\s*followers\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-9.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-9.english.md new file mode 100644 index 0000000000..c1b9a06c88 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-9.english.md @@ -0,0 +1,93 @@ +--- +id: 5d8a4cfbe6b6180ed9a1c9e6 +title: Part 9 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Now you can see your dashboard element. Center it by adding a `margin` of `auto` to it. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: const dashboard = code.match(/.dashboard\s*{[\s\S]+?[^}]}/g)[0]; assert(/margin\s*:\s*auto\s*(;|})/g.test(dashboard)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-90.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-90.english.md new file mode 100644 index 0000000000..05a74e85f7 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-90.english.md @@ -0,0 +1,353 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca37 +title: Part 90 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Since the domain has three items, the range also needs to have three items. If it had less, the values would repeat, putting the same color on the pie chart multiple times. Add the `range` function to the scale and pass it an array with your three color variables. Put them in the same order in which they are defined. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/\.domain\(data\[8\]\.followers\)\s*\.\s*range\s*\(\s*\[\s*twitterColor\s*,\s*tumblrColor\s*,\s*instagramColor\s*\]\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-91.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-91.english.md new file mode 100644 index 0000000000..5b75e4ee2e --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-91.english.md @@ -0,0 +1,356 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca38 +title: Part 91 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Create a new `const` named `pie` and set it equal to `d3.pie()`. This is the D3 pie chart generator. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const\s*pie\s*=\s*d3\s*\.\s*pie\s*\(\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-92.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-92.english.md new file mode 100644 index 0000000000..3d52afe441 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-92.english.md @@ -0,0 +1,361 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca39 +title: Part 92 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Chain a `value` function to `pie` and pass it `d => d.value`. Each piece of data(`d`) will have a `key`(platform) and a `value`(number of followers), you want to return the number of followers here. The pie function will create an array of objects from these values that describe the angles and sizes the pie chart needs. + +In a few steps, you will make an array out of your data variable that will be passed to this function. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const pie = d3\.pie\(\)\s*\.\s*value\s*\(\s*d\s*=>\s*d\.value\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-93.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-93.english.md new file mode 100644 index 0000000000..e19dd0bbe8 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-93.english.md @@ -0,0 +1,362 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca3a +title: Part 93 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Create a new `const` named `pieGraphData` and set the value equal to `pieGraph.selectAll('pieSlices')`. This is an empty selection similar circles you created earlier. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const\s*pieGraphData\s*=\s*pieGraph\s*\.\s*selectAll\s*\(\s*(`|'|")pieSlices\1\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-94.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-94.english.md new file mode 100644 index 0000000000..32d8d7e0dc --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-94.english.md @@ -0,0 +1,365 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca3b +title: Part 94 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add the `data` function to the selection. Pass it your `pie` function with an empty array as its argument for now. The next step will get the correct array to put there. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const pieGraphData = pieGraph\.selectAll\((`|'|")pieSlices\1\)\s*\.\s*data\s*\(pie\s*\(\s*\[\s*\]\s*\)\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-95.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-95.english.md new file mode 100644 index 0000000000..8608913fb9 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-95.english.md @@ -0,0 +1,384 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca3c +title: Part 95 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +You want the array passed to `pie` to be an array of key/value objects for the 2020 followers. `d3.entries` will build that array for you. Here's how that looks: + +```js +d3.entries(data[8].followers)) +``` + +The array it builds looks like this: + +```js +[ + { key: 'twitter', value: 2845 }, + { key: 'tumblr', value: 2040 }, + { key: 'instagram', value: 4801 } +] +``` + +This is where the `value` comes from in your `pie` variable. + +Add the `d3.entries` function as your `pie` argument. Use it to create the above array. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/const pieGraphData = pieGraph\.selectAll\((`|'|")pieSlices\1\)\s*\.\s*data\s*\(pie\s*\(\s*d3\s*\.\s*entries\s*\(\s*data\s*\[\s*8\s*\]\s*\.\s*followers\s*\)\s*\)\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-96.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-96.english.md new file mode 100644 index 0000000000..5837d9d0d2 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-96.english.md @@ -0,0 +1,366 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca3d +title: Part 96 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Add the `enter` function to the current selection. Just like before, the initial selection here has a length of zero and the data has a length of three. So when you append elements in the next step, three will be created; one for each slice of the pie.
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/\.data\(pie\(d3\.entries\(data\[8\]\.followers\)\)\)\s*\.\s*enter\s*\(\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-97.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-97.english.md new file mode 100644 index 0000000000..3b67557b2f --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-97.english.md @@ -0,0 +1,369 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca3e +title: Part 97 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Use `append` to add three `g` elements for the pie. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('svg g').length === 20); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-98.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-98.english.md new file mode 100644 index 0000000000..b5cb9dd639 --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-98.english.md @@ -0,0 +1,372 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca3f +title: Part 98 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +On a new line, `append` a `path` element to your `pieGraphData` variable. This is where you will start to draw the pie chart. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert(/pieGraphData\s*\.\s*append\s*\((`|'|")path\1\s*\)/g.test(code)); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-99.english.md b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-99.english.md new file mode 100644 index 0000000000..a62f6961ea --- /dev/null +++ b/curriculum/challenges/english/04-data-visualization/d3-dashboard/part-99.english.md @@ -0,0 +1,373 @@ +--- +id: 5d8a4cfbe6b6180ed9a1ca40 +title: Part 99 +challengeType: 0 +isBeta: true +--- + +## Description +
+ +Set the `d` attribute to your `pieArc` variable. Just like the `d` in your lines, this is an SVG attribute for path elements that describes how to draw things. Your `pieArc` variable will determine what this value is for you. +
+ +## Instructions +
+
+ +## Tests +
+ +```yml +tests: + - text: test-text + testString: assert($('.dashboard div svg path')[0].getAttribute('d').length === 94); + +``` + +
+ +## Challenge Seed +
+
+ +```html + + +``` + +
+ + +### Before Test +
+ +```html + + + + D3 Dashboard + + + + +
+ + +``` + +
+
+ + +## Solution +
+ +```html + + +``` + +
diff --git a/utils/block-nameify.js b/utils/block-nameify.js index e72d4a6060..309bc751d1 100644 --- a/utils/block-nameify.js +++ b/utils/block-nameify.js @@ -21,7 +21,8 @@ const preFormattedBlockNames = { 'css-variables-skyline': 'CSS Variables Skyline', 'javascript-spreadsheet': 'JavaScript Spreadsheet', 'intermediate-javascript-calorie-counter': - 'Intermediate JavaScript Calorie Counter' + 'Intermediate JavaScript Calorie Counter', + 'd3-dashboard': 'D3 Dashboard Project' }; const noFormatting = ['and', 'for', 'of', 'the', 'up', 'with'];