Browse Source

新增字段支持部分图表类型

feature/big-screen
Qinghui.Liu 4 years ago
parent
commit
e115ec56e0
  1. 15
      designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java
  2. 6
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListPane.java
  3. 8
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java
  4. 4
      designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryRichTextFieldListPane.java

15
designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java

@ -19,6 +19,7 @@ import com.fr.plugin.chart.heatmap.VanChartHeatMapPlot;
import com.fr.plugin.chart.line.VanChartLinePlot; import com.fr.plugin.chart.line.VanChartLinePlot;
import com.fr.plugin.chart.map.VanChartMapPlot; import com.fr.plugin.chart.map.VanChartMapPlot;
import com.fr.plugin.chart.multilayer.VanChartMultiPiePlot; import com.fr.plugin.chart.multilayer.VanChartMultiPiePlot;
import com.fr.plugin.chart.radar.VanChartRadarPlot;
import com.fr.plugin.chart.scatter.VanChartScatterPlot; import com.fr.plugin.chart.scatter.VanChartScatterPlot;
import com.fr.plugin.chart.structure.VanChartStructurePlot; import com.fr.plugin.chart.structure.VanChartStructurePlot;
import com.fr.plugin.chart.treemap.VanChartTreeMapPlot; import com.fr.plugin.chart.treemap.VanChartTreeMapPlot;
@ -94,6 +95,20 @@ public class PlotFactory {
return autoAdjustLabelPlots.contains(plot.getClass()); return autoAdjustLabelPlots.contains(plot.getClass());
} }
private static Set<Class<? extends Plot>> supportAddTableFieldPlots = new HashSet<>();
static {
supportAddTableFieldPlots.add(PiePlot4VanChart.class);
supportAddTableFieldPlots.add(VanChartColumnPlot.class);
supportAddTableFieldPlots.add(VanChartLinePlot.class);
supportAddTableFieldPlots.add(VanChartAreaPlot.class);
supportAddTableFieldPlots.add(VanChartRadarPlot.class);
}
public static boolean plotSupportAddTableField(Plot plot) {
return supportAddTableFieldPlots.contains(plot.getClass());
}
private static Set<Class<? extends Plot>> borderAndBackgroundLabelPlots = new HashSet<>(); private static Set<Class<? extends Plot>> borderAndBackgroundLabelPlots = new HashSet<>();
static { static {

6
designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListPane.java

@ -54,7 +54,7 @@ public class VanChartFieldListPane extends JPanel {
List<String> richEditorFieldNames = VanChartRichEditorPane.getFieldNames(); List<String> richEditorFieldNames = VanChartRichEditorPane.getFieldNames();
this.tableFieldNameList = richEditorFieldNames == null ? new ArrayList<>() : richEditorFieldNames; this.tableFieldNameList = (!supportAddField() || richEditorFieldNames == null) ? new ArrayList<>() : richEditorFieldNames;
this.fieldAttrPane = fieldAttrPane; this.fieldAttrPane = fieldAttrPane;
this.richEditorPane = richEditorPane; this.richEditorPane = richEditorPane;
@ -133,6 +133,10 @@ public class VanChartFieldListPane extends JPanel {
new AttrTooltipPercentFormat(), false, fieldListener); new AttrTooltipPercentFormat(), false, fieldListener);
} }
protected boolean supportAddField() {
return true;
}
protected void addDefaultFieldButton(JPanel fieldPane) { protected void addDefaultFieldButton(JPanel fieldPane) {
fieldPane.add(categoryNameButton); fieldPane.add(categoryNameButton);
fieldPane.add(seriesNameButton); fieldPane.add(seriesNameButton);

8
designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java

@ -3,6 +3,7 @@ package com.fr.van.chart.designer.component.richText;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.base.chart.chartdata.TopDefinitionProvider; import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartdata.MoreNameCDDefinition; import com.fr.chart.chartdata.MoreNameCDDefinition;
import com.fr.chart.chartdata.OneValueCDDefinition; import com.fr.chart.chartdata.OneValueCDDefinition;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
@ -17,6 +18,7 @@ import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.base.AttrTooltipRichText; import com.fr.plugin.chart.base.AttrTooltipRichText;
import com.fr.plugin.chart.type.TextAlign; import com.fr.plugin.chart.type.TextAlign;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.PlotFactory;
import com.teamdev.jxbrowser.chromium.Browser; import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.JSValue; import com.teamdev.jxbrowser.chromium.JSValue;
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter;
@ -51,6 +53,12 @@ public class VanChartRichEditorPane {
return; return;
} }
Plot plot = chart.getPlot();
if (plot == null || !PlotFactory.plotSupportAddTableField(plot)) {
return;
}
TopDefinitionProvider definition = chart.getFilterDefinition(); TopDefinitionProvider definition = chart.getFilterDefinition();
if (definition == null) { if (definition == null) {

4
designer-chart/src/main/java/com/fr/van/chart/pie/style/VanChartPieCategoryRichTextFieldListPane.java

@ -32,6 +32,10 @@ public class VanChartPieCategoryRichTextFieldListPane extends VanChartFieldListP
new AttrTooltipSummaryValueFormat(), false, listener); new AttrTooltipSummaryValueFormat(), false, listener);
} }
protected boolean supportAddField() {
return false;
}
protected void addDefaultFieldButton(JPanel fieldPane) { protected void addDefaultFieldButton(JPanel fieldPane) {
fieldPane.add(getCategoryNameButton()); fieldPane.add(getCategoryNameButton());
fieldPane.add(summaryValueButton); fieldPane.add(summaryValueButton);

Loading…
Cancel
Save