1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
| import zhCN from '@/locales/zh-CN/model.js'
| import enUS from '@/locales/en-US/model.js'
|
| const Formdict = localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
|
| /**
| * @description 获取图表视图配置表单
| * @param {object} card // 图表对象
| * @param {Array} columns // 显示列
| */
| export function getBarOrLineChartOptionForm (card, columns, sysRoles = [], MenuType) {
| let shapes = []
| let _sysRoles = sysRoles.map(item => ({...item, field: item.value, label: item.text}))
|
| if (card.chartType === 'line') {
| shapes = [
| { field: 'smooth', label: 'smooth' },
| { field: 'line', label: 'line' },
| { field: 'dot', label: 'dot' },
| { field: 'dash', label: 'dash' },
| { field: 'hv', label: 'hv' },
| { field: 'vh', label: 'vh' },
| { field: 'hvh', label: 'hvh' },
| { field: 'vhv', label: 'vhv' }
| ]
| } else if (card.chartType === 'bar') {
| shapes = [
| { field: 'rect', label: 'rect' },
| { field: 'hollow-rect', label: 'hollow-rect' },
| { field: 'line', label: 'line' },
| { field: 'tick', label: 'tick' },
| { field: 'funnel', label: 'funnel' },
| { field: 'pyramid', label: 'pyramid' }
| ]
| }
|
| let xfields = columns.filter(item => /^Nvarchar/ig.test(item.datatype))
| let yfields = columns.filter(item => /^(Int|Decimal)/ig.test(item.datatype))
|
| return [
| {
| type: 'text',
| key: 'title',
| label: '标题',
| initVal: card.title,
| required: false
| },
| {
| type: 'text',
| key: 'name',
| label: '组件名称',
| initVal: card.name,
| tooltip: '用于组件间的区分。',
| required: true
| },
| {
| type: 'number',
| key: 'width',
| label: '宽度',
| initVal: card.width,
| tooltip: '栅格布局,每行等分为24列。',
| min: 1,
| max: 24,
| decimal: 0,
| required: true
| },
| {
| type: 'number',
| key: 'height',
| label: '高度',
| initVal: card.height,
| min: 100,
| max: 1000,
| decimal: 0,
| required: true
| },
| {
| type: 'radio',
| key: 'datatype',
| label: '数据类型',
| initVal: card.datatype || 'query',
| tooltip: '统计图表适用于表格不分页,且数据需要转换',
| required: false,
| options: [
| { value: 'query', text: Formdict['header.form.query'] },
| { value: 'statistics', text: Formdict['header.form.statistics'] }
| ]
| },
| {
| type: 'select',
| key: 'Xaxis',
| label: 'X-轴',
| initVal: card.Xaxis || '',
| required: true,
| options: xfields
| },
| {
| type: 'select',
| key: 'InfoType',
| label: '类型',
| initVal: card.InfoType || '',
| hidden: card.datatype !== 'statistics',
| required: true,
| options: xfields
| },
| {
| type: 'select',
| key: 'InfoValue',
| label: '值',
| initVal: card.InfoValue || '',
| hidden: card.datatype !== 'statistics',
| required: true,
| options: yfields
| },
| {
| type: 'select',
| key: 'legend',
| label: '图例位置',
| initVal: card.legend || 'bottom',
| required: false,
| options: [
| { field: 'bottom', label: '下' },
| { field: 'bottom-left', label: '下左' },
| { field: 'bottom-right', label: '下右' },
| { field: 'top', label: '上' },
| { field: 'top-left', label: '上左' },
| { field: 'top-right', label: '上右' },
| { field: 'right', label: '右' },
| { field: 'right-top', label: '右上' },
| { field: 'right-bottom', label: '右下' },
| { field: 'left', label: '左' },
| { field: 'left-top', label: '左上' },
| { field: 'left-bottom', label: '左下' },
| { field: 'hidden', label: '隐藏' }
| ]
| },
| {
| type: 'select',
| key: 'Yaxis',
| label: 'Y-轴',
| initVal: card.Yaxis || [],
| multi: true, // 多选
| hidden: card.datatype === 'statistics',
| required: true,
| options: yfields
| },
| {
| type: 'select',
| key: 'shape',
| label: '形状',
| initVal: card.shape || (shapes[0] && shapes[0].field),
| required: false,
| options: shapes
| },
| {
| type: 'radio',
| key: 'tooltip',
| label: '提示信息',
| initVal: card.tooltip || 'true',
| required: false,
| options: [{
| value: 'true',
| text: '显示'
| }, {
| value: 'false',
| text: '隐藏'
| }]
| },
| {
| type: 'radio',
| key: 'coordinate',
| label: '坐标',
| initVal: card.coordinate || 'angle',
| required: false,
| options: [{
| value: 'angle',
| text: '二维坐标'
| }, {
| value: 'polar',
| text: '极坐标'
| }]
| },
| {
| type: 'radio',
| key: 'point',
| label: '点图',
| initVal: card.point || 'false',
| required: false,
| forbid: !['line'].includes(card.chartType),
| options: [{
| value: 'true',
| text: '显示'
| }, {
| value: 'false',
| text: '隐藏'
| }]
| },
| {
| type: 'radio',
| key: 'transpose',
| label: '变换',
| initVal: card.transpose || 'false',
| required: false,
| options: [{
| value: 'true',
| text: Formdict['model.true']
| }, {
| value: 'false',
| text: Formdict['model.false']
| }]
| },
| {
| type: 'radio',
| key: 'show',
| label: '显示值',
| initVal: card.show || 'value',
| required: false,
| options: [{
| value: 'percent',
| text: '百分比'
| }, {
| value: 'value',
| text: '数值'
| }]
| },
| {
| type: 'radio',
| key: 'label',
| label: '标注-值',
| initVal: card.label || 'false',
| required: false,
| options: [{
| value: 'true',
| text: '显示'
| }, {
| value: 'false',
| text: '隐藏'
| }]
| }, {
| type: 'radio',
| key: 'adjust',
| label: '多柱排列',
| initVal: card.adjust || 'dodge',
| required: false,
| forbid: !['bar'].includes(card.chartType),
| options: [{
| value: 'dodge',
| text: '分组'
| }, {
| value: 'stack',
| text: '堆叠'
| }]
| }, {
| type: 'radio',
| key: 'repeat',
| label: '重复数据',
| initVal: card.repeat || 'unrepeat',
| required: false,
| options: [{
| value: 'unrepeat',
| text: '去重'
| }, {
| value: 'average',
| text: '平均'
| }, {
| value: 'cumsum',
| text: '累加'
| }]
| }, {
| type: 'number',
| key: 'InfoDefNumber',
| label: '展示数',
| tooltip: '默认显示类型数量',
| min: 1,
| max: 50,
| decimal: 0,
| initVal: card.InfoDefNumber || 5,
| hidden: card.datatype !== 'statistics',
| required: true
| }, {
| type: 'number',
| key: 'barSize',
| label: '柱形宽度',
| tooltip: '空值时,宽度自适应。',
| min: 5,
| max: 100,
| decimal: 0,
| initVal: card.barSize,
| forbid: !['bar'].includes(card.chartType),
| required: false
| }, {
| type: 'color',
| key: 'color',
| label: '色系',
| initVal: card.color || 'rgba(0, 0, 0, 0.85)',
| tooltip: '坐标轴及示例等提示文字使用的颜色。',
| required: false,
| options: [{
| value: 'black',
| text: '黑色'
| }, {
| value: 'white',
| text: '白色'
| }]
| }, {
| type: 'select',
| key: 'blacklist',
| label: '黑名单',
| initVal: card.blacklist || [],
| multi: true,
| required: false,
| forbid: MenuType === 'billPrint',
| options: _sysRoles
| }
| ]
| }
|
|