Merge pull request #9708 from ulleo/dev-v2

fix(图表): 修复区间条形图值轴选择纬度时,勾选聚合时间维度,无法获取间隔值的问题
This commit is contained in:
ulleo 2024-05-17 17:07:15 +08:00 committed by GitHub
commit 00d1c943b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 27 additions and 5 deletions

View File

@ -565,7 +565,21 @@ public class ChartDataManage {
String limit = ((pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) ? " LIMIT " + pageInfo.getPageSize() + " OFFSET " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() : "");
detailFieldSql = originSql + limit;
}
} else {
} else if (StringUtils.equalsIgnoreCase("bar-range", view.getType())) {
sqlMeta.setChartType(view.getType());
Dimension2SQLObj.dimension2sqlObj(sqlMeta, xAxis, transFields(allFields), crossDs, dsMap);
Quota2SQLObj.quota2sqlObj(sqlMeta, yAxis, transFields(allFields), crossDs, dsMap);
querySql = SQLProvider.createQuerySQL(sqlMeta, true, needOrder, view);
if (containDetailField(view) && ObjectUtils.isNotEmpty(viewFields)) {
detailFieldList.addAll(xAxis);
detailFieldList.addAll(viewFields);
Dimension2SQLObj.dimension2sqlObj(sqlMeta, detailFieldList, transFields(allFields), crossDs, dsMap);
String originSql = SQLProvider.createQuerySQL(sqlMeta, false, needOrder, view);
String limit = ((pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) ? " LIMIT " + pageInfo.getPageSize() + " OFFSET " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() : "");
detailFieldSql = originSql + limit;
}
}else {
Dimension2SQLObj.dimension2sqlObj(sqlMeta, xAxis, transFields(allFields), crossDs, dsMap);
Quota2SQLObj.quota2sqlObj(sqlMeta, yAxis, transFields(allFields), crossDs, dsMap);
querySql = SQLProvider.createQuerySQL(sqlMeta, true, needOrder, view);
@ -776,7 +790,7 @@ public class ChartDataManage {
} else if (StringUtils.containsIgnoreCase(view.getType(), "quadrant")) {
mapChart = ChartDataBuild.transQuadrantDataAntV(xAxis, yAxis, view, data, extBubble, isDrill);
} else if (StringUtils.equalsIgnoreCase(view.getType(), "bar-range")) {
mapChart = ChartDataBuild.transTimeBarDataAntV(skipBarRange, barRangeDate, xAxisBase, xAxis, yAxis, view, data, isDrill);
mapChart = ChartDataBuild.transBarRangeDataAntV(skipBarRange, barRangeDate, xAxisBase, xAxis, yAxis, view, data, isDrill);
} else {
mapChart = ChartDataBuild.transChartDataAntV(xAxis, yAxis, view, data, isDrill);
}

View File

@ -1327,7 +1327,7 @@ public class ChartDataBuild {
return map;
}
public static Map<String, Object> transTimeBarDataAntV(boolean skipBarRange, boolean isDate, List<ChartViewFieldDTO> xAxisBase, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, ChartViewDTO view, List<String[]> data, boolean isDrill) {
public static Map<String, Object> transBarRangeDataAntV(boolean skipBarRange, boolean isDate, List<ChartViewFieldDTO> xAxisBase, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, ChartViewDTO view, List<String[]> data, boolean isDrill) {
Map<String, Object> map = new HashMap<>();
if (skipBarRange) {

View File

@ -66,7 +66,7 @@ public class Dimension2SQLObj {
meta.setXFieldsDialect(fieldsDialect);
}
private static SQLObj getXFields(ChartViewFieldDTO x, String originField, String fieldAlias) {
public static SQLObj getXFields(ChartViewFieldDTO x, String originField, String fieldAlias) {
String fieldName = "";
if (Objects.equals(x.getDeExtractType(), DeTypeConstants.DE_TIME)) {
if (Objects.equals(x.getDeType(), DeTypeConstants.DE_INT) || Objects.equals(x.getDeType(), DeTypeConstants.DE_FLOAT)) {

View File

@ -50,7 +50,12 @@ public class Quota2SQLObj {
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
yFields.add(getYFields(y, originField, fieldAlias));
SQLObj ySQLObj = getYFields(y, originField, fieldAlias);
if (StringUtils.equalsIgnoreCase("bar-range", meta.getChartType()) && StringUtils.equalsIgnoreCase(y.getGroupType(), "d") && y.getDeType() == 1) {
yFields.add(Dimension2SQLObj.getXFields(y, ySQLObj.getFieldName(), fieldAlias));
} else {
yFields.add(ySQLObj);
}
// 处理纵轴过滤
String wheres = getYWheres(y, originField, fieldAlias);
if (ObjectUtils.isNotEmpty(wheres)) {

View File

@ -203,6 +203,7 @@ export class RangeBar extends G2PlotChartView<BarOptions, Bar> {
const t = JSON.parse(JSON.stringify(customAttr.tooltip))
if (t.show) {
tooltip = {
fields: ['values', 'field', 'gap'],
formatter: function (param: Datum) {
let res
if (isDate) {

View File

@ -11,6 +11,8 @@ import java.util.Map;
@Data
public class SQLMeta {
private String chartType;
private SQLObj table;
/**