Skip to content

Commit 25c1c2a

Browse files
author
aiyin.lzy
committed
feat: 去除 treemap seriesfield 属性
1 parent 9e8c1ec commit 25c1c2a

File tree

16 files changed

+20
-26
lines changed

16 files changed

+20
-26
lines changed

__tests__/unit/plots/treemap/basic-spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ describe('treemap', () => {
5555
const treemapPlot = new Treemap(createDiv(), {
5656
data,
5757
colorField: 'name',
58-
seriesField: 'value',
5958
color,
6059
});
6160

__tests__/unit/plots/treemap/treemap-nest-spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ describe('treemap', () => {
2222
const treemapPlot = new Treemap(createDiv(), {
2323
data: TREEMAP_CHILDREN,
2424
colorField: 'brand',
25-
seriesField: 'value',
2625
color,
2726
label: {
2827
fields: ['name'],

docs/api/plots/treemap.en.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,20 @@ const data = {
2626

2727
```
2828

29+
其中,每一层级的数据都需要具备三个属性
30+
31+
- name
32+
- value (叶子节点)
33+
- children (非叶子节点)
34+
35+
2936
#### colorField
3037

3138
<description>**optional** _string_</description>
3239

3340
颜色映射字段名。
3441

3542

36-
#### seriesField
37-
38-
<description>**optional** _string_</description>
39-
40-
分组字段,即要映射的数值字段。
4143

4244

4345

docs/api/plots/treemap.zh.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,17 @@ const data = {
2626

2727
```
2828

29-
#### colorField
30-
31-
<description>**optional** _string_</description>
29+
其中,每一层级的数据都需要具备三个属性
3230

33-
颜色映射字段名。
31+
- name
32+
- value (叶子节点)
33+
- children (非叶子节点)
3434

35-
36-
#### seriesField
35+
#### colorField
3736

3837
<description>**optional** _string_</description>
3938

40-
分组字段,即要映射的数值字段
39+
颜色映射字段名
4140

4241

4342

examples/treemap/basic/demo/basic.ts renamed to examples/more-plots/treemap/demo/basic.ts

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const data = {
2929
const treemapPlot = new Treemap('container', {
3030
data,
3131
colorField: 'name',
32-
seriesField: 'value',
3332
});
3433

3534
treemapPlot.render();

examples/treemap/basic/demo/treemap-nest.ts renamed to examples/more-plots/treemap/demo/treemap-nest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ fetch('https://gw.alipayobjects.com/os/basement_prod/be471bfc-b37f-407e-833b-0f4
1919
const treemapPlot = new Treemap('container', {
2020
data: mobileData,
2121
colorField: 'brand',
22-
seriesField: 'value',
2322
});
2423
treemapPlot.render();
2524
});

src/plots/treemap/adaptor.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ import { TreemapOptions } from './types';
1111
*/
1212
function defaultOptions(params: Params<TreemapOptions>): Params<TreemapOptions> {
1313
const { options } = params;
14-
const { colorField, seriesField } = options;
14+
const { colorField } = options;
1515

1616
return deepAssign(
1717
{
1818
options: {
19-
seriesField: 'value',
2019
label: {
21-
fields: [colorField],
20+
fields: ['name'],
2221
layout: {
2322
type: 'limit-in-shape',
2423
},
@@ -28,11 +27,11 @@ function defaultOptions(params: Params<TreemapOptions>): Params<TreemapOptions>
2827
showMarkers: false,
2928
offset: 20,
3029
showTitle: false,
31-
fields: [colorField, seriesField],
30+
fields: ['name', 'value', colorField],
3231
formatter: (data) => {
3332
return {
34-
name: data[colorField],
35-
value: data[seriesField],
33+
name: data.name,
34+
value: data.value,
3635
};
3736
},
3837
},

src/plots/treemap/types.ts

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@ import { Options } from '../../types';
33
export interface TreemapOptions extends Omit<Options, 'data'> {
44
/** 颜色字段 */
55
readonly colorField?: string;
6-
/** 分组字段默认为 **/
7-
readonly seriesField?: string;
86
readonly data?: Record<string, any>;
97
}

src/plots/treemap/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { treemap } from '../../utils/hierarchy/treemap';
22
import { TreemapOptions } from './types';
33

44
export function transformData(options: TreemapOptions) {
5-
const { data, seriesField, colorField } = options;
5+
const { data, colorField } = options;
66

77
const nodes = treemap(data, {
88
// @ts-ignore
99
type: 'hierarchy.treemap',
1010
tile: 'treemapResquarify',
11-
field: seriesField,
11+
field: 'value',
1212
as: ['x', 'y'],
1313
});
1414

0 commit comments

Comments
 (0)