freeCodeCamp/curriculum/challenges/spanish/04-data-visualization/data-visualization-with-d3/add-inline-styling-to-eleme...

1.7 KiB

id title challengeType videoUrl localeTitle
587d7fa7367417b2b2512bc6 Add Inline Styling to Elements 6 Añadir estilo en línea a los elementos

Description

D3 le permite agregar estilos CSS en línea en elementos dinámicos con el método style() . El método style() toma un par clave-valor separado por comas como argumento. Aquí hay un ejemplo para establecer el color del texto de la selección en azul: selection.style("color","blue");

Instructions

Agregue el método style() al código en el editor para hacer que todo el texto mostrado tenga una font-family de verdana .

Tests

tests:
  - text: Tus elementos <code>h2</code> deben tener una <code>font-family</code> de verdana.
    testString: 'assert($("h2").css("font-family") == "verdana", "Your <code>h2</code> elements should have a <code>font-family</code> of verdana.");'
  - text: Su código debe utilizar el método <code>style()</code> .
    testString: 'assert(code.match(/\.style/g), "Your code should use the <code>style()</code> method.");'

Challenge Seed

<body>
  <script>
    const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9];

    d3.select("body").selectAll("h2")
      .data(dataset)
      .enter()
      .append("h2")
      .text((d) => (d + " USD"))
      // Add your code below this line



      // Add your code above this line
  </script>
</body>

Solution

// solution required