Merge pull request #12481 from dataease/dev

merge v1.18.25
This commit is contained in:
fit2cloudrd 2024-09-26 10:40:44 +08:00 committed by GitHub
commit 13d88fba75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 71 additions and 22 deletions

View File

@ -787,17 +787,20 @@ public class ChartViewService {
return emptyChartViewDTO(view);
}
ChartFieldCompareDTO compareCalc = yAxis.get(0).getCompareCalc();
boolean isYoy = StringUtils.isNotEmpty(compareCalc.getType()) && !StringUtils.equalsIgnoreCase(compareCalc.getType(),"none");
if(isYoy){
List<DatasetTableField> xField = fields.stream().filter(item->StringUtils.equalsIgnoreCase(item.getId(),compareCalc.getField())).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(xField)){
if (Objects.isNull(compareCalc)) {
break;
}
boolean isYoy = StringUtils.isNotEmpty(compareCalc.getType()) && !StringUtils.equalsIgnoreCase(compareCalc.getType(), "none");
if (isYoy) {
List<DatasetTableField> xField = fields.stream().filter(item -> StringUtils.equalsIgnoreCase(item.getId(), compareCalc.getField())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(xField)) {
ChartViewFieldDTO xFieldChartViewFieldDTO = new ChartViewFieldDTO();
org.springframework.beans.BeanUtils.copyProperties(xField.get(0), xFieldChartViewFieldDTO);
xAxis.add(xFieldChartViewFieldDTO);
xAxis.get(0).setSort("desc");
if(Objects.isNull(compareCalc.getCustom())){
if (Objects.isNull(compareCalc.getCustom())) {
xAxis.get(0).setDateStyle("y_M_d");
}else{
} else {
xAxis.get(0).setDateStyle(compareCalc.getCustom().getTimeType());
}
}
@ -1179,7 +1182,7 @@ public class ChartViewService {
data = resultCustomSort(xAxis, data);
// 插件同环比
data = pluginViewYOY(pluginViewParam, view, data);
data = pluginViewYOY(pluginViewParam, view, data, ds);
// 请求正确的数据然后取值
if (isYOY) {
@ -2035,9 +2038,9 @@ public class ChartViewService {
return result;
}
private List<String[]> pluginViewYOY(PluginViewParam param, ChartViewDTO view, List<String[]> args) {
private List<String[]> pluginViewYOY(PluginViewParam param, ChartViewDTO view, List<String[]> args, Datasource ds) {
ViewPluginService viewPluginService = getPluginService(view.getType());
return viewPluginService.yoy(param, args);
return viewPluginService.yoy(param, args, ds);
}
private ChartViewDTO emptyChartViewDTO(ChartViewDTO view) {

View File

@ -608,11 +608,13 @@ export function stockLineOptionAntV(container, chart, action) {
const theme = getTheme(chart)
const legend = getLegend(chart)
const basicStyle = JSON.parse(chart.customAttr).color
const colors = []
let colors = []
const alpha = basicStyle.alpha
basicStyle.colors.forEach(ele => {
colors.push(hexColorToRGBA(ele, alpha))
})
// custom color
colors = antVCustomColor(chart)
const data = cloneDeep(chart.data?.tableRow ?? [])
// 时间字段

View File

@ -1746,7 +1746,7 @@ export const TYPE_CONFIGS = [
icon: 'stock-line',
properties: [
'color-selector',
'size-selector',
'size-selector-ant-v',
'tooltip-selector-ant-v',
'x-axis-selector-ant-v',
'y-axis-selector-ant-v',
@ -1760,7 +1760,7 @@ export const TYPE_CONFIGS = [
'customColor',
'alpha'
],
'size-selector': [
'size-selector-ant-v': [
'lineWidth',
'lineSymbol',
'lineSymbolSize',
@ -3761,6 +3761,15 @@ export function getColors(chart, colors, reset) {
})
}
}
} else if (equalsAny(chart.type, 'stock-line')) {
const averages = ['MA5', 'MA10', 'MA20', 'MA60', 'MA120', 'MA180']
for (let i = 0; i < averages.length; i++) {
seriesColors.push({
name: averages[i],
color: colors[i % colors.length],
isCustom: false
})
}
} else {
if (chart.data) {
const data = chart.data.data

View File

@ -1909,23 +1909,23 @@ export default {
this.sizeForm.gaugePercentLabel = this.sizeForm.gaugePercentLabel === false ? false : DEFAULT_SIZE.gaugePercentLabel
if (this.chart.type !== 'table-pivot') {
let { xaxis, yaxis } = this.chart
if (!(xaxis instanceof Object)) {
if (!(xaxis instanceof Object) && xaxis) {
xaxis = JSON.parse(xaxis)
}
if (!(yaxis instanceof Object)) {
if (!(yaxis instanceof Object) && yaxis) {
yaxis = JSON.parse(yaxis)
}
let allAxis = xaxis
if (this.chart.type === 'table-normal') {
allAxis = allAxis.concat(yaxis)
}
if (allAxis.length && this.sizeForm.showIndex) {
if (allAxis?.length && this.sizeForm.showIndex) {
allAxis.unshift({
dataeaseName: SERIES_NUMBER_FIELD,
name: this.sizeForm.indexLabel
})
}
if (!allAxis.length) {
if (!allAxis?.length) {
this.sizeForm.tableFieldWidth?.splice(0)
this.fieldColumnWidth.fieldId = ''
this.fieldColumnWidth.width = ''
@ -1982,7 +1982,10 @@ export default {
},
changeBarSizeCase(modifyName) {
if (!this.doChange) {
this.doChange = _.debounce(() => this.debounceChange(modifyName), 200)
this.doChange = _.debounce(() => {
this.debounceChange(modifyName)
this.doChange = undefined
}, 200)
}
this.doChange()
},

View File

@ -10,5 +10,6 @@ public class ChartConstants {
public static final String YEAR_YOY = "year_yoy";
public static final String DAY_MOM = "day_mom";
public static final String MONTH_YOY = "month_yoy";
public static final String[] M_Y = {YEAR_MOM, MONTH_MOM, YEAR_YOY, DAY_MOM, MONTH_YOY};
public static final String WEEK_MOM = "week_mom";
public static final String[] M_Y = {YEAR_MOM, MONTH_MOM, YEAR_YOY, DAY_MOM, MONTH_YOY, WEEK_MOM};
}

View File

@ -1,5 +1,6 @@
package io.dataease.plugins.view.official.impl;
import io.dataease.plugins.common.base.domain.Datasource;
import io.dataease.plugins.common.dto.StaticResource;
import io.dataease.plugins.common.dto.chart.ChartFieldCompareDTO;
import io.dataease.plugins.view.entity.*;
@ -119,7 +120,7 @@ public class ChartMixService extends ViewPluginService {
}
@Override
public List<String[]> yoy(PluginViewParam pluginViewParam, List<String[]> data) {
public List<String[]> yoy(PluginViewParam pluginViewParam, List<String[]> data, Datasource ds) {
List<PluginViewField> xAxis = new ArrayList<>();
List<PluginViewField> yAxis = new ArrayList<>();
@ -183,7 +184,7 @@ public class ChartMixService extends ViewPluginService {
String cValue = item[dataIndex];
// 获取计算后的时间并且与所有维度拼接
String lastTime = calcLastTime(cTime, compareCalc.getType(), timeField.getDateStyle(), timeField.getDatePattern());
String lastTime = calcLastTime(cTime, compareCalc.getType(), timeField.getDateStyle(), timeField.getDatePattern(), ds);
String[] dimension = Arrays.copyOfRange(item, 0, checkedField.size());
dimension[timeIndex] = lastTime;
@ -317,11 +318,14 @@ public class ChartMixService extends ViewPluginService {
return StringUtils.equalsIgnoreCase(calcType, "day_mom")
|| StringUtils.equalsIgnoreCase(calcType, "month_yoy")
|| StringUtils.equalsIgnoreCase(calcType, "year_yoy");
case "y_W":
return StringUtils.equalsIgnoreCase(calcType, "week_mom")
|| StringUtils.equalsIgnoreCase(calcType, "year_yoy");
}
return false;
}
private String calcLastTime(String cTime, String type, String dateStyle, String datePattern) {
private String calcLastTime(String cTime, String type, String dateStyle, String datePattern, Datasource ds) {
try {
String lastTime = null;
Calendar calendar = Calendar.getInstance();
@ -356,6 +360,12 @@ public class ChartMixService extends ViewPluginService {
} else {
simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
}
} else if (StringUtils.equalsIgnoreCase(dateStyle, "y_W")) {
if (StringUtils.equalsIgnoreCase(datePattern, "date_split")) {
simpleDateFormat = new SimpleDateFormat("yyyy/'W'w");
} else {
simpleDateFormat = new SimpleDateFormat("yyyy-'W'w");
}
}
Date date = simpleDateFormat.parse(cTime);
calendar.setTime(date);
@ -391,6 +401,26 @@ public class ChartMixService extends ViewPluginService {
calendar.setTime(date);
calendar.add(Calendar.MONTH, -1);
lastTime = simpleDateFormat.format(calendar.getTime());
} else if (StringUtils.equalsIgnoreCase(type, ChartConstants.WEEK_MOM)) {
SimpleDateFormat simpleDateFormat = null;
if (StringUtils.equalsIgnoreCase(datePattern, "date_split")) {
if (StringUtils.equalsIgnoreCase(ds.getType(), "ck")) {
simpleDateFormat = new SimpleDateFormat("yyyy/'W'w");
} else {
simpleDateFormat = new SimpleDateFormat("yyyy/'W'ww");
}
} else {
if (StringUtils.equalsIgnoreCase(ds.getType(), "ck")) {
simpleDateFormat = new SimpleDateFormat("yyyy-'W'w");
} else {
simpleDateFormat = new SimpleDateFormat("yyyy-'W'ww");
}
}
Date date = simpleDateFormat.parse(cTime);
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_YEAR, 6);// 加6天用一周最后一天计算周可避免跨年的问题
calendar.add(Calendar.WEEK_OF_YEAR, -1);
lastTime = simpleDateFormat.format(calendar.getTime());
}
return lastTime;
} catch (Exception e) {

View File

@ -1,5 +1,6 @@
package io.dataease.plugins.view.service;
import io.dataease.plugins.common.base.domain.Datasource;
import io.dataease.plugins.common.service.PluginComponentService;
import io.dataease.plugins.common.util.PluginSpringContextUtil;
import io.dataease.plugins.view.entity.PluginViewParam;
@ -40,7 +41,7 @@ public abstract class ViewPluginService extends PluginComponentService {
return rsHandler.format(param, lists, isDrill);
}
public List<String[]> yoy(PluginViewParam param, List<String[]> lists) {
public List<String[]> yoy(PluginViewParam param, List<String[]> lists, Datasource ds) {
yoyHandler = new DefaultViewYOYHandler();
return yoyHandler.yoy(param, lists);
}