From fab6a34948ce02e1616fa223a61e17b4f98ddd31 Mon Sep 17 00:00:00 2001 From: jianneng-fit2cloud Date: Mon, 22 Jul 2024 18:05:21 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=9B=BE=E8=A1=A8):=20=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E3=80=81=E6=B0=94=E6=B3=A1=E5=9C=B0=E5=9B=BE=E7=9A=84=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E6=94=AF=E6=8C=81=E6=98=BE=E7=A4=BA=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E6=8C=87=E6=A0=87=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../charts/impl/map/BubbleMapHandler.java | 20 ++++++++++ .../components/js/panel/charts/map/common.ts | 2 +- .../components/js/panel/common/common_antv.ts | 37 ++++++++++++++----- 3 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 core/core-backend/src/main/java/io/dataease/chart/charts/impl/map/BubbleMapHandler.java diff --git a/core/core-backend/src/main/java/io/dataease/chart/charts/impl/map/BubbleMapHandler.java b/core/core-backend/src/main/java/io/dataease/chart/charts/impl/map/BubbleMapHandler.java new file mode 100644 index 0000000000..1b926b1ac2 --- /dev/null +++ b/core/core-backend/src/main/java/io/dataease/chart/charts/impl/map/BubbleMapHandler.java @@ -0,0 +1,20 @@ +package io.dataease.chart.charts.impl.map; + +import io.dataease.chart.charts.impl.ExtQuotaChartHandler; +import io.dataease.extensions.view.dto.AxisFormatResult; +import io.dataease.extensions.view.dto.ChartViewDTO; +import lombok.Getter; +import org.springframework.stereotype.Component; + +@Component +public class BubbleMapHandler extends ExtQuotaChartHandler { + @Getter + private String type = "bubble-map"; + + @Override + public AxisFormatResult formatAxis(ChartViewDTO view) { + return super.formatAxis(view); + } +} + + diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/map/common.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/map/common.ts index 0fce5e2a71..18335669da 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/map/common.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/map/common.ts @@ -34,7 +34,7 @@ export const MAP_EDITOR_PROPERTY_INNER: EditorPropertyInner = { 'showDimension', 'showQuota' ], - 'tooltip-selector': ['color', 'fontSize', 'backgroundColor', 'tooltipFormatter', 'show'], + 'tooltip-selector': ['color', 'fontSize', 'backgroundColor', 'seriesTooltipFormatter', 'show'], 'function-cfg': ['emptyDataStrategy'], 'map-mapping': [''] } diff --git a/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts b/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts index 050b56e31c..46e21b8682 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts @@ -856,20 +856,39 @@ export function configL7Style(chart: Chart): AreaOptions['style'] { export function configL7Tooltip(chart: Chart): TooltipOptions { const customAttr = parseJson(chart.customAttr) const tooltip = customAttr.tooltip - const { yAxis } = chart + const formatterMap = tooltip.seriesTooltipFormatter + ?.filter(i => i.show) + .reduce((pre, next) => { + pre[next.id] = next + return pre + }, {}) as Record return { customTitle(data) { return data.name }, - items: [ - { - field: 'value', - alias: yAxis?.[0]?.chartShowName ?? yAxis?.[0]?.name, - customValue: value => { - return valueFormatter(value, tooltip.tooltipFormatter) - } + customItems(originalItem) { + const result = [] + if (isEmpty(formatterMap)) { + return result } - ], + const head = originalItem.properties + const formatter = formatterMap[head.quotaList?.[0]?.id] + if (!isEmpty(formatter)) { + const originValue = parseFloat(head.value as string) + const value = valueFormatter(originValue, formatter.formatterCfg) + const name = isEmpty(formatter.chartShowName) ? formatter.name : formatter.chartShowName + result.push({ ...head, name, value: `${value ?? ''}` }) + } + head.dynamicTooltipValue?.forEach(item => { + const formatter = formatterMap[item.fieldId] + if (formatter) { + const value = valueFormatter(parseFloat(item.value), formatter.formatterCfg) + const name = isEmpty(formatter.chartShowName) ? formatter.name : formatter.chartShowName + result.push({ color: 'grey', name, value: `${value ?? ''}` }) + } + }) + return result + }, showComponent: tooltip.show, domStyles: { 'l7plot-tooltip': {