Skip to content

Commit 2c3ae81

Browse files
committed
BREAKING CHANGE: update the configuration of the RadialBar
1 parent 15b0a91 commit 2c3ae81

15 files changed

Lines changed: 82 additions & 49 deletions

File tree

packages/plots/src/core/plots/radial-bar/adaptor.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ export function adaptor(params: Params) {
5959
const { markBackground, children, scale, coordinate, xField } = options;
6060
const domain = get(scale, 'y.domain', []);
6161
if (markBackground) {
62+
const { style, ...rest } = markBackground;
6263
children.unshift({
6364
type: 'interval',
6465
xField: xField,
6566
yField: domain[domain.length - 1],
66-
colorField: markBackground.color,
67-
scale: { color: { type: 'identity' } },
6867
style: {
69-
fillOpacity: markBackground.opacity,
70-
fill: markBackground.color ? undefined : '#e0e4ee', // 默认用fill填满灰色背景
68+
fillOpacity: 0.4,
69+
fill: '#e0e4ee', // 默认用fill填满灰色背景
70+
...style,
7171
},
7272
// 背景图需要填满整个圆
7373
coordinate: {
@@ -76,7 +76,7 @@ export function adaptor(params: Params) {
7676
endAngle: (3 / 2) * Math.PI,
7777
},
7878
animate: false,
79-
...markBackground,
79+
...rest,
8080
});
8181
}
8282
return params;

packages/plots/src/core/plots/radial-bar/type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ export type RadialBarOptions = Options & {
3030
* @default null
3131
* @description 通过配置color指定颜色参数,必须配合scale.y.domain 指定背景轴的范围区间
3232
*/
33-
markBackground: Record<string, string>;
33+
markBackground: Record<string, any>;
3434
};

site/docs/components/plots/bar.zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ conversionTag: {
6565
| data | [数据](/options/plots/data/overview) | Array | [] |
6666
| xField | 横轴字段 | string | - |
6767
| yField | 纵轴字段 | string \| string[] | - |
68-
| seriesField | 多折线图区分字段 | string(可选) | - |
68+
| seriesField | 多条形图区分字段 | string(可选) | - |
6969
| colorField | 和 seriesField 类似,不过会加上颜色通道,详见[color](/options/plots/color) | string(可选) | - |
7070
| stack | 条形图是否堆叠 | boolean\|[Stack](#stack) | false |
7171
| group | 条形图是否分组 | boolean\|[Group](#group) | false |

site/docs/components/plots/box.zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ p12 p11 p13
9494
| data | [数据](#data) | Array | [] |
9595
| xField | 横轴字段 | string | - |
9696
| yField | 纵轴字段 | string \| string[] | - |
97-
| seriesField | 多折线图区分字段 | string(可选) | - |
97+
| seriesField | 多箱线图区分字段 | string(可选) | - |
9898
| colorField | 和 seriesField 类似,不过会加上颜色通道,详见[color](/options/plots/color) | string(可选) | - |
9999
| boxType | 标记类型,可选值为 `box``boxplot``box` 是原子标记,需要开发者手动指定 5 个统计点的数据; `boxplot` 是高阶标记,自带数据分组和数据统计聚合功能; | box \| boxplot | `box` |
100100
| transpose | 是否开启坐标转置 | boolean | - |

site/docs/components/plots/column.zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ conversionTag: {
7272
| data | [数据](/options/plots/data/overview) | Array | [] |
7373
| xField | 横轴字段 | string | - |
7474
| yField | 纵轴字段 | string \| string[] | - |
75-
| seriesField | 多折线图区分字段 | string(可选) | - |
75+
| seriesField | 多柱状图区分字段 | string(可选) | - |
7676
| colorField | 和 seriesField 类似,不过会加上颜色通道,详见[color](/options/plots/color) | string(可选) | - |
7777
| stack | 柱状图是否堆叠 | boolean\|[Stack](#stack) | false |
7878
| group | 柱状图是否分组 | boolean\|[Group](#group) | false |

site/docs/components/plots/dual-axes.zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ order: 5
5555
| xField | 横轴字段 | string | - |
5656
| yField | 纵轴字段 | string \| string[] | - |
5757
| children | 图表列表 | any[] | - |
58-
| seriesField | 多折线图区分字段 | string(可选) | - |
58+
| seriesField | 多 Mark 区分字段 | string(可选) | - |
5959
| colorField | 和 seriesField 类似,不过会加上颜色通道,详见[color](/options/plots/color) | string(可选) | - |
6060
| title | 用于指定图表的标题内容,详见[标题](/options/plots/title) | object(可选) | - |
6161
| axis | 用于建立数据与视觉位置的映射关系,详见[坐标轴](/options/plots/axis) | object(可选) | - |

site/docs/components/plots/radial-bar.zh.md

Lines changed: 72 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,85 @@ link: /examples#statistics-radial-bar
88
order: 21
99
---
1010

11-
## 特有
11+
## 简介
1212

13-
### markBackground
13+
玉珏图(RadialBar)又名环形柱状图,是柱状图关于笛卡尔坐标系转换到极坐标系的仿射变换。其意义和用法与柱状图类似。
1414

15-
<description>**optional** _BarOptions_</description>
15+
玉珏图有半径反馈效应。由于玉珏图中是用角度表示每个珏环数值的大小,角度是决定性因素。所以,哪怕外侧(半径大的)珏环的数值小于内侧(半径小的)珏环,外侧的每个珏环会相对的比里面的珏环更长。这会造成视觉上的误解。
1616

17-
data 参数
17+
而且因为我们的视觉系统更善于比较直线,所以笛卡尔坐标系更适合于比较各个分类的数值比较。所以玉珏图从实用的角度去看,其更多的是一种审美上的需求。。
1818

19-
```ts
20-
const data = [
21-
{ name: 'X6', star: 297, color: 'pink' },
22-
{ name: 'G', star: 506, color: 'pink' },
23-
{ name: 'AVA', star: 805, color: 'pink' },
24-
{ name: 'G2Plot', star: 1478, color: 'orange' },
25-
{ name: 'L7', star: 2029, color: 'orange' },
26-
{ name: 'G6', star: 7100, color: 'orange' },
27-
{ name: 'F2', star: 7346, color: 'orange' },
28-
{ name: 'G2', star: 10178, color: 'blue' },
29-
];
30-
```
19+
## 代码演示
20+
21+
更多示例详见[玉珏图](/examples#statistics-radial-bar)
22+
23+
### 基础用法
24+
25+
<Playground path="/statistics/radial-bar/demo/basic.js" rid="radial-bar-basic"></playground>
26+
27+
### 带圆角
28+
29+
<Playground path="/statistics/radial-bar/demo/round-corner.js" rid="radial-bar-round-corner"></playground>
30+
31+
### 自定义颜色
32+
33+
<Playground path="/statistics/radial-bar/demo/color.js" rid="radial-bar-color"></playground>
34+
35+
### 堆叠
3136

32-
mark 背景配置
37+
<Playground path="/statistics/radial-bar/demo/stacked.js" rid="radial-bar-stacked"></playground>
38+
39+
### 带背景
40+
41+
<Playground path="/statistics/radial-bar/demo/background.js" rid="radial-bar-background"></playground>
42+
43+
44+
## 配置项
45+
46+
### 概览
47+
48+
|配置项|说明|类型|默认值|
49+
|-----|---|----|-----|
50+
| data | [数据](/options/plots/data/overview) | Array | [] |
51+
| xField | 横轴字段 | string | - |
52+
| yField | 纵轴字段 | string \| string[] | - |
53+
| colorField | 颜色映射通道,详见[color](/options/plots/color) | string(可选) | - |
54+
| radius | 半径 | number[0~1] | - |
55+
| innerRadius | 内径 | number[0~1] | 0 |
56+
| startAngle | 起始角度 | number | - |
57+
| endAngle | 起始角度 | number | - |
58+
| stack | 柱状图是否堆叠 | boolean\|[Stack](#stack) | false |
59+
| group | 柱状图是否分组 | boolean\|[Group](#group) | false |
60+
| markBackground | 元素背景配置,和配置柱子无区别,可以看做是放置于底层的 Column 组件,需要配置 `scale.y.domain` 才能生效 | [MarkBackground](#markBackground) | - |
61+
| title | 用于指定图表的标题内容,详见[标题](/options/plots/title) | object(可选) | - |
62+
| legend | 图表的辅助元素,使用颜色、大小、形状区分不同的数据类型,用于图表中数据的筛选,详见[图例](/options/plots/legend) | object(可选) | - |
63+
| label | 数据标签是给图表添加标注的手段之一,详见[标签](/options/plots/label) | object(可选) | - |
64+
| tooltip | 用于动态展示数据点的详细信息,详见[提示](/options/plots/tooltip) | object(可选) | - |
65+
| style | 视觉样式,配置项详见[绘图属性](/options/plots/style#绘图属性) | object(可选) | - |
66+
| theme | 用于控制图表的整体外观,包括颜色、字体、边距等视觉属性,详见[主题](/options/plots/theme/overview) | string \| object(可选) | `light` |
67+
| onReady | 图表加载回调,用于后续的事件[事件](/options/plots/event)绑定 | Function(可选) | - |
68+
| scale | 将抽象数据映射为视觉数据,详见[比例尺](/options/plots/scale/overview) | object(可选) | - |
69+
| animate | 动画作为可视化的重要组成部分,能显著提高数据可视化的表现力,详见[动画](/options/plots/animate/overview) | object(可选) | - |
70+
| interaction | 提供了按需探索数据的能力,详见[交互](/options/plots/interaction/overview) | object(可选) | - |
71+
| state | 实现交互反馈、高亮、选中等效果,详见[状态](/options/plots/state),不同交互下图表样式 | object(可选) | - |
72+
| annotations | 视图好比一个画板,`RadailBar` 组件默认在其上绘制了一个玉珏图,我们可以通过 annotations 在上面叠加更多的图层,详见[标注](/examples#statistics-annotation-shape) | Array(可选) | - |
73+
74+
### MarkBackground
3375

3476
```ts
35-
{
36-
scale: {
37-
y: {
38-
domain: [0, 200]
39-
}
40-
},
41-
/** 不配置任何参数,默认开启背景颜色 '#e0e4ee' */
42-
// markBackground:{}
43-
markBackground: {
44-
color: 'color'; // 指定color的参数,即根据color字段进行颜色映射
45-
},
46-
}
77+
type MarkBackground = {
78+
/** background 样式 */
79+
style?: ShapeAttrs;
80+
[key: string]: any
81+
};
4782
```
4883

49-
示例:
84+
style 配置可以参考[配置图形样式](/options/plots/style#配置图形样式)
85+
86+
## 事件
87+
88+
详见[选项-事件](/options/plots/event)
89+
90+
## 方法
5091

51-
<img src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*4IsBSoYrLL4AAAAAAAAAAAAADmJ7AQ/original" />
92+
详见[图表概览-图表方法](/components/plots/overview#图表方法)

site/examples/statistics/radial-bar/demo/apple-watch-activity.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const DemoRadialBar = () => {
3232
height: 244,
3333
autoFit: false,
3434
appendPadding: [50, 0, 50, 0],
35-
// maxAngle: 90, //最大旋转角度,
3635
radius: 1,
3736
innerRadius: 0.2,
3837
style: {

site/examples/statistics/radial-bar/demo/background.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const DemoRadialBar = () => {
1818
data,
1919
xField: 'name',
2020
yField: 'star',
21-
maxAngle: 350,
2221
radius: 1,
2322
innerRadius: 0.2,
2423
tooltip: {

site/examples/statistics/radial-bar/demo/basic.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const DemoRadialBar = () => {
1818
data,
1919
xField: 'name',
2020
yField: 'star',
21-
// maxAngle: 90, //最大旋转角度,
2221
radius: 1,
2322
innerRadius: 0.2,
2423
tooltip: {

0 commit comments

Comments
 (0)