官术网_书友最值得收藏!

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:

  1. Create and add an empty SVG group (g) element, to which we'll add our data elements.
  2. Use a JavaScript array that contains some sample data to add rectangles to the SVG element created in the previous step.
  3. Show how changes in the data can be used to update the drawn rectangles.
  4. 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.

主站蜘蛛池模板: 明星| 蓬莱市| 阿勒泰市| 咸阳市| 绥芬河市| 稻城县| 奇台县| 乐都县| 泸定县| 丰原市| 迁西县| 伊金霍洛旗| 阳信县| 湖口县| 晋州市| 莎车县| 舟曲县| 宁南县| 长岭县| 且末县| 武宣县| 上思县| 乌兰浩特市| 青浦区| 重庆市| 武陟县| 滦平县| 成都市| 宿松县| 隆安县| 松滋市| 兴仁县| 明光市| 江陵县| 昂仁县| 华池县| 桐柏县| 莱西市| 九台市| 天长市| 开封市|