---
id: 587d7fa9367417b2b2512bd0
title: Invert SVG Elements
required:
- src: 'https://cdnjs.cloudflare.com/ajax/libs/d3/4.3.0/d3.min.js'
challengeType: 6
videoUrl: ''
localeTitle: 反转SVG元素
---
## Description
undefined
## Instructions
更改y
属性的回调函数以将栏设置为正面朝上。请记住,条形的height
是数据值d
3倍。 注意
通常,关系是y = h - m * d
,其中m
是缩放数据点的常数。
## Tests
```yml
tests:
- text: 第一个rect
的y
值应为64。
testString: 'assert($("rect").eq(0).attr("y") == h - (dataset[0] * 3), "The first rect
should have a y
value of 64.");'
- text: 第二个rect
的y
值应为7。
testString: 'assert($("rect").eq(1).attr("y") == h - (dataset[1] * 3), "The second rect
should have a y
value of 7.");'
- text: 第三个rect
的y
值应为34。
testString: 'assert($("rect").eq(2).attr("y") == h - (dataset[2] * 3), "The third rect
should have a y
value of 34.");'
- text: 第四个rect
的y
值应为49。
testString: 'assert($("rect").eq(3).attr("y") == h - (dataset[3] * 3), "The fourth rect
should have a y
value of 49.");'
- text: 第五个rect
的y
值应为25。
testString: 'assert($("rect").eq(4).attr("y") == h - (dataset[4] * 3), "The fifth rect
should have a y
value of 25.");'
- text: 第六个rect
的y
值应为46。
testString: 'assert($("rect").eq(5).attr("y") == h - (dataset[5] * 3), "The sixth rect
should have a y
value of 46.");'
- text: 第七个rect
的y
值应为13。
testString: 'assert($("rect").eq(6).attr("y") == h - (dataset[6] * 3), "The seventh rect
should have a y
value of 13.");'
- text: 第八个rect
的y
值应为58。
testString: 'assert($("rect").eq(7).attr("y") == h - (dataset[7] * 3), "The eighth rect
should have a y
value of 58.");'
- text: 第九个rect
的y
值应为73。
testString: 'assert($("rect").eq(8).attr("y") == h - (dataset[8] * 3), "The ninth rect
should have a y
value of 73.");'
```
## Challenge Seed
## Solution
```js
// solution required
```