From 8da885e7d836b67520223d3c8a32a3ab5039c061 Mon Sep 17 00:00:00 2001 From: jianneng-fit2cloud Date: Wed, 24 Jul 2024 13:06:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8-=E6=B5=81=E5=90=91?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE):=20=E4=BF=AE=E5=A4=8D=E6=8B=96=E5=85=A5?= =?UTF-8?q?=E8=B5=B7=E7=82=B9=E5=8F=8A=E7=BB=88=E7=82=B9=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=90=8E=E6=97=A0=E6=B3=95=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=80=BC=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/charts/impl/map/FlowMapHandler.java | 12 ++++++++++++ .../components/js/panel/charts/map/flow-map.ts | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/chart/charts/impl/map/FlowMapHandler.java b/core/core-backend/src/main/java/io/dataease/chart/charts/impl/map/FlowMapHandler.java index aa0963e0c4..0f63710e3b 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/charts/impl/map/FlowMapHandler.java +++ b/core/core-backend/src/main/java/io/dataease/chart/charts/impl/map/FlowMapHandler.java @@ -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; + } } diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/map/flow-map.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/map/flow-map.ts index 87283a679f..cbaaebf019 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/map/flow-map.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/map/flow-map.ts @@ -130,12 +130,26 @@ export class FlowMap extends L7ChartView { 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 { }) if (lineWidthField) { - config.size(lineWidthField, [1, 10]) + config.size(lineWidthField === asteriskField ? 'f_record' : lineWidthField, [1, 10]) } if (lineColorField) { config.style({