freeCodeCamp/curriculum/challenges/arabic/04-data-visualization/data-visualization-with-d3/create-a-bar-for-each-data-...

81 lines
1.4 KiB
Markdown
Raw Normal View History

---
id: 587d7fa8367417b2b2512bcd
title: Create a Bar for Each Data Point in the Set
required:
- src: 'https://cdnjs.cloudflare.com/ajax/libs/d3/4.3.0/d3.min.js'
challengeType: 6
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert($("rect").length == 9, "Your document should have 9 <code>rect</code> elements.");'
- text: ''
testString: 'assert(code.match(/\.data/g), "Your code should use the <code>data()</code> method.");'
- text: ''
testString: 'assert(code.match(/\.enter/g), "Your code should use the <code>enter()</code> method.");'
- text: ''
testString: 'assert(code.match(/\.append/g), "Your code should use the <code>append()</code> method.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```html
<body>
<script>
const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9];
const w = 500;
const h = 100;
const svg = d3.select("body")
.append("svg")
.attr("width", w)
.attr("height", h);
svg.selectAll("rect")
// Add your code below this line
// Add your code above this line
.attr("x", 0)
.attr("y", 0)
.attr("width", 25)
.attr("height", 100);
</script>
</body>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>