@gm-pc/vision 1.25.0-beta.0 → 1.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/chart/bar/components/table_chart.tsx +106 -106
- package/src/chart/bar/core/config.ts +257 -257
- package/src/chart/bar/core/index.ts +9 -9
- package/src/chart/bar/core/utils.ts +8 -8
- package/src/chart/bar/index.less +132 -132
- package/src/chart/bar/index.tsx +18 -18
- package/src/chart/bar/stories.tsx +420 -420
- package/src/chart/base/index.ts +135 -135
- package/src/chart/line/core/config.ts +209 -209
- package/src/chart/line/core/index.ts +9 -9
- package/src/chart/line/core/utils.ts +49 -49
- package/src/chart/line/index.tsx +12 -12
- package/src/chart/line/stories.tsx +234 -234
- package/src/chart/pie/core/config.ts +199 -199
- package/src/chart/pie/core/index.ts +9 -9
- package/src/chart/pie/index.tsx +12 -12
- package/src/chart/pie/stories.tsx +39 -39
- package/src/common/hooks/useChart.ts +40 -40
- package/src/common/utils/dom.ts +22 -22
- package/src/index.ts +11 -11
- package/src/theme/index.ts +8 -8
- package/src/theme/ocean/chart.ts +40 -40
- package/src/theme/ocean/index.ts +495 -495
- package/src/theme/sunset/chart.ts +40 -40
- package/src/theme/sunset/index.ts +495 -495
- package/src/theme/utils/create-style-by-sheet.ts +1303 -1303
- package/src/types/common.ts +41 -41
- package/src/types/theme.ts +552 -552
- package/tsconfig.json +3 -3
|
@@ -1,257 +1,257 @@
|
|
|
1
|
-
import _ from 'lodash'
|
|
2
|
-
import { Instance } from '../../../types/common'
|
|
3
|
-
import themes from '../../../theme'
|
|
4
|
-
import { getMaxFieldStringLength } from './utils'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* - 几何标记 Geometry
|
|
8
|
-
* - 度量 Scale
|
|
9
|
-
* - 坐标系 Coordinate
|
|
10
|
-
* - 可视化组件 Component
|
|
11
|
-
* - 包括坐标轴 Axis,
|
|
12
|
-
* - 图例 Legend,
|
|
13
|
-
* - 提示信息 Tooltip,
|
|
14
|
-
* - 图形标记 Annotation,
|
|
15
|
-
* - 滑动条 Slider 等。
|
|
16
|
-
*
|
|
17
|
-
* - 交互 interaction
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
function coordinate(params: Instance) {
|
|
21
|
-
const { chart, options } = params
|
|
22
|
-
const { coordinate } = options
|
|
23
|
-
if (coordinate) {
|
|
24
|
-
// 只做了x,y置换
|
|
25
|
-
if (coordinate.actions) {
|
|
26
|
-
chart.coordinate().transpose()
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return params
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function geometry(params: Instance) {
|
|
33
|
-
const { chart, options } = params
|
|
34
|
-
let { position, color, adjust, data } = options
|
|
35
|
-
const [x, y, type] = position.split('*') // type只有adjust为facet才会有
|
|
36
|
-
const paddingStep = getMaxFieldStringLength(x, data)
|
|
37
|
-
const geometry = chart.interval().position(position)
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 柱状图类型
|
|
41
|
-
* 1. stack 分层(g2原有)
|
|
42
|
-
* 2. dodge 分组(g2原有)
|
|
43
|
-
* 3. rank 排名
|
|
44
|
-
* 4. table
|
|
45
|
-
* 5. facet
|
|
46
|
-
*/
|
|
47
|
-
if (adjust) {
|
|
48
|
-
color = color || ''
|
|
49
|
-
const geometryColor = geometry.color(color)
|
|
50
|
-
switch (adjust) {
|
|
51
|
-
case 'dodge':
|
|
52
|
-
geometryColor.adjust({
|
|
53
|
-
type: adjust,
|
|
54
|
-
marginRatio: 0,
|
|
55
|
-
})
|
|
56
|
-
break
|
|
57
|
-
case 'rank':
|
|
58
|
-
geometry.label(y, {
|
|
59
|
-
position: 'left',
|
|
60
|
-
style: {
|
|
61
|
-
fill: '#fff',
|
|
62
|
-
},
|
|
63
|
-
offset: 10,
|
|
64
|
-
})
|
|
65
|
-
chart.axis(x, {
|
|
66
|
-
tickLine: null,
|
|
67
|
-
line: null,
|
|
68
|
-
})
|
|
69
|
-
chart.axis(y, {
|
|
70
|
-
label: null,
|
|
71
|
-
grid: null,
|
|
72
|
-
})
|
|
73
|
-
chart.coordinate().transpose()
|
|
74
|
-
break
|
|
75
|
-
case 'table':
|
|
76
|
-
// table时边距特殊处理
|
|
77
|
-
chart.appendPadding = 0
|
|
78
|
-
chart.axis(x, false)
|
|
79
|
-
chart.axis(y, false)
|
|
80
|
-
chart
|
|
81
|
-
.coordinate()
|
|
82
|
-
.transpose()
|
|
83
|
-
.reflect(y as 'y')
|
|
84
|
-
break
|
|
85
|
-
case 'facet':
|
|
86
|
-
// 分面创建多个图表,前面的配置不适用,清除掉
|
|
87
|
-
chart.clear()
|
|
88
|
-
chart.axis(x, {
|
|
89
|
-
tickLine: null,
|
|
90
|
-
line: null,
|
|
91
|
-
grid: null,
|
|
92
|
-
label: {
|
|
93
|
-
autoEllipsis: true,
|
|
94
|
-
},
|
|
95
|
-
})
|
|
96
|
-
chart.axis(y, false)
|
|
97
|
-
chart.axis(type, false)
|
|
98
|
-
chart.facet('mirror', {
|
|
99
|
-
fields: [type],
|
|
100
|
-
transpose: true,
|
|
101
|
-
showTitle: false,
|
|
102
|
-
padding: [0, paddingStep * 15, 0, 0],
|
|
103
|
-
eachView(view) {
|
|
104
|
-
view
|
|
105
|
-
.interval()
|
|
106
|
-
.position(x + '*' + y)
|
|
107
|
-
.color(type)
|
|
108
|
-
.label(y, {
|
|
109
|
-
position: 'right',
|
|
110
|
-
})
|
|
111
|
-
},
|
|
112
|
-
})
|
|
113
|
-
break
|
|
114
|
-
default:
|
|
115
|
-
geometryColor.adjust(adjust)
|
|
116
|
-
break
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return { ...params, geometry }
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function scale(params: Instance) {
|
|
124
|
-
const { chart, options } = params
|
|
125
|
-
// position = x*y
|
|
126
|
-
const { position, adjust, scale } = options
|
|
127
|
-
const [x, y, type] = position.split('*')
|
|
128
|
-
// TODO 通用配置 y轴nice: true
|
|
129
|
-
chart.scale({
|
|
130
|
-
y: {
|
|
131
|
-
nice: true,
|
|
132
|
-
},
|
|
133
|
-
...scale,
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
switch (adjust) {
|
|
137
|
-
case 'facet':
|
|
138
|
-
chart.scale({
|
|
139
|
-
[type]: {
|
|
140
|
-
sync: true,
|
|
141
|
-
},
|
|
142
|
-
[x]: {
|
|
143
|
-
sync: true,
|
|
144
|
-
},
|
|
145
|
-
})
|
|
146
|
-
break
|
|
147
|
-
|
|
148
|
-
default:
|
|
149
|
-
break
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return params
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function annotation(params: Instance) {
|
|
156
|
-
return params
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function tooltip(params: Instance) {
|
|
160
|
-
const { chart } = params
|
|
161
|
-
chart.tooltip({
|
|
162
|
-
showMarkers: false,
|
|
163
|
-
shared: true,
|
|
164
|
-
domStyles: {
|
|
165
|
-
'g2-tooltip-marker': {
|
|
166
|
-
width: '10px',
|
|
167
|
-
height: '10px',
|
|
168
|
-
borderRadius: '0%',
|
|
169
|
-
display: 'inline-block',
|
|
170
|
-
marginRight: '6px',
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
return params
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function interaction(params: Instance) {
|
|
179
|
-
const { chart, options } = params
|
|
180
|
-
const { color } = options
|
|
181
|
-
if (color) {
|
|
182
|
-
chart.interaction('element-highlight-by-x')
|
|
183
|
-
} else {
|
|
184
|
-
chart.interaction('element-active')
|
|
185
|
-
}
|
|
186
|
-
return params
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function theme(params: Instance) {
|
|
190
|
-
const { chart, options, geometry } = params
|
|
191
|
-
const { theme, position, coordinate, adjust } = options
|
|
192
|
-
if (theme) {
|
|
193
|
-
const themeConfig = themes[theme as 'ocean'].chart
|
|
194
|
-
|
|
195
|
-
if (themeConfig) {
|
|
196
|
-
const [x, y] = position.split('*')
|
|
197
|
-
let fill = themeConfig.bar.style.default.fill
|
|
198
|
-
|
|
199
|
-
// -------------- 颜色配置 ---------------
|
|
200
|
-
if (adjust !== 'stack' && adjust !== 'dodge') {
|
|
201
|
-
if (
|
|
202
|
-
coordinate?.actions === 'transpose' ||
|
|
203
|
-
adjust === 'rank' ||
|
|
204
|
-
adjust === 'table'
|
|
205
|
-
)
|
|
206
|
-
fill = themeConfig.bar.style.transpose.fill
|
|
207
|
-
geometry!.style({
|
|
208
|
-
fill,
|
|
209
|
-
})
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// ---------- tiptop配置 ----------------
|
|
213
|
-
if (!adjust || adjust === 'rank' || adjust === 'table') {
|
|
214
|
-
chart.tooltip({
|
|
215
|
-
showMarkers: false,
|
|
216
|
-
shared: true,
|
|
217
|
-
domStyles: {
|
|
218
|
-
'g2-tooltip-marker': {
|
|
219
|
-
display: 'none',
|
|
220
|
-
},
|
|
221
|
-
},
|
|
222
|
-
})
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
// ---------- 坐标轴配置 ----------------
|
|
226
|
-
if (adjust !== 'table') {
|
|
227
|
-
chart.axis(y, {
|
|
228
|
-
label: {
|
|
229
|
-
style: {
|
|
230
|
-
fill: themeConfig.bar.axis.label.fill,
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
})
|
|
234
|
-
chart.axis(x, {
|
|
235
|
-
label: {
|
|
236
|
-
style: {
|
|
237
|
-
fill: themeConfig.bar.axis.label.fill,
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
})
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return params
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
export function processor(params: Instance) {
|
|
248
|
-
return _.flow(
|
|
249
|
-
geometry,
|
|
250
|
-
coordinate,
|
|
251
|
-
interaction,
|
|
252
|
-
annotation,
|
|
253
|
-
tooltip,
|
|
254
|
-
scale,
|
|
255
|
-
theme
|
|
256
|
-
)(params)
|
|
257
|
-
}
|
|
1
|
+
import _ from 'lodash'
|
|
2
|
+
import { Instance } from '../../../types/common'
|
|
3
|
+
import themes from '../../../theme'
|
|
4
|
+
import { getMaxFieldStringLength } from './utils'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* - 几何标记 Geometry
|
|
8
|
+
* - 度量 Scale
|
|
9
|
+
* - 坐标系 Coordinate
|
|
10
|
+
* - 可视化组件 Component
|
|
11
|
+
* - 包括坐标轴 Axis,
|
|
12
|
+
* - 图例 Legend,
|
|
13
|
+
* - 提示信息 Tooltip,
|
|
14
|
+
* - 图形标记 Annotation,
|
|
15
|
+
* - 滑动条 Slider 等。
|
|
16
|
+
*
|
|
17
|
+
* - 交互 interaction
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function coordinate(params: Instance) {
|
|
21
|
+
const { chart, options } = params
|
|
22
|
+
const { coordinate } = options
|
|
23
|
+
if (coordinate) {
|
|
24
|
+
// 只做了x,y置换
|
|
25
|
+
if (coordinate.actions) {
|
|
26
|
+
chart.coordinate().transpose()
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return params
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function geometry(params: Instance) {
|
|
33
|
+
const { chart, options } = params
|
|
34
|
+
let { position, color, adjust, data } = options
|
|
35
|
+
const [x, y, type] = position.split('*') // type只有adjust为facet才会有
|
|
36
|
+
const paddingStep = getMaxFieldStringLength(x, data)
|
|
37
|
+
const geometry = chart.interval().position(position)
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 柱状图类型
|
|
41
|
+
* 1. stack 分层(g2原有)
|
|
42
|
+
* 2. dodge 分组(g2原有)
|
|
43
|
+
* 3. rank 排名
|
|
44
|
+
* 4. table
|
|
45
|
+
* 5. facet
|
|
46
|
+
*/
|
|
47
|
+
if (adjust) {
|
|
48
|
+
color = color || ''
|
|
49
|
+
const geometryColor = geometry.color(color)
|
|
50
|
+
switch (adjust) {
|
|
51
|
+
case 'dodge':
|
|
52
|
+
geometryColor.adjust({
|
|
53
|
+
type: adjust,
|
|
54
|
+
marginRatio: 0,
|
|
55
|
+
})
|
|
56
|
+
break
|
|
57
|
+
case 'rank':
|
|
58
|
+
geometry.label(y, {
|
|
59
|
+
position: 'left',
|
|
60
|
+
style: {
|
|
61
|
+
fill: '#fff',
|
|
62
|
+
},
|
|
63
|
+
offset: 10,
|
|
64
|
+
})
|
|
65
|
+
chart.axis(x, {
|
|
66
|
+
tickLine: null,
|
|
67
|
+
line: null,
|
|
68
|
+
})
|
|
69
|
+
chart.axis(y, {
|
|
70
|
+
label: null,
|
|
71
|
+
grid: null,
|
|
72
|
+
})
|
|
73
|
+
chart.coordinate().transpose()
|
|
74
|
+
break
|
|
75
|
+
case 'table':
|
|
76
|
+
// table时边距特殊处理
|
|
77
|
+
chart.appendPadding = 0
|
|
78
|
+
chart.axis(x, false)
|
|
79
|
+
chart.axis(y, false)
|
|
80
|
+
chart
|
|
81
|
+
.coordinate()
|
|
82
|
+
.transpose()
|
|
83
|
+
.reflect(y as 'y')
|
|
84
|
+
break
|
|
85
|
+
case 'facet':
|
|
86
|
+
// 分面创建多个图表,前面的配置不适用,清除掉
|
|
87
|
+
chart.clear()
|
|
88
|
+
chart.axis(x, {
|
|
89
|
+
tickLine: null,
|
|
90
|
+
line: null,
|
|
91
|
+
grid: null,
|
|
92
|
+
label: {
|
|
93
|
+
autoEllipsis: true,
|
|
94
|
+
},
|
|
95
|
+
})
|
|
96
|
+
chart.axis(y, false)
|
|
97
|
+
chart.axis(type, false)
|
|
98
|
+
chart.facet('mirror', {
|
|
99
|
+
fields: [type],
|
|
100
|
+
transpose: true,
|
|
101
|
+
showTitle: false,
|
|
102
|
+
padding: [0, paddingStep * 15, 0, 0],
|
|
103
|
+
eachView(view) {
|
|
104
|
+
view
|
|
105
|
+
.interval()
|
|
106
|
+
.position(x + '*' + y)
|
|
107
|
+
.color(type)
|
|
108
|
+
.label(y, {
|
|
109
|
+
position: 'right',
|
|
110
|
+
})
|
|
111
|
+
},
|
|
112
|
+
})
|
|
113
|
+
break
|
|
114
|
+
default:
|
|
115
|
+
geometryColor.adjust(adjust)
|
|
116
|
+
break
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return { ...params, geometry }
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function scale(params: Instance) {
|
|
124
|
+
const { chart, options } = params
|
|
125
|
+
// position = x*y
|
|
126
|
+
const { position, adjust, scale } = options
|
|
127
|
+
const [x, y, type] = position.split('*')
|
|
128
|
+
// TODO 通用配置 y轴nice: true
|
|
129
|
+
chart.scale({
|
|
130
|
+
y: {
|
|
131
|
+
nice: true,
|
|
132
|
+
},
|
|
133
|
+
...scale,
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
switch (adjust) {
|
|
137
|
+
case 'facet':
|
|
138
|
+
chart.scale({
|
|
139
|
+
[type]: {
|
|
140
|
+
sync: true,
|
|
141
|
+
},
|
|
142
|
+
[x]: {
|
|
143
|
+
sync: true,
|
|
144
|
+
},
|
|
145
|
+
})
|
|
146
|
+
break
|
|
147
|
+
|
|
148
|
+
default:
|
|
149
|
+
break
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return params
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function annotation(params: Instance) {
|
|
156
|
+
return params
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function tooltip(params: Instance) {
|
|
160
|
+
const { chart } = params
|
|
161
|
+
chart.tooltip({
|
|
162
|
+
showMarkers: false,
|
|
163
|
+
shared: true,
|
|
164
|
+
domStyles: {
|
|
165
|
+
'g2-tooltip-marker': {
|
|
166
|
+
width: '10px',
|
|
167
|
+
height: '10px',
|
|
168
|
+
borderRadius: '0%',
|
|
169
|
+
display: 'inline-block',
|
|
170
|
+
marginRight: '6px',
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
return params
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function interaction(params: Instance) {
|
|
179
|
+
const { chart, options } = params
|
|
180
|
+
const { color } = options
|
|
181
|
+
if (color) {
|
|
182
|
+
chart.interaction('element-highlight-by-x')
|
|
183
|
+
} else {
|
|
184
|
+
chart.interaction('element-active')
|
|
185
|
+
}
|
|
186
|
+
return params
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function theme(params: Instance) {
|
|
190
|
+
const { chart, options, geometry } = params
|
|
191
|
+
const { theme, position, coordinate, adjust } = options
|
|
192
|
+
if (theme) {
|
|
193
|
+
const themeConfig = themes[theme as 'ocean'].chart
|
|
194
|
+
|
|
195
|
+
if (themeConfig) {
|
|
196
|
+
const [x, y] = position.split('*')
|
|
197
|
+
let fill = themeConfig.bar.style.default.fill
|
|
198
|
+
|
|
199
|
+
// -------------- 颜色配置 ---------------
|
|
200
|
+
if (adjust !== 'stack' && adjust !== 'dodge') {
|
|
201
|
+
if (
|
|
202
|
+
coordinate?.actions === 'transpose' ||
|
|
203
|
+
adjust === 'rank' ||
|
|
204
|
+
adjust === 'table'
|
|
205
|
+
)
|
|
206
|
+
fill = themeConfig.bar.style.transpose.fill
|
|
207
|
+
geometry!.style({
|
|
208
|
+
fill,
|
|
209
|
+
})
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// ---------- tiptop配置 ----------------
|
|
213
|
+
if (!adjust || adjust === 'rank' || adjust === 'table') {
|
|
214
|
+
chart.tooltip({
|
|
215
|
+
showMarkers: false,
|
|
216
|
+
shared: true,
|
|
217
|
+
domStyles: {
|
|
218
|
+
'g2-tooltip-marker': {
|
|
219
|
+
display: 'none',
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
})
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// ---------- 坐标轴配置 ----------------
|
|
226
|
+
if (adjust !== 'table') {
|
|
227
|
+
chart.axis(y, {
|
|
228
|
+
label: {
|
|
229
|
+
style: {
|
|
230
|
+
fill: themeConfig.bar.axis.label.fill,
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
})
|
|
234
|
+
chart.axis(x, {
|
|
235
|
+
label: {
|
|
236
|
+
style: {
|
|
237
|
+
fill: themeConfig.bar.axis.label.fill,
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
})
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return params
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export function processor(params: Instance) {
|
|
248
|
+
return _.flow(
|
|
249
|
+
geometry,
|
|
250
|
+
coordinate,
|
|
251
|
+
interaction,
|
|
252
|
+
annotation,
|
|
253
|
+
tooltip,
|
|
254
|
+
scale,
|
|
255
|
+
theme
|
|
256
|
+
)(params)
|
|
257
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Base } from '../../base/index'
|
|
2
|
-
import { processor } from './config'
|
|
3
|
-
|
|
4
|
-
export default class Bar extends Base {
|
|
5
|
-
name = 'bar'
|
|
6
|
-
getProcessor() {
|
|
7
|
-
return processor
|
|
8
|
-
}
|
|
9
|
-
}
|
|
1
|
+
import { Base } from '../../base/index'
|
|
2
|
+
import { processor } from './config'
|
|
3
|
+
|
|
4
|
+
export default class Bar extends Base {
|
|
5
|
+
name = 'bar'
|
|
6
|
+
getProcessor() {
|
|
7
|
+
return processor
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export function getMaxFieldStringLength(field: string, data: any[]) {
|
|
2
|
-
let maxLength = 0
|
|
3
|
-
data.forEach((d) => {
|
|
4
|
-
const strLen = d[field].length
|
|
5
|
-
maxLength = Math.max(strLen, maxLength)
|
|
6
|
-
})
|
|
7
|
-
return maxLength
|
|
8
|
-
}
|
|
1
|
+
export function getMaxFieldStringLength(field: string, data: any[]) {
|
|
2
|
+
let maxLength = 0
|
|
3
|
+
data.forEach((d) => {
|
|
4
|
+
const strLen = d[field].length
|
|
5
|
+
maxLength = Math.max(strLen, maxLength)
|
|
6
|
+
})
|
|
7
|
+
return maxLength
|
|
8
|
+
}
|