From 5ee5c7a6423d2b7d46ba31280ed06a29708d843b Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Tue, 29 Dec 2020 09:56:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/VanChartTooltipContentPane.java | 12 ++--- .../designer/style/VanChartStylePane.java | 54 +++++++++++++++++++ 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java index 89a6275181..b9472dd869 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java @@ -49,7 +49,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.util.ArrayList; import java.util.List; /** @@ -475,14 +474,11 @@ public class VanChartTooltipContentPane extends BasicBeanPane getTableFieldNames() { - List fieldNames = new ArrayList<>(); - - fieldNames.add("字段A"); - fieldNames.add("字段B"); - fieldNames.add("字段C"); - fieldNames.add("字段D"); + if (parent == null) { + return null; + } - return fieldNames; + return parent.getDataModelColumnNames(); } private JPanel createHtmlPane() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java index 32a4f8e547..f9d0720dc6 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java @@ -1,9 +1,20 @@ package com.fr.van.chart.designer.style; +import com.fr.base.TableData; +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; +import com.fr.chart.chartdata.MoreNameCDDefinition; +import com.fr.chart.chartdata.OneValueCDDefinition; +import com.fr.data.TableDataSource; +import com.fr.data.impl.EmbeddedTableData; +import com.fr.design.DesignModelAdapter; +import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.mainframe.chart.gui.ChartStylePane; +import com.fr.general.ComparatorUtils; +import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.attr.plot.VanChartAxisPlot; import com.fr.van.chart.designer.style.axis.VanChartAxisPane; import com.fr.van.chart.designer.style.background.VanChartAreaPane; @@ -75,4 +86,47 @@ public class VanChartStylePane extends ChartStylePane { protected void addVanChartTooltipPane(List paneList) { paneList.add(new VanChartTooltipPane(VanChartStylePane.this)); } + + public List getDataModelColumnNames() { + Chart chart = getChart(); + + if (chart == null) { + return null; + } + + TopDefinitionProvider definition = chart.getFilterDefinition(); + + if (definition == null) { + return null; + } + + DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter(); + TableDataSource tableDataSource = adapter == null ? null : adapter.getBook(); + + TableData tableData = null; + + if (ComparatorUtils.equals(definition.getDataDefinitionType(), OneValueCDDefinition.DEFINITION_TYPE)) { + OneValueCDDefinition oneValueCDDefinition = (OneValueCDDefinition) definition; + tableData = oneValueCDDefinition.getTableData(); + } + + if (ComparatorUtils.equals(definition.getDataDefinitionType(), MoreNameCDDefinition.DEFINITION_TYPE)) { + MoreNameCDDefinition moreNameCDDefinition = (MoreNameCDDefinition) definition; + tableData = moreNameCDDefinition.getTableData(); + } + + if (tableData == null) { + return null; + } + + try { + EmbeddedTableData embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tableDataSource, + tableData, TableData.RESULT_NOT_NEED, false); + + return DesignTableDataManager.getColumnNamesByTableData(embeddedTableData); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + return null; + } + } } \ No newline at end of file