fix(图表-流向地图): 修复拖入起点及终点名称字段后无法显示值的问题

This commit is contained in:
jianneng-fit2cloud 2024-07-24 13:06:06 +08:00
parent 62c2b8f0a6
commit 8da885e7d8
2 changed files with 28 additions and 2 deletions

View File

@ -1,6 +1,9 @@
package io.dataease.chart.charts.impl.map; package io.dataease.chart.charts.impl.map;
import io.dataease.chart.charts.impl.GroupChartHandler; import io.dataease.chart.charts.impl.GroupChartHandler;
import io.dataease.extensions.view.dto.AxisFormatResult;
import io.dataease.extensions.view.dto.ChartAxis;
import io.dataease.extensions.view.dto.ChartViewDTO;
import lombok.Getter; import lombok.Getter;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -8,4 +11,13 @@ import org.springframework.stereotype.Component;
public class FlowMapHandler extends GroupChartHandler { public class FlowMapHandler extends GroupChartHandler {
@Getter @Getter
private String type = "flow-map"; private String type = "flow-map";
@Override
public AxisFormatResult formatAxis(ChartViewDTO view) {
var result = super.formatAxis(view);
var xAxis = result.getAxisMap().get(ChartAxis.xAxis);
xAxis.addAll(view.getFlowMapStartName());
xAxis.addAll(view.getFlowMapEndName());
result.getAxisMap().put(ChartAxis.xAxis, xAxis);
return result;
}
} }

View File

@ -130,12 +130,26 @@ export class FlowMap extends L7ChartView<Scene, L7Config> {
if (yAxisExt.length > 0) { if (yAxisExt.length > 0) {
lineColorField = yAxisExt[0].dataeaseName lineColorField = yAxisExt[0].dataeaseName
} }
const asteriskField = '*'
const data = []
chart.data?.tableRow.forEach(item => {
const newKey = 'f_record'
const newObj = Object.keys(item).reduce((acc, key) => {
if (key === asteriskField) {
acc[newKey] = item[key]
} else {
acc[key] = item[key]
}
return acc
}, {})
data.push(newObj)
})
const config: L7Config = new LineLayer({ const config: L7Config = new LineLayer({
name: 'line', name: 'line',
blend: 'normal', blend: 'normal',
autoFit: true autoFit: true
}) })
.source(chart.data?.tableRow ? chart.data.tableRow : [], { .source(data, {
parser: { parser: {
type: 'json', type: 'json',
x: xAxis[0].dataeaseName, x: xAxis[0].dataeaseName,
@ -154,7 +168,7 @@ export class FlowMap extends L7ChartView<Scene, L7Config> {
}) })
if (lineWidthField) { if (lineWidthField) {
config.size(lineWidthField, [1, 10]) config.size(lineWidthField === asteriskField ? 'f_record' : lineWidthField, [1, 10])
} }
if (lineColorField) { if (lineColorField) {
config.style({ config.style({