---
id: 587d7fa8367417b2b2512bca
title: Change the Presentation of a Bar Chart
required:
- src: 'https://cdnjs.cloudflare.com/ajax/libs/d3/4.3.0/d3.min.js'
challengeType: 6
videoUrl: ''
localeTitle: 更改条形图的演示文稿
---
## Description
最后一个挑战创建了一个条形图,但有几个格式更改可以改善它:1)在每个条之间添加空格以在视觉上分隔它们,这是通过为bar
类添加边距来完成的2)增加条形的高度可以更好地显示值的差异,这可以通过将值乘以数字来缩放高度来完成
## Instructions
首先,在style
标记的bar
类中添加2px的margin
。接下来,更改style()
方法中的回调函数,使其返回原始数据值的10倍(加上“px”)。 注意
将每个数据点乘以相同的常数只会改变比例。它就像放大一样,并没有改变底层数据的含义。
## Tests
```yml
tests:
- text: 第一个div
的height
应为120像素, margin
为2像素。
testString: 'assert($("div").eq(0).css("height") == "120px" && $("div").eq(0).css("margin-right") == "2px", "The first div
should have a height
of 120 pixels and a margin
of 2 pixels.");'
- text: 第二个div
的height
应为310像素, margin
为2像素。
testString: 'assert($("div").eq(1).css("height") == "310px" && $("div").eq(1).css("margin-right") == "2px", "The second div
should have a height
of 310 pixels and a margin
of 2 pixels.");'
- text: 第三个div
的height
应为220像素, margin
为2像素。
testString: 'assert($("div").eq(2).css("height") == "220px" && $("div").eq(2).css("margin-right") == "2px", "The third div
should have a height
of 220 pixels and a margin
of 2 pixels.");'
- text: 第四个div
的height
应为170像素, margin
为2像素。
testString: 'assert($("div").eq(3).css("height") == "170px" && $("div").eq(3).css("margin-right") == "2px", "The fourth div
should have a height
of 170 pixels and a margin
of 2 pixels.");'
- text: 第五个div
的height
应为250像素, margin
为2像素。
testString: 'assert($("div").eq(4).css("height") == "250px" && $("div").eq(4).css("margin-right") == "2px", "The fifth div
should have a height
of 250 pixels and a margin
of 2 pixels.");'
- text: 第六个div
的height
应为180像素, margin
为2像素。
testString: 'assert($("div").eq(5).css("height") == "180px" && $("div").eq(5).css("margin-right") == "2px", "The sixth div
should have a height
of 180 pixels and a margin
of 2 pixels.");'
- text: 第七个div
的height
应为290像素, margin
为2像素。
testString: 'assert($("div").eq(6).css("height") == "290px" && $("div").eq(6).css("margin-right") == "2px", "The seventh div
should have a height
of 290 pixels and a margin
of 2 pixels.");'
- text: 第八个div
的height
应为140像素, margin
为2像素。
testString: 'assert($("div").eq(7).css("height") == "140px" && $("div").eq(7).css("margin-right") == "2px", "The eighth div
should have a height
of 140 pixels and a margin
of 2 pixels.");'
- text: 第九个div
的height
应为90像素, margin
为2像素。
testString: 'assert($("div").eq(8).css("height") == "90px" && $("div").eq(8).css("margin-right") == "2px", "The ninth div
should have a height
of 90 pixels and a margin
of 2 pixels.");'
```
## Challenge Seed
## Solution
```js
// solution required
```