28 - Use a Pre-Defined Scale to Place Elements - Data Visualization with D3 - freeCodeCamp Tutorial
Ganesh H
We're gonna use the scales we created in the previous challenge to place our SVG circle elements.
Link to challenge : https://www.freecodecamp.org/learn/data-visualization/data-visualization-with-d3/use-a-pre-defined-scale-to-place-elements Concepts: selection.attr(name[, value]) If a value is specified, sets the attribute with the specified name to the specified value on the selected elements and returns this selection. If the value is a constant, all elements are given the same attribute value; otherwise, if the value is a function, it is evaluated for each selected element, in order, being passed the current datum (d), the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). The function’s return value is then used to set each element’s attribute. A null value will remove the specified attribute. If a value is not specified, returns the current value of the specified attribute for the first (non-null) element in the selection. This is generally useful only if you know that the selection contains exactly one element. https://github.com/d3/d3-selection/blob/v1.4.1/README.md#selection_attr
circle circle element is used to draw circle with a center point and given radius. cx − x-axis co-ordinate of the center of the circle. Default is 0. cy − y-axis co-ordinate of the center of the circle. Default is 0. r − radius of the circle. https://developer.mozilla.org/en-US/docs/Web/SVG/Element/circle
selection.text([value]) If a value is specified, sets the text content to the specified value on all selected elements, replacing any existing child elements. If the value is a constant, then all elements are given the same text content; otherwise, if the value is a function, it is evaluated for each selected element, in order, being passed the current datum (d), the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). The function’s return value is then used to set each element’s text content. A null value will clear the content. If a value is not specified, returns the text content for the first (non-null) element in the selection. This is generally useful only if you know the selection contains exactly one element. https://github.com/d3/d3-selection/blob/v1.4.1/README.md#selection_text -————————————————————————————————————- D3.js (also known as D3, short for Data-Driven Documents) is a JavaScript library for producing dynamic, interactive data visualizations in web browsers. It makes use of Scalable Vector Graphics (SVG), HTML5, and Cascading Style Sheets (CSS) standards.
freeCodeCamp (also referred to as “Free Code Camp”) is a non-profit organization that consists of an inter ... https://www.youtube.com/watch?v=Mgou4HdrW8E
16351904 Bytes