freeCodeCamp/curriculum/challenges/chinese/04-data-visualization/data-visualization-projects/visualize-data-with-a-treem...

39 lines
4.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
id: 587d7fa6367417b2b2512bc0
title: Visualize Data with a Treemap Diagram
isRequired: true
challengeType: 3
videoUrl: ''
localeTitle: 使用树形图可视化数据
---
## Description
<section id="description"> <strong>目标:</strong>构建一个功能类似于此的<a href="https://codepen.io" target="_blank">CodePen.io</a>应用程序: <a href="https://codepen.io/freeCodeCamp/full/KaNGNR" target="_blank">https</a> <strong></strong> <a href="https://codepen.io" target="_blank">//codepen.io/freeCodeCamp/full/KaNGNR</a> 。完成以下<a href="https://en.wikipedia.org/wiki/User_story" target="_blank">用户故事</a>并通过所有测试。给它你自己的个人风格。您可以使用HTMLJavaScriptCSS和基于D3 svg的可视化库。测试需要使用D3轴属性生成轴该属性会自动生成沿轴的刻度。通过D3测试需要这些刻度因为它们的位置用于确定绘制元素的对齐方式。有关生成轴的信息 <a href="https://github.com/d3/d3/blob/master/API.md#axes-d3-axis" target="_blank"></a>访问<a href="https://github.com/d3/d3/blob/master/API.md#axes-d3-axis" target="_blank">https://github.com/d3/d3/blob/master/API.md#axes-d3-axis</a> 。在每次测试时查询必需非虚拟DOM元素。如果您使用前端框架例如Vue则测试结果可能对动态内容不准确。我们希望最终能够容纳它们但D3项目目前不支持这些框架。 <strong>用户故事1</strong>我的树图应该有一个标题,对应的<code>id=&quot;title&quot;</code><strong>用户故事2</strong>我的树图应该有一个对应<code>id=&quot;description&quot;</code><strong>用户故事3</strong>我的树形图应该有一个<code>rect</code>元素,并且对应的<code>class=&quot;tile&quot;</code>代表数据。 <strong>用户故事4</strong>瓷砖应至少有2种不同的填充颜色。 <strong>用户故事5</strong>每个瓷砖应具有属性<code>data-name</code> <code>data-category</code> ,和<code>data-value</code>包含其相应的名称,类别,和值。 <strong>用户故事6</strong>每个图块的区域应对应于数据值量:具有较大数据值的图块应具有更大的区域。 <strong>用户故事7</strong>我的树形图应该有一个对应<code>id=&quot;legend&quot;</code><strong>用户故事8</strong>我的图例应该有一个带有相应<code>class=&quot;legend-item&quot;</code> <code>rect</code>元素。 <strong>用户故事9</strong>图例中的<code>rect</code>元素应使用至少2种不同的填充颜色。 <strong>用户故事10</strong>我可以将鼠标悬停在某个区域上,并查看带有相应<code>id=&quot;tooltip&quot;</code> ,其中显示有关该区域的更多信息。 <strong>用户故事11</strong>我的工具提示应具有与活动区域的<code>data-value</code>对应的<code>data-value</code> <code>data-value</code>属性。对于此项目,您可以使用以下任何数据集: <br><ul><li> <strong>Kickstarter承诺</strong> <code>https://cdn.freecodecamp.org/testable-projects-fcc/data/tree_map/kickstarter-funding-data.json</code> <strong></strong> <code>https://cdn.freecodecamp.org/testable-projects-fcc/data/tree_map/kickstarter-funding-data.json</code> </li><li> <strong>电影销售:</strong> <code>https://cdn.freecodecamp.org/testable-projects-fcc/data/tree_map/movie-data.json</code> <strong></strong> <code>https://cdn.freecodecamp.org/testable-projects-fcc/data/tree_map/movie-data.json</code> </li><li> <strong>视频游戏销售:</strong> <code>https://cdn.freecodecamp.org/testable-projects-fcc/data/tree_map/video-game-sales-data.json</code> <strong></strong> <code>https://cdn.freecodecamp.org/testable-projects-fcc/data/tree_map/video-game-sales-data.json</code> </li></ul>您可以通过分叉<a href="https://codepen.io/freeCodeCamp/pen/MJjpwO" target="_blank">此CodePen笔</a>来构建项目。或者您可以使用此CDN链接在您喜欢的任何环境中运行测试 <code>https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js</code> <code>https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js</code>完成后将URL提交给您的工作通过所有测试的项目。如果卡住请记住使用<a href="https://www.freecodecamp.org/forum/t/how-to-get-help-when-you-are-stuck-coding/19514" target="_blank">Read-Search-Ask</a>方法。 </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests: []
```
</section>
## Challenge Seed
<section id='challengeSeed'>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>