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

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.

主站蜘蛛池模板: 三原县| 朔州市| 西贡区| 独山县| 报价| 富蕴县| 青阳县| 本溪市| 元朗区| 治县。| 枣庄市| 遵义县| 小金县| 阳曲县| 马山县| 海门市| 连云港市| 石渠县| 阿拉善右旗| 东源县| 宁都县| 南澳县| 大埔区| 宁武县| 茌平县| 尼玛县| 桐柏县| 奉贤区| 广东省| 龙岩市| 谢通门县| 正阳县| 揭东县| 鄂州市| 开阳县| 交口县| 古浪县| 涞水县| 谢通门县| 广昌县| 津南区|