Browse Source

获取数据集字段

persist/11.0
Qinghui.Liu 4 years ago
parent
commit
04756947ee
  1. 12
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java
  2. 54
      designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java

12
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.ActionListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -475,14 +474,11 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
} }
private List<String> getTableFieldNames() { private List<String> getTableFieldNames() {
List<String> fieldNames = new ArrayList<>(); if (parent == null) {
return null;
fieldNames.add("字段A"); }
fieldNames.add("字段B");
fieldNames.add("字段C");
fieldNames.add("字段D");
return fieldNames; return parent.getDataModelColumnNames();
} }
private JPanel createHtmlPane() { private JPanel createHtmlPane() {

54
designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java

@ -1,9 +1,20 @@
package com.fr.van.chart.designer.style; 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.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.dialog.BasicPane;
import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.mainframe.chart.gui.ChartStylePane; 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.plugin.chart.attr.plot.VanChartAxisPlot;
import com.fr.van.chart.designer.style.axis.VanChartAxisPane; import com.fr.van.chart.designer.style.axis.VanChartAxisPane;
import com.fr.van.chart.designer.style.background.VanChartAreaPane; import com.fr.van.chart.designer.style.background.VanChartAreaPane;
@ -75,4 +86,47 @@ public class VanChartStylePane extends ChartStylePane {
protected void addVanChartTooltipPane(List<BasicPane> paneList) { protected void addVanChartTooltipPane(List<BasicPane> paneList) {
paneList.add(new VanChartTooltipPane(VanChartStylePane.this)); paneList.add(new VanChartTooltipPane(VanChartStylePane.this));
} }
public List<String> 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;
}
}
} }
Loading…
Cancel
Save