- 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:
- First, we need to load our sanitized data so that we can use it to create the donut.
- 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.
- 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.
- When you open the page for the first time, we see an empty gray donut. This one we'll add next.
- 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.
- Besides the arc segments, we also have labels that describe what a specific segment means. We add and animate these separately.
- We also add and animate the lines pointing from the center of a donut segment to the text label.
- 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.
推薦閱讀
- ClickHouse性能之巔:從架構(gòu)設(shè)計(jì)解讀性能之謎
- SQL Server 2016從入門到精通(視頻教學(xué)超值版)
- Scratch 3游戲與人工智能編程完全自學(xué)教程
- Access 2010數(shù)據(jù)庫(kù)基礎(chǔ)與應(yīng)用項(xiàng)目式教程(第3版)
- 正則表達(dá)式經(jīng)典實(shí)例(第2版)
- MySQL入門很輕松(微課超值版)
- Hands-On Full Stack Development with Spring Boot 2.0 and React
- Instant Zurb Foundation 4
- Python一行流:像專家一樣寫代碼
- SAP Web Dynpro for ABAP開發(fā)技術(shù)詳解:基礎(chǔ)應(yīng)用
- Go Systems Programming
- React and React Native
- Java程序性能優(yōu)化實(shí)戰(zhàn)
- Learning Redis
- TensorFlow程序設(shè)計(jì)