Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
620ff4af
提交
620ff4af
authored
5月 16, 2022
作者:
junjun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 维度自定义排序
上级
866a840d
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
56 行增加
和
29 行删除
+56
-29
ChartViewService.java
...main/java/io/dataease/service/chart/ChartViewService.java
+48
-22
CustomSortEdit.vue
...end/src/views/chart/components/compare/CustomSortEdit.vue
+2
-1
ChartEdit.vue
frontend/src/views/chart/view/ChartEdit.vue
+6
-6
没有找到文件。
backend/src/main/java/io/dataease/service/chart/ChartViewService.java
浏览文件 @
620ff4af
...
@@ -873,24 +873,7 @@ public class ChartViewService {
...
@@ -873,24 +873,7 @@ public class ChartViewService {
}
}
}
}
// 自定义排序
// 自定义排序
if
(
xAxis
.
size
()
>
0
)
{
data
=
resultCustomSort
(
xAxis
,
data
);
// 找到对应维度
ChartViewFieldDTO
chartViewFieldDTO
=
null
;
int
index
=
0
;
for
(
int
i
=
0
;
i
<
xAxis
.
size
();
i
++)
{
ChartViewFieldDTO
item
=
xAxis
.
get
(
i
);
if
(
StringUtils
.
equalsIgnoreCase
(
item
.
getSort
(),
"custom_sort"
))
{
chartViewFieldDTO
=
item
;
index
=
i
;
break
;
}
}
if
(
ObjectUtils
.
isNotEmpty
(
chartViewFieldDTO
))
{
// 获取自定义值与data对应列的结果
data
=
customSort
(
Optional
.
ofNullable
(
chartViewFieldDTO
.
getCustomSort
()).
orElse
(
new
ArrayList
<>()),
data
,
index
);
}
}
// 同比/环比计算,通过对比类型和数据设置,计算出对应指标的结果,然后替换结果data数组中的对应元素
// 同比/环比计算,通过对比类型和数据设置,计算出对应指标的结果,然后替换结果data数组中的对应元素
// 如果因维度变化(如时间字段缺失,时间字段的展示格式变化)导致无法计算结果的,则结果data数组中的对应元素全置为null
// 如果因维度变化(如时间字段缺失,时间字段的展示格式变化)导致无法计算结果的,则结果data数组中的对应元素全置为null
// 根据不同图表类型,获得需要替换的指标index array
// 根据不同图表类型,获得需要替换的指标index array
...
@@ -1020,6 +1003,48 @@ public class ChartViewService {
...
@@ -1020,6 +1003,48 @@ public class ChartViewService {
return
uniteViewResult
(
datasourceRequest
.
getQuery
(),
mapChart
,
mapTableNormal
,
view
,
isDrill
,
drillFilters
);
return
uniteViewResult
(
datasourceRequest
.
getQuery
(),
mapChart
,
mapTableNormal
,
view
,
isDrill
,
drillFilters
);
}
}
// 对结果排序
public
List
<
String
[]>
resultCustomSort
(
List
<
ChartViewFieldDTO
>
xAxis
,
List
<
String
[]>
data
)
{
List
<
String
[]>
res
=
new
ArrayList
<>(
data
);
if
(
xAxis
.
size
()
>
0
)
{
// 找到对应维度
for
(
int
i
=
0
;
i
<
xAxis
.
size
();
i
++)
{
ChartViewFieldDTO
item
=
xAxis
.
get
(
i
);
if
(
StringUtils
.
equalsIgnoreCase
(
item
.
getSort
(),
"custom_sort"
))
{
// 获取自定义值与data对应列的结果
if
(
i
>
0
)
{
// 首先根据优先级高的字段分类,在每个前置字段相同的组里排序
Map
<
String
,
List
<
String
[]>>
map
=
new
LinkedHashMap
<>();
for
(
String
[]
d
:
res
)
{
StringBuilder
stringBuilder
=
new
StringBuilder
();
for
(
int
j
=
0
;
j
<
i
;
j
++)
{
if
(
StringUtils
.
equalsIgnoreCase
(
xAxis
.
get
(
j
).
getSort
(),
"none"
))
{
continue
;
}
stringBuilder
.
append
(
d
[
j
]);
}
if
(
CollectionUtils
.
isEmpty
(
map
.
get
(
stringBuilder
.
toString
())))
{
map
.
put
(
stringBuilder
.
toString
(),
new
ArrayList
<>());
}
map
.
get
(
stringBuilder
.
toString
()).
add
(
d
);
}
Iterator
<
Map
.
Entry
<
String
,
List
<
String
[]>>>
iterator
=
map
.
entrySet
().
iterator
();
List
<
String
[]>
list
=
new
ArrayList
<>();
while
(
iterator
.
hasNext
())
{
Map
.
Entry
<
String
,
List
<
String
[]>>
next
=
iterator
.
next
();
list
.
addAll
(
customSort
(
Optional
.
ofNullable
(
item
.
getCustomSort
()).
orElse
(
new
ArrayList
<>()),
next
.
getValue
(),
i
));
}
res
.
clear
();
res
.
addAll
(
list
);
}
else
{
res
=
customSort
(
Optional
.
ofNullable
(
item
.
getCustomSort
()).
orElse
(
new
ArrayList
<>()),
res
,
i
);
}
}
}
}
return
res
;
}
public
ChartViewDTO
uniteViewResult
(
String
sql
,
Map
<
String
,
Object
>
chartData
,
Map
<
String
,
Object
>
tabelData
,
ChartViewDTO
view
,
Boolean
isDrill
,
List
<
ChartExtFilterRequest
>
drillFilters
)
{
public
ChartViewDTO
uniteViewResult
(
String
sql
,
Map
<
String
,
Object
>
chartData
,
Map
<
String
,
Object
>
tabelData
,
ChartViewDTO
view
,
Boolean
isDrill
,
List
<
ChartExtFilterRequest
>
drillFilters
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
...
@@ -1371,16 +1396,17 @@ public class ChartViewService {
...
@@ -1371,16 +1396,17 @@ public class ChartViewService {
getIndex
=
i
;
getIndex
=
i
;
}
}
}
}
if
(
ObjectUtils
.
isNotEmpty
(
chartViewFieldDTO
))
{
List
<
String
[]>
sortResult
=
resultCustomSort
(
xAxis
,
sqlData
);
if
(
ObjectUtils
.
isNotEmpty
(
chartViewFieldDTO
)
&&
(
getIndex
>=
index
))
{
// 获取自定义值与data对应列的结果
// 获取自定义值与data对应列的结果
List
<
String
[]>
strings
=
customSort
(
Optional
.
ofNullable
(
chartViewFieldDTO
.
getCustomSort
()).
orElse
(
new
ArrayList
<>()),
s
qlData
,
index
);
List
<
String
[]>
strings
=
customSort
(
Optional
.
ofNullable
(
chartViewFieldDTO
.
getCustomSort
()).
orElse
(
new
ArrayList
<>()),
s
ortResult
,
index
);
for
(
int
i
=
0
;
i
<
strings
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
strings
.
size
();
i
++)
{
res
.
add
(
strings
.
get
(
i
)[
getIndex
]);
res
.
add
(
strings
.
get
(
i
)[
getIndex
]);
}
}
}
else
{
}
else
{
// 返回请求结果
// 返回请求结果
for
(
int
i
=
0
;
i
<
s
qlData
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
s
ortResult
.
size
();
i
++)
{
res
.
add
(
s
qlData
.
get
(
i
)[
getIndex
]);
res
.
add
(
s
ortResult
.
get
(
i
)[
getIndex
]);
}
}
}
}
}
}
...
...
frontend/src/views/chart/components/compare/CustomSortEdit.vue
浏览文件 @
620ff4af
...
@@ -17,7 +17,8 @@
...
@@ -17,7 +17,8 @@
</span>
</span>
</transition-group>
</transition-group>
</draggable>
</draggable>
<p
style=
"margin-top: 10px;color:#F56C6C;font-size: 12px;"
>
{{
$t
(
'chart.custom_sort_tip'
)
}}
</p>
<!--tips-->
<!--
<p
style=
"margin-top: 10px;color:#F56C6C;font-size: 12px;"
>
{{
$t
(
'chart.custom_sort_tip'
)
}}
</p>
-->
</div>
</div>
</
template
>
</
template
>
...
...
frontend/src/views/chart/view/ChartEdit.vue
浏览文件 @
620ff4af
...
@@ -2444,19 +2444,19 @@ export default {
...
@@ -2444,19 +2444,19 @@ export default {
this
.
customSortList
=
[]
this
.
customSortList
=
[]
},
},
saveCustomSort
()
{
saveCustomSort
()
{
// 先将所有自定义排序的维度设置为none,再对当前维度赋值
this
.
view
.
xaxis
.
forEach
(
ele
=>
{
this
.
view
.
xaxis
.
forEach
(
ele
=>
{
if
(
ele
.
sort
===
'custom_sort'
)
{
// 先将所有自定义排序的维度设置为none,再对当前维度赋值
ele
.
sort
=
'none'
// if (ele.sort === 'custom_sort') {
ele
.
customSort
=
[]
// ele.sort = 'none'
}
// ele.customSort = []
// }
if
(
ele
.
id
===
this
.
customSortField
.
id
)
{
if
(
ele
.
id
===
this
.
customSortField
.
id
)
{
ele
.
sort
=
'custom_sort'
ele
.
sort
=
'custom_sort'
ele
.
customSort
=
this
.
customSortList
ele
.
customSort
=
this
.
customSortList
}
}
})
})
this
.
calcData
(
true
)
this
.
closeCustomSort
()
this
.
closeCustomSort
()
this
.
calcData
(
true
)
}
}
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论