donut

饼图

1{
2  "chartType": "donut",
3  "dataset": [
4    { "date": "2019", "profit": 10, "sales": 20 },
5    { "date": "2020", "profit": 30, "sales": 60 },
6    { "date": "2021", "profit": 30, "sales": 60 },
7    { "date": "2022", "profit": 50, "sales": 100 },
8    { "date": "2023", "profit": 40, "sales": 80 }
9  ]
10}

组合环形图

1{
2  "chartType": "donut",
3  "measures": [
4    {
5      "id": "sales",
6      "alias": "sales",
7      "parentId": "sales-and-profit"
8    },
9    {
10      "id": "profit",
11      "alias": "利润",
12      "parentId": "sales-and-profit"
13    },
14    {
15      "id": "rateOfReturn",
16      "alias": "回报率",
17      "parentId": "ratio"
18    }
19  ],
20  "dataset": [
21    { "date": "2019", "profit": 10, "sales": 20, "rateOfReturn": 0.1 },
22    { "date": "2020", "profit": 20, "sales": 40, "rateOfReturn": 0.2 },
23    { "date": "2021", "profit": 30, "sales": 60, "rateOfReturn": 0.3 },
24    { "date": "2022", "profit": 40, "sales": 80, "rateOfReturn": 0.4 },
25    { "date": "2023", "profit": 50, "sales": 100, "rateOfReturn": 0.5 }
26  ],
27  "dimensions": [
28    {
29      "id": "date",
30      "alias": "日期"
31    }
32  ]
33}

透视组合环形图

1{
2  "chartType": "donut",
3  "dimensions": [
4    { "id": "category", "alias": "类别" },
5    { "id": "date", "alias": "日期", "encoding": "column" },
6    { "id": "region", "alias": "区域", "encoding": "row" }
7  ],
8  "measures": [
9    { "id": "sales", "alias": "销售额", "parentId": "group-sales" },
10    { "id": "profit", "alias": "利润" }
11  ],
12  "dataset": [
13    { "date": "2019", "region": "east", "category": "Grocery", "profit": 10, "sales": 100 },
14    { "date": "2019", "region": "east", "category": "Beverages", "profit": 30, "sales": 3200 },
15    { "date": "2019", "region": "east", "category": "Dairy", "profit": 30, "sales": 300 },
16    { "date": "2019", "region": "east", "category": "Household", "profit": 50, "sales": 2400 },
17    { "date": "2019", "region": "east", "category": "Personal", "profit": 40, "sales": 500 },
18    { "date": "2019", "region": "west", "category": "Grocery", "profit": 10, "sales": 100 },
19    { "date": "2019", "region": "west", "category": "Beverages", "profit": 30, "sales": 3200 },
20    { "date": "2019", "region": "west", "category": "Dairy", "profit": 30, "sales": 300 },
21    { "date": "2019", "region": "west", "category": "Household", "profit": 50, "sales": 2400 },
22    { "date": "2019", "region": "west", "category": "Personal", "profit": 40, "sales": 500 },
23
24    { "date": "2020", "region": "east", "category": "Grocery", "profit": 10, "sales": 100 },
25    { "date": "2020", "region": "east", "category": "Beverages", "profit": 30, "sales": 3200 },
26    { "date": "2020", "region": "east", "category": "Dairy", "profit": 30, "sales": 300 },
27    { "date": "2020", "region": "east", "category": "Household", "profit": 50, "sales": 2400 },
28    { "date": "2020", "region": "east", "category": "Personal", "profit": 40, "sales": 500 },
29    { "date": "2020", "region": "west", "category": "Grocery", "profit": 10, "sales": 100 },
30    { "date": "2020", "region": "west", "category": "Beverages", "profit": 30, "sales": 3200 },
31    { "date": "2020", "region": "west", "category": "Dairy", "profit": 30, "sales": 300 },
32    { "date": "2020", "region": "west", "category": "Household", "profit": 50, "sales": 2400 },
33    { "date": "2020", "region": "west", "category": "Personal", "profit": 40, "sales": 500 }
34  ]
35}