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

  • Expert Data Visualization
  • Jos Dirksen
  • 244字
  • 2021-07-09 18:22:45

Creating the donut

The complete source file for this sample is a bit long, so we won't show it completely. You can, of course, look at the complete annotated sources here: <DVD3>/src/chapter-02/D02-01.html. In the following sections, we'll explore the steps you need to take to create this visualization:

  1. First, we need to load our sanitized data so that we can use it to create the donut.
  2. Next, we're going to add the dropdown you can see at the top. With this dropdown, we can select which group we want to show in the donut.
  3. Before we look at the D3 code needed to create the donut, we set up some helper objects for handling colors and determining the arc segments dimensions.
  4. When you open the page for the first time, we see an empty gray donut. This one we'll add next.
  5. Then we add the inpidual donut segments-based on the selected group from the dropdown and make sure that they are animated when a new group is selected.
  6. Besides the arc segments, we also have labels that describe what a specific segment means. We add and animate these separately.
  7. We also add and animate the lines pointing from the center of a donut segment to the text label.
  8. Use mouse events to show a percentage and pop out a donut segment.

Lots of steps to take, but as you'll see, most will follow the same principles we've already learned about in the previous chapter.

主站蜘蛛池模板: 苏尼特右旗| 绿春县| 庆城县| 德安县| 库尔勒市| 郑州市| 探索| 唐河县| 乌苏市| 扬州市| 屏山县| 尼勒克县| 漯河市| 江川县| 靖安县| 弥勒县| 湘潭县| 松江区| 芷江| 桦南县| 尚志市| 南丰县| 清镇市| 呼伦贝尔市| 丰宁| 岗巴县| 黄大仙区| 工布江达县| 庆城县| 秦安县| 裕民县| 汕头市| 伊春市| 舞钢市| 西平县| 莱芜市| 平乡县| 元阳县| 巩义市| 乌审旗| 吉隆县|