4 - Work with Dynamic Data - Data Visualization with D3 - freeCodeCamp Tutorial

Опубликовано: 03 Июнь 2020
на канале: Ganesh H
676
6

We're now going to set the heading text dynamically by providing a function into the text() method, instead of a string. This function can take in an item from the array and return some data from it to set as the text for each created element.

Link to challenge : https://www.freecodecamp.org/learn/da...
Concepts:
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.
https://github.com/d3/d3-selection/bl...

selection.data([data[, key]])
Binds the specified array of data with the selected elements, returning a new selection that represents the update selection: the elements successfully bound to data. Also defines the enter and exit selections on the returned selection, which can be used to add or remove elements to correspond to the new data. The specified data is an array of arbitrary values (e.g., numbers or objects), or a function that returns an array of values for each group. When data is assigned to an element, it is stored in the property __data__, thus making the data “sticky” and available on re-selection.
https://github.com/d3/d3-selection/bl...

selection.enter()
Returns the enter selection: placeholder nodes for each datum that had no corresponding DOM element in the selection. (The enter selection is empty for selections not returned by selection.data.)
The enter selection is typically used to create “missing” elements corresponding to new data.
https://github.com/d3/d3-selection/bl...
————————————————————————————————————
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 interactive learning web platform, an online community forum, chat rooms, online publications and local organizations that intend to make learning web development accessible to anyone. Beginning with tutorials that introduce students to HTML, CSS and JavaScript, students progress to project assignments that they complete either alone or in pairs. Upon completion of all project tasks, students are partnered with other nonprofits to build web applications, giving the students practical development experience.

Thanks for Watching!


Смотрите видео 4 - Work with Dynamic Data - Data Visualization with D3 - freeCodeCamp Tutorial онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Ganesh H 03 Июнь 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 676 раз и оно понравилось 6 людям.