king
2023-12-14 0eb129a9beddbb86ae74d7106a8e60823206b8d5
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
/**
 * @description 获取图表视图配置表单
 * @param {object} card       // 图表对象
 * @param {Array}  columns    // 显示列
 * @param {String} setting    // 页面设置
 */
export function getChartOptionForm (card, columns, setting) {
  let shapes = []
 
  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' }
    ]
  } else if (card.chartType === 'pie') {
    shapes = [
      { field: 'pie', label: '饼图' },
      { field: 'ring', label: '环图' }
    ]
  }
 
  return [
    {
      type: 'radio',
      key: 'datatype',
      label: '数据类型',
      initVal: card.datatype || 'query',
      tooltip: '统计图表适用于表格不分页,且数据需要转换',
      required: false,
      readonly: !(setting.laypage === 'false'),
      forbid: !['line', 'bar'].includes(card.chartType),
      options: [
        { value: 'query', text: '查询' },
        { value: 'statistics', text: '统计' }
      ]
    },
    {
      type: 'select',
      key: 'Xaxis',
      label: card.chartType === 'pie' ? 'Text' : 'X-轴',
      initVal: card.Xaxis || '',
      required: true,
      options: columns.filter(col => col.type === 'text')
    },
    {
      type: 'select',
      key: 'Yaxis',
      label: card.chartType === 'pie' ? 'Value' : 'Y-轴',
      initVal: card.chartType === 'pie' ? card.Yaxis || '' : card.Yaxis || [],
      multi: card.chartType !== 'pie',
      hidden: card.datatype === 'statistics',
      required: true,
      options: columns.filter(col => col.type === 'number')
    },
    {
      type: 'select',
      key: 'InfoType',
      label: '类型',
      initVal: card.InfoType || '',
      forbid: !['line', 'bar'].includes(card.chartType),
      hidden: card.datatype !== 'statistics',
      required: true,
      options: columns.filter(col => col.type === 'text')
    },
    {
      type: 'select',
      key: 'InfoValue',
      label: '值',
      initVal: card.InfoValue || '',
      forbid: !['line', 'bar'].includes(card.chartType),
      hidden: card.datatype !== 'statistics',
      required: true,
      options: columns.filter(col => col.type === 'number')
    },
    {
      type: 'select',
      key: 'legend',
      label: '图例位置',
      initVal: card.legend || 'bottom',
      required: false,
      options: [
        { field: 'top', label: 'top' },
        { field: 'top-left', label: 'top-left' },
        { field: 'top-right', label: 'top-right' },
        { field: 'right', label: 'right' },
        { field: 'right-top', label: 'right-top' },
        { field: 'right-bottom', label: 'right-bottom' },
        { field: 'left', label: 'left' },
        { field: 'left-top', label: 'left-top' },
        { field: 'left-bottom', label: 'left-bottom' },
        { field: 'bottom', label: 'bottom' },
        { field: 'bottom-left', label: 'bottom-left' },
        { field: 'bottom-right', label: 'bottom-right' },
        { field: 'hidden', label: 'hidden' }
      ]
    },
    {
      type: 'select',
      key: 'shape',
      label: '形状',
      initVal: card.shape || (shapes[0] && shapes[0].field),
      required: false,
      forbid: !['line', 'bar', 'pie'].includes(card.chartType),
      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,
      forbid: !['line', 'bar'].includes(card.chartType),
      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,
      forbid: !['line', 'bar'].includes(card.chartType),
      options: [{
        value: 'true',
        text: '是'
      }, {
        value: 'false',
        text: '否'
      }]
    },
    {
      type: 'radio',
      key: 'pieshow',
      label: '显示值',
      initVal: card.pieshow || 'percent',
      required: false,
      forbid: !['pie'].includes(card.chartType),
      options: [{
        value: 'percent',
        text: '百分比'
      }, {
        value: 'value',
        text: '数值'
      }]
    },
    {
      type: 'radio',
      key: 'label',
      label: '标注-值',
      initVal: card.label || (card.chartType === 'pie' ? 'true' : 'false'),
      required: false,
      forbid: !['pie', 'bar', 'line'].includes(card.chartType),
      options: [{
        value: 'true',
        text: '显示'
      }, {
        value: 'false',
        text: '隐藏'
      }]
    }, {
      type: 'radio',
      key: 'labelLayout',
      label: '标签布局',
      initVal: card.labelLayout || 'normal',
      required: false,
      forbid: !['pie'].includes(card.chartType),
      options: [{
        value: 'normal',
        text: '常规'
      }, {
        value: 'overlap',
        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: 'number',
      key: 'InfoDefNumber',
      label: '展示数',
      tooltip: '默认显示类型数量',
      min: 1,
      max: 50,
      decimal: 0,
      initVal: card.InfoDefNumber || 5,
      forbid: !['line', 'bar'].includes(card.chartType),
      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
    }
  ]
}