forked from github/dataease
Merge pull request #11140 from dataease/pr@dev-v2@chart-flow-map-fix
fix(图表-流向地图): 修复拖入起点及终点名称字段后无法显示值的问题
This commit is contained in:
commit
2c4bbd2bb7
@ -1,6 +1,9 @@
|
||||
package io.dataease.chart.charts.impl.map;
|
||||
|
||||
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 org.springframework.stereotype.Component;
|
||||
|
||||
@ -8,4 +11,13 @@ import org.springframework.stereotype.Component;
|
||||
public class FlowMapHandler extends GroupChartHandler {
|
||||
@Getter
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -130,12 +130,26 @@ export class FlowMap extends L7ChartView<Scene, L7Config> {
|
||||
if (yAxisExt.length > 0) {
|
||||
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({
|
||||
name: 'line',
|
||||
blend: 'normal',
|
||||
autoFit: true
|
||||
})
|
||||
.source(chart.data?.tableRow ? chart.data.tableRow : [], {
|
||||
.source(data, {
|
||||
parser: {
|
||||
type: 'json',
|
||||
x: xAxis[0].dataeaseName,
|
||||
@ -154,7 +168,7 @@ export class FlowMap extends L7ChartView<Scene, L7Config> {
|
||||
})
|
||||
|
||||
if (lineWidthField) {
|
||||
config.size(lineWidthField, [1, 10])
|
||||
config.size(lineWidthField === asteriskField ? 'f_record' : lineWidthField, [1, 10])
|
||||
}
|
||||
if (lineColorField) {
|
||||
config.style({
|
||||
|
Loading…
Reference in New Issue
Block a user