diff --git a/curriculum/challenges/chinese/04-data-visualization/data-visualization-with-d3/add-a-hover-effect-to-a-d3-element.chinese.md b/curriculum/challenges/chinese/04-data-visualization/data-visualization-with-d3/add-a-hover-effect-to-a-d3-element.chinese.md
index 328fa3624f..79f4381746 100644
--- a/curriculum/challenges/chinese/04-data-visualization/data-visualization-with-d3/add-a-hover-effect-to-a-d3-element.chinese.md
+++ b/curriculum/challenges/chinese/04-data-visualization/data-visualization-with-d3/add-a-hover-effect-to-a-d3-element.chinese.md
@@ -2,22 +2,27 @@
id: 587d7faa367417b2b2512bd4
title: Add a Hover Effect to a D3 Element
challengeType: 6
-videoUrl: ''
-localeTitle: 将悬停效果添加到D3元素
+forumTopicId: 301469
+localeTitle: 给 D3 元素添加悬停效果
---
## Description
-当用户用鼠标悬停在其上时,可以添加突出显示条形的效果。到目前为止,矩形的样式使用内置的D3和SVG方法,但您也可以使用CSS。使用attr()
方法在SVG元素上设置CSS类。然后,新类的:hover
伪类保存任何悬停效果的样式规则。
+
+我们可以为用户的鼠标悬停行为添加高亮显示的效果。到目前为止,矩形的样式应用了内置的 D3 和 SVG 方法,但是你也可以使用 CSS 来实现。
+你可以使用 attr()
方法在 SVG 元素上设置 CSS 类。然后用 :hover
伪类为你新添加的 CSS 类设置鼠标悬停的效果。
+
## Instructions
-使用attr()
方法向所有rect
元素添加一个bar
类。将鼠标悬停在其上时,会将条形的fill
颜色更改为棕色。
+
+用 attr()
方法给所有的 rect
元素都添加 bar
类。当鼠标悬停在元素上时,它的 fill
将变为棕色。
+
## Tests
```yml
tests:
- - text: 你的rect
元素应该有一类bar
。
+ - text: rect
元素应该有 bar
类。
testString: assert($('rect').attr('class') == "bar");
```
@@ -56,11 +61,11 @@ tests:
.attr("width", 25)
.attr("height", (d, i) => 3 * d)
.attr("fill", "navy")
- // Add your code below this line
+ // 在下面添加你的代码
- // Add your code above this line
+ // 在上面添加你的代码
svg.selectAll("text")
.data(dataset)
@@ -72,7 +77,6 @@ tests: