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

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.

主站蜘蛛池模板: 台安县| 静宁县| 华亭县| 舒兰市| 宝丰县| 长泰县| 宁陵县| 兰溪市| 抚宁县| 弥勒县| 泸溪县| 龙山县| 泰州市| 区。| 吴忠市| 都江堰市| 鹤山市| 托克逊县| 湟源县| 新野县| 二手房| 吉隆县| 从江县| 巢湖市| 合作市| 邛崃市| 从化市| 东城区| 宝山区| 龙州县| 阳泉市| 丰城市| 蕲春县| 江陵县| 周宁县| 桂东县| 剑河县| 筠连县| 黔东| 灌南县| 闵行区|