Merge pull request #10626 from dataease/pr@dev-v2@chart-symbolic-fix

fix(图表-符号地图): 修复符号地图标签或者提示出现value是undefined的问题
This commit is contained in:
jianneng-fit2cloud 2024-06-30 16:10:02 +08:00 committed by GitHub
commit d7505b618f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 4 deletions

View File

@ -62,7 +62,12 @@ public class SymbolicMapHandler extends GroupChartHandler {
var xAxis = formatResult.getAxisMap().get(ChartAxis.xAxis);
var yAxis = formatResult.getAxisMap().get(ChartAxis.yAxis);
var allFields = (List<ChartViewFieldDTO>) filterResult.getContext().get("allFields");
SQLMeta sqlMeta1 = new SQLMeta();
BeanUtils.copyBean(sqlMeta1, sqlMeta);
Dimension2SQLObj.dimension2sqlObj(sqlMeta, xAxis, FieldUtil.transFields(allFields), crossDs, dsMap);
List<ChartViewFieldDTO> yFields = new ArrayList<>();
yFields.addAll(chartViewManege.transFieldDTO(Collections.singletonList(chartViewManege.createCountField(view.getTableId()))));
yAxis.addAll(yFields);
Quota2SQLObj.quota2sqlObj(sqlMeta, yAxis, FieldUtil.transFields(allFields), crossDs, dsMap);
String querySql = SQLProvider.createQuerySQL(sqlMeta, true, needOrder, view);
querySql = SqlUtils.rebuildSQL(querySql, sqlMeta, crossDs, dsMap);
@ -76,15 +81,16 @@ public class SymbolicMapHandler extends GroupChartHandler {
detailFields.addAll(xAxis);
detailFields.addAll(allFields.stream().filter(field -> !xAxisIds.contains(field.getId())).toList());
if (ObjectUtils.isNotEmpty(detailFields)) {
SQLMeta sqlMeta1 = new SQLMeta();
BeanUtils.copyBean(sqlMeta1, sqlMeta);
sqlMeta1.setYFields(new ArrayList<>());
Dimension2SQLObj.dimension2sqlObj(sqlMeta1, detailFields, FieldUtil.transFields(allFields), crossDs, dsMap);
// 为了不添加limit,要查所有数据否则无法跟前面的数据对上因为前面使用了group by
String defaultResultMode = view.getResultMode();
view.setResultMode("");
String originSql = SQLProvider.createQuerySQL(sqlMeta1, false, needOrder, view);
originSql = SqlUtils.rebuildSQL(originSql, sqlMeta, crossDs, dsMap);
datasourceRequest.setQuery(originSql);
logger.info("calcite detail field sql: " + querySql);
detailData = (List<String[]>) provider.fetchResultField(datasourceRequest).get("data");
view.setResultMode(defaultResultMode);
}
//自定义排序
data = ChartDataUtil.resultCustomSort(xAxis, data);

View File

@ -1798,7 +1798,8 @@ public class ChartDataBuild {
}
return temp;
})).collect(Collectors.toList());
row.put("details", detailValueMapList);
//详情只要一个
row.put("details", !detailValueMapList.isEmpty() ?Collections.singletonList(detailValueMapList.getFirst()):detailValueMapList);
});
ChartViewFieldDTO detailFieldDTO = new ChartViewFieldDTO();