sissou123

Untitled

Mar 18th, 2022
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. Data Visualization
  2. Data Visualization with D3
  3. Work with Data in D3
  4. The D3 library focuses on a data-driven approach. When you have a set of data, you can apply D3 methods to display it on the page. Data comes in many formats, but this challenge uses a simple array of numbers.
  5.  
  6. The first step is to make D3 aware of the data. The data() method is used on a selection of DOM elements to attach the data to those elements. The data set is passed as an argument to the method.
  7.  
  8. A common workflow pattern is to create a new element in the document for each piece of data in the set. D3 has the enter() method for this purpose.
  9.  
  10. When enter() is combined with the data() method, it looks at the selected elements from the page and compares them to the number of data items in the set. If there are fewer elements than data items, it creates the missing elements.
  11. <body>
  12. <ul></ul>
  13. <script>
  14. const dataset = ["a", "b", "c"];
  15. d3.select("ul").selectAll("li")
  16. .data(dataset)
  17. .enter()
  18. .append("li")
  19. .text("New item");
  20. </script>
  21. </body>
  22. for more:https://ouo.io/eufR0PA
Add Comment
Please, Sign In to add comment