--- id: 587d7fab367417b2b2512bd9 title: Add Labels to Scatter Plot Circles required: - src: 'https://cdnjs.cloudflare.com/ajax/libs/d3/4.3.0/d3.min.js' challengeType: 6 videoUrl: '' localeTitle: Adicionar rótulos aos círculos de plotagem de dispersão --- ## Description
Você pode adicionar texto para criar rótulos para os pontos em um gráfico de dispersão. O objetivo é exibir os valores separados por vírgulas dos primeiros campos ( x ) e segundos ( y ) de cada item no dataset . As text nós precisamos x e y atributos para posicioná-la na tela SVG. Nesse desafio, o valor y (que determina a altura) pode usar o mesmo valor que o circle usa para seu atributo cy . O valor x pode ser um pouco maior que o valor cx do circle , portanto, o rótulo fica visível. Isso empurrará o rótulo para a direita do ponto plotado.
## Instructions
Rotule cada ponto no gráfico de dispersão usando os elementos de text . O texto do rótulo deve ser os dois valores separados por uma vírgula e um espaço. Por exemplo, o rótulo para o primeiro ponto é "34, 78". Defina o atributo x para que ele seja 5 unidades a mais que o valor usado para o atributo cx no circle . Defina o atributo y da mesma maneira que é usado para o valor de cy no circle .
## Tests
```yml tests: - text: Seu código deve ter 10 elementos de text . testString: 'assert($("text").length == 10, "Your code should have 10 text elements.");' - text: 'A primeira etiqueta deve ter o texto "34, 78", um valor x de 39 e um valor y de 422.' testString: 'assert($("text").eq(0).text() == "34, 78" && $("text").eq(0).attr("x") == "39" && $("text").eq(0).attr("y") == "422", "The first label should have text of "34, 78", an x value of 39, and a y value of 422.");' - text: 'A segunda etiqueta deve ter texto de "109, 280", um valor de x de 114 e um valor de y de 220.' testString: 'assert($("text").eq(1).text() == "109, 280" && $("text").eq(1).attr("x") == "114" && $("text").eq(1).attr("y") == "220", "The second label should have text of "109, 280", an x value of 114, and a y value of 220.");' - text: 'O terceiro rótulo deve ter o texto "310, 120", um valor x de 315 e um valor y de 380.' testString: 'assert($("text").eq(2).text() == "310, 120" && $("text").eq(2).attr("x") == "315" && $("text").eq(2).attr("y") == "380", "The third label should have text of "310, 120", an x value of 315, and a y value of 380.");' - text: 'O quarto rótulo deve ter o texto "79, 411", um valor x de 84 e um valor y de 89.' testString: 'assert($("text").eq(3).text() == "79, 411" && $("text").eq(3).attr("x") == "84" && $("text").eq(3).attr("y") == "89", "The fourth label should have text of "79, 411", an x value of 84, and a y value of 89.");' - text: 'O quinto rótulo deve ter texto de "420, 220", um valor de x de 425 e um valor de y de 280.' testString: 'assert($("text").eq(4).text() == "420, 220" && $("text").eq(4).attr("x") == "425" && $("text").eq(4).attr("y") == "280", "The fifth label should have text of "420, 220", an x value of 425, and a y value of 280.");' - text: 'O sexto rótulo deve ter texto de "233, 145", um valor de x de 238 e um valor de y de 355.' testString: 'assert($("text").eq(5).text() == "233, 145" && $("text").eq(5).attr("x") == "238" && $("text").eq(5).attr("y") == "355", "The sixth label should have text of "233, 145", an x value of 238, and a y value of 355.");' - text: 'O sétimo rótulo deve ter texto de "333, 96", um valor de x de 338 e um valor de y de 404.' testString: 'assert($("text").eq(6).text() == "333, 96" && $("text").eq(6).attr("x") == "338" && $("text").eq(6).attr("y") == "404", "The seventh label should have text of "333, 96", an x value of 338, and a y value of 404.");' - text: 'O oitavo rótulo deve ter o texto "222, 333", um valor x de 227 e um valor y de 167.' testString: 'assert($("text").eq(7).text() == "222, 333" && $("text").eq(7).attr("x") == "227" && $("text").eq(7).attr("y") == "167", "The eighth label should have text of "222, 333", an x value of 227, and a y value of 167.");' - text: 'O nono rótulo deve ter texto de "78, 320", um valor de x de 83 e um valor de y de 180.' testString: 'assert($("text").eq(8).text() == "78, 320" && $("text").eq(8).attr("x") == "83" && $("text").eq(8).attr("y") == "180", "The ninth label should have text of "78, 320", an x value of 83, and a y value of 180.");' - text: 'O décimo rótulo deve ter texto de "21, 123", um valor de x de 26 e um valor de y de 377.' testString: 'assert($("text").eq(9).text() == "21, 123" && $("text").eq(9).attr("x") == "26" && $("text").eq(9).attr("y") == "377", "The tenth label should have text of "21, 123", an x value of 26, and a y value of 377.");' ```
## Challenge Seed
```html ```
## Solution
```js // solution required ```