fix(图表-符号地图): 修复气泡大小字段配置汇总方式无效的问题

This commit is contained in:
jianneng-fit2cloud 2024-08-27 09:32:58 +08:00
parent ce1b8d12ee
commit 86e90823d5
5 changed files with 56 additions and 25 deletions

View File

@ -1764,25 +1764,24 @@ public class ChartDataBuild {
Map<String, List<String[]>> groupDataList = detailData.stream().collect(Collectors.groupingBy(item -> "(" + StringUtils.join(ArrayUtils.subarray(item, 0, xEndIndex), ")-de-(") + ")"));
tableRow.forEach(row -> {
BigDecimal rowValue = new BigDecimal(row.get(yAxis.get(0).getDataeaseName()).toString());
String key = xAxis.stream().map(x -> String.format(format, row.get(x.getDataeaseName()).toString())).collect(Collectors.joining("-de-"));
List<String[]> detailFieldValueList = groupDataList.get(key);
List<Map<String, Object>> detailValueMapList = Optional.ofNullable(detailFieldValueList).orElse(new ArrayList<>()).stream().map((detailArr -> {
Map<String, Object> temp = new HashMap<>();
for (int i = 0; i < realDetailFields.size(); i++) {
ChartViewFieldDTO realDetailField = realDetailFields.get(i);
temp.put(realDetailField.getDataeaseName(), detailArr[detailIndex + i]);
if(StringUtils.equalsIgnoreCase(yAxis.get(0).getDataeaseName(),realDetailField.getDataeaseName())){
temp.put(realDetailField.getDataeaseName(), rowValue);
}else{
temp.put(realDetailField.getDataeaseName(), detailArr[detailIndex + i]);
}
}
return temp;
})).collect(Collectors.toList());
//详情只要一个
row.put("details", !detailValueMapList.isEmpty() ?Collections.singletonList(detailValueMapList.getFirst()):detailValueMapList);
});
ChartViewFieldDTO detailFieldDTO = new ChartViewFieldDTO();
detailFieldDTO.setId(IDUtils.snowID());
detailFieldDTO.setName("detail");
detailFieldDTO.setDataeaseName("detail");
fields.add(detailFieldDTO);
map.put("fields", fields);
map.put("detailFields", realDetailFields);
map.put("tableRow", tableRow);

View File

@ -4,13 +4,12 @@ import { useI18n } from '@/hooks/web/useI18n'
import { COLOR_PANEL, DEFAULT_LABEL } from '@/views/chart/components/editor/util/chart'
import { ElFormItem, ElIcon, ElInput, ElSpace } from 'element-plus-secondary'
import { formatterType, unitType } from '../../../js/formatter'
import { defaultsDeep, cloneDeep, intersection, union, defaultTo, map } from 'lodash-es'
import { defaultsDeep, cloneDeep, intersection, union, defaultTo, map, isEmpty } from 'lodash-es'
import { includesAny } from '../../util/StringUtils'
import { fieldType } from '@/utils/attr'
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
import { storeToRefs } from 'pinia'
import Icon from '../../../../../../components/icon-custom/src/Icon.vue'
import { useEmitt } from '@/hooks/web/useEmitt'
const { t } = useI18n()
@ -43,12 +42,6 @@ const dvMainStore = dvMainStoreWithOut()
const toolTip = computed(() => {
return props.themes === 'dark' ? 'ndark' : 'dark'
})
const changeDataset = () => {
if (showProperty('showFields')) {
state.labelForm.showFields = []
emit('onLabelChange', { data: state.labelForm }, 'showFields')
}
}
const { batchOptStatus } = storeToRefs(dvMainStore)
watch(
[() => props.chart.customAttr.label, () => props.chart.customAttr.label.show],
@ -363,16 +356,31 @@ const allFields = computed(() => {
const defaultPlaceholder = computed(() => {
if (state.labelForm.showFields && state.labelForm.showFields.length > 0) {
return state.labelForm.showFields
.map(field => {
.filter(field => !isEmpty(field))
?.map(field => {
return '${' + field.split('@')[1] + '}'
})
.join(',')
}
return ''
})
watch(
() => allFields.value,
() => {
let result = []
state.labelForm.showFields?.forEach(field => {
if (allFields.value?.map(i => i.value).includes(field)) {
result.push(field)
}
})
state.labelForm.showFields = result
if (allFields.value.length > 0) {
changeLabelAttr('showFields')
}
}
)
onMounted(() => {
init()
useEmitt({ name: 'dataset-change', callback: changeDataset })
})
const isGroupBar = computed(() => {
return props.chart.type === 'bar-group'

View File

@ -7,7 +7,7 @@ import cloneDeep from 'lodash-es/cloneDeep'
import defaultsDeep from 'lodash-es/defaultsDeep'
import { formatterType, unitType } from '../../../js/formatter'
import { fieldType } from '@/utils/attr'
import { defaultTo, partition, map, includes } from 'lodash-es'
import { defaultTo, partition, map, includes, isEmpty } from 'lodash-es'
import chartViewManager from '../../../js/panel'
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
import { storeToRefs } from 'pinia'
@ -94,10 +94,6 @@ const changeDataset = () => {
})
}
})
if (showProperty('showFields')) {
state.tooltipForm.showFields = []
emit('onTooltipChange', { data: state.tooltipForm }, 'showFields')
}
}
const AXIS_PROP: AxisType[] = ['yAxis', 'yAxisExt', 'extBubble']
@ -380,11 +376,17 @@ const updateAxis = (form: AxisEditForm) => {
})
}
const allFields = computed(() => {
return defaultTo(props.allFields, [])
return defaultTo(props.allFields, []).map(item => ({
key: item.dataeaseName,
name: item.name,
value: `${item.dataeaseName}@${item.name}`,
disabled: false
}))
})
const defaultPlaceholder = computed(() => {
if (state.tooltipForm.showFields && state.tooltipForm.showFields.length > 0) {
return state.tooltipForm.showFields
.filter(field => !isEmpty(field))
.map(field => {
const v = field.split('@')
return v[1] + ': ${' + field.split('@')[1] + '}'
@ -393,6 +395,21 @@ const defaultPlaceholder = computed(() => {
}
return ''
})
watch(
() => allFields.value,
() => {
let result = []
state.tooltipForm.showFields?.forEach(field => {
if (allFields.value?.map(i => i.value).includes(field)) {
result.push(field)
}
})
state.tooltipForm.showFields = result
if (allFields.value.length > 0) {
changeTooltipAttr('showFields')
}
}
)
onMounted(() => {
init()
useEmitt({ name: 'addAxis', callback: updateSeriesTooltipFormatter })
@ -482,9 +499,9 @@ onMounted(() => {
>
<el-option
v-for="option in allFields"
:key="option.dataeaseName"
:key="option.key"
:label="option.name"
:value="option.dataeaseName + '@' + option.name"
:value="option.value"
/>
</el-select>
</el-form-item>

View File

@ -471,6 +471,9 @@ export class CarouselManager {
const buildTooltip = () => {
const customAttr = this.chart.customAttr ? parseJson(this.chart.customAttr) : null
if (customAttr?.tooltip?.show) {
if (!this.popup) {
return undefined
}
const { tooltip } = deepCopy(customAttr)
let showFields = tooltip.showFields || []
if (!tooltip.showFields || tooltip.showFields.length === 0) {

View File

@ -521,6 +521,10 @@ export const exportExcelDownload = (chart, callBack?) => {
}
}
if (chart.type.includes('symbolic-map')) {
request.detailFields = []
}
const linkStore = useLinkStoreWithOut()
if (isDataEaseBi.value || appStore.getIsIframe) {