lambo-design-bi 0.0.237 → 0.0.239
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.
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<script>
|
|
7
7
|
import { getListMapData } from "../api/data"
|
|
8
8
|
import LamboChartsFactory from "../../../pub/charts/factory/charts-factory.vue"
|
|
9
|
-
import { convertChartsData } from "./util/charts-data-util"
|
|
9
|
+
import { convertChartsData, convertChartsDataType42 } from "./util/charts-data-util"
|
|
10
10
|
import { EventBus, EVENT_TYPES } from '../util/event-bus'
|
|
11
11
|
|
|
12
12
|
export default {
|
|
@@ -81,8 +81,13 @@ export default {
|
|
|
81
81
|
if (res.data.data.rows.length > 0) {
|
|
82
82
|
let rows = res.data.data.rows
|
|
83
83
|
if (rows && this.columns) {
|
|
84
|
-
let resObj =
|
|
85
|
-
|
|
84
|
+
let resObj = {}
|
|
85
|
+
if (this.chartsType === '42') {
|
|
86
|
+
resObj = convertChartsDataType42(rows, this.columns)
|
|
87
|
+
} else {
|
|
88
|
+
resObj = convertChartsData(rows, this.columns)
|
|
89
|
+
}
|
|
90
|
+
console.log( "chartsType:", this.chartsType, "resObj:", resObj)
|
|
86
91
|
if (resObj) {
|
|
87
92
|
this.dataX = resObj.dataX
|
|
88
93
|
this.dataY = resObj.dataY
|
|
@@ -112,7 +117,7 @@ export default {
|
|
|
112
117
|
let rows = res.data.data.rows
|
|
113
118
|
if (rows && rows.length > 0) {
|
|
114
119
|
let rowData = rows[0]
|
|
115
|
-
if(rowData && Object.prototype.hasOwnProperty.call(rowData, "val")){
|
|
120
|
+
if (rowData && Object.prototype.hasOwnProperty.call(rowData, "val")) {
|
|
116
121
|
this.chartsNote = rowData["val"] || ''
|
|
117
122
|
}
|
|
118
123
|
}
|
|
@@ -156,3 +156,114 @@ export function convertChartsData(rows, columns) {
|
|
|
156
156
|
return { dataX, dataY, dataDim }
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
/**
|
|
160
|
+
* 桑基图类型的charts的数据rows,根据columns的配置转换输出 { dataX, dataY, dataZ, dataDim }
|
|
161
|
+
*
|
|
162
|
+
* @param {*} rows
|
|
163
|
+
* @param {*} columns
|
|
164
|
+
* 示例输入:"rows": [
|
|
165
|
+
{
|
|
166
|
+
"source_node": "电",
|
|
167
|
+
"target_node": "业务环节",
|
|
168
|
+
"index_val": 9
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"source_node": "油",
|
|
172
|
+
"target_node": "业务环节",
|
|
173
|
+
"index_val": 8
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"source_node": "电",
|
|
177
|
+
"target_node": "高架库区",
|
|
178
|
+
"index_val": 5
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"source_node": "业务环节",
|
|
182
|
+
"target_node": "高架库区",
|
|
183
|
+
"index_val": 1
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"source_node": "电",
|
|
187
|
+
"target_node": "分拣区",
|
|
188
|
+
"index_val": 3
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"source_node": "油",
|
|
192
|
+
"target_node": "分拣区",
|
|
193
|
+
"index_val": 3
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"source_node": "业务环节",
|
|
197
|
+
"target_node": "发货区",
|
|
198
|
+
"index_val": 2
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
* 示例输入:"columns": '{"x_key":"source_node", "y_key":"target_node", "z_key":"index_val", "data_col":"z", "height":"400px"}'
|
|
202
|
+
* 示例输出:{
|
|
203
|
+
* dataX: ['业务环节', '高架库区', '电', '油', '分拣区', '发货区',],
|
|
204
|
+
dataY: [['电', '业务环节', 9], ['油', '业务环节', 8], ['电', '高架库区', 5], ['业务环节', '高架库区', 1],['电', '分拣区', 3], ['油', '分拣区', 3], ['业务环节', '发货区', 2]],
|
|
205
|
+
dataZ: [],
|
|
206
|
+
dataDim: []
|
|
207
|
+
}
|
|
208
|
+
*
|
|
209
|
+
*/
|
|
210
|
+
export function convertChartsDataType42(rows, columns) {
|
|
211
|
+
if (!rows || !columns) {
|
|
212
|
+
console.error(`convertChartsDataType42 rows:${rows},或者columns:${columns}为无效值`)
|
|
213
|
+
return null
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
let xKey = null
|
|
217
|
+
let yKey = null
|
|
218
|
+
let zKey = null
|
|
219
|
+
let dataCol = null
|
|
220
|
+
|
|
221
|
+
if (Object.prototype.hasOwnProperty.call(columns, "x_key")) {
|
|
222
|
+
xKey = columns["x_key"]
|
|
223
|
+
}
|
|
224
|
+
if (Object.prototype.hasOwnProperty.call(columns, "y_key")) {
|
|
225
|
+
yKey = columns["y_key"]
|
|
226
|
+
}
|
|
227
|
+
if (Object.prototype.hasOwnProperty.call(columns, "z_key")) {
|
|
228
|
+
zKey = columns["z_key"]
|
|
229
|
+
}
|
|
230
|
+
if (Object.prototype.hasOwnProperty.call(columns, "data_col")) {
|
|
231
|
+
dataCol = columns["data_col"]
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (!xKey || !yKey || !zKey || dataCol !== 'z') {
|
|
235
|
+
console.error("convertChartsDataType42 columns的xKey,或者yKey,或者zKey,或者dataCol为无效值:", columns)
|
|
236
|
+
return null
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
let dataX = []
|
|
240
|
+
let dataY = []
|
|
241
|
+
let dataZ = []
|
|
242
|
+
let dataDim = []
|
|
243
|
+
let sourceArr = []
|
|
244
|
+
let targetArr = []
|
|
245
|
+
|
|
246
|
+
rows.forEach(rowData => {
|
|
247
|
+
if (!rowData || !Object.prototype.hasOwnProperty.call(rowData, xKey)
|
|
248
|
+
|| !Object.prototype.hasOwnProperty.call(rowData, yKey)
|
|
249
|
+
|| !Object.prototype.hasOwnProperty.call(rowData, zKey)) {
|
|
250
|
+
return
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const source = rowData[xKey]
|
|
254
|
+
const target = rowData[yKey]
|
|
255
|
+
const value = Number(rowData[zKey])
|
|
256
|
+
if (source === null || source === undefined || target === null || target === undefined || isNaN(value)) {
|
|
257
|
+
return
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
sourceArr.push(source)
|
|
261
|
+
targetArr.push(target)
|
|
262
|
+
dataY.push([source, target, value])
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
dataX = [...new Set(sourceArr.concat(targetArr))]
|
|
266
|
+
return { dataX, dataY, dataZ, dataDim }
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
|