- Expert Data Visualization
- Jos Dirksen
- 191字
- 2021-07-09 18:22:40
How does D3 work?
At this point, you should have a working environment, so let's start by looking at some code and see if we can get D3 up and running. As we've mentioned at the beginning of this chapter, D3 is most often used to create and manipulate SVG elements using a data-driven approach. SVG elements can represent shapes, lines, and also allow for grouping. If you need a reference to check what attributes are available for a specific SVG element, the Mozilla Developer Network also has an excellent page on that: https://developer.mozilla.org/en-US/docs/Web/SVG.
In this section, we'll perform the following steps:
- Create and add an empty SVG group (g) element, to which we'll add our data elements.
- Use a JavaScript array that contains some sample data to add rectangles to the SVG element created in the previous step.
- Show how changes in the data can be used to update the drawn rectangles.
- Explain how to handle added and removed data elements using D3.
At the end of these steps, you should have a decent idea of how D3 binds data to elements, and how you can update the bound data.
推薦閱讀
- C++程序設計(第3版)
- Python 3.7網絡爬蟲快速入門
- Docker and Kubernetes for Java Developers
- C語言程序設計(第2 版)
- Spring Boot+Spring Cloud+Vue+Element項目實戰:手把手教你開發權限管理系統
- Apache Karaf Cookbook
- HTML5+CSS3網站設計基礎教程
- 零基礎入門學習Python(第2版)
- Visual Basic程序設計上機實驗教程
- Python High Performance Programming
- Android應用開發實戰
- Java程序設計基礎(第6版)
- C語言程序設計實踐
- 深入理解Java虛擬機:JVM高級特性與最佳實踐
- 游戲設計的底層邏輯