|
|
|
@ -21,6 +21,9 @@ import com.fr.plugin.chart.attr.plot.VanChartPlot;
|
|
|
|
|
import com.fr.plugin.chart.base.AttrLabel; |
|
|
|
|
import com.fr.plugin.chart.base.AttrTooltip; |
|
|
|
|
import com.fr.plugin.chart.base.VanChartHtmlLabel; |
|
|
|
|
import com.fr.plugin.chart.map.VanChartMapPlot; |
|
|
|
|
import com.fr.plugin.chart.map.attr.AttrMapLabel; |
|
|
|
|
import com.fr.plugin.chart.map.attr.AttrMapTooltip; |
|
|
|
|
import com.fr.plugin.chart.vanchart.VanChart; |
|
|
|
|
import com.fr.report.cell.Elem; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
@ -39,6 +42,21 @@ import java.util.List;
|
|
|
|
|
*/ |
|
|
|
|
public class SearchJSUtils { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 样式-数据点提示 |
|
|
|
|
*/ |
|
|
|
|
public static final String STYLE_TOOLTIP_CUSTOM = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Basic_Style"), Toolkit.i18nText("Fine-Design_Chart_Tooltip")); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 样式-标签 |
|
|
|
|
*/ |
|
|
|
|
public static final String STYLE_LABEL = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Basic_Style"), Toolkit.i18nText("Fine-Design_Chart_Data_Label")); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 样式-分类标签 |
|
|
|
|
*/ |
|
|
|
|
public static final String CATEGORY_LABEL = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Basic_Style"), Toolkit.i18nText("Fine-Design_Chart_Data_Label"), Toolkit.i18nText("Fine-Design_Chart_Category_Label")); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 从Listener中获取JS |
|
|
|
|
*/ |
|
|
|
@ -118,29 +136,77 @@ public class SearchJSUtils {
|
|
|
|
|
*/ |
|
|
|
|
private static void addAttrLabelHtmlLabel(VanChart chart, List<Pair<VanChartHtmlLabel, String>> arrayList) { |
|
|
|
|
VanChartPlot plot = chart.getPlot(); |
|
|
|
|
//如果是地图类型要特殊处理
|
|
|
|
|
if (plot instanceof VanChartMapPlot) { |
|
|
|
|
addMapJS2Array((VanChartMapPlot) plot, arrayList); |
|
|
|
|
} else { |
|
|
|
|
addAttrToolTipCondition2Array(plot, arrayList); |
|
|
|
|
if (isAttrLabelExist(plot)) { |
|
|
|
|
addAttrLabelDetail2Array(plot, arrayList); |
|
|
|
|
addAttrSecondLabelDetail2Array(plot, arrayList); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 用于处理地图类型图表中的样式中的JS(AttrMapTooltip 与 AttrMapLabel) |
|
|
|
|
* |
|
|
|
|
* @param plot |
|
|
|
|
* @param arrayList |
|
|
|
|
*/ |
|
|
|
|
private static void addMapJS2Array(VanChartMapPlot plot, List<Pair<VanChartHtmlLabel, String>> arrayList) { |
|
|
|
|
ConditionAttr defaultAttr = plot.getConditionCollection().getDefaultAttr(); |
|
|
|
|
AttrMapTooltip attrMapTooltip = defaultAttr.getExisted(AttrMapTooltip.class); |
|
|
|
|
AttrMapLabel attrMapLabel = defaultAttr.getExisted(AttrMapLabel.class); |
|
|
|
|
//处理三种地图的数据点提示——点地图、流向地图、区域地图
|
|
|
|
|
dealMapTooltipJS(attrMapTooltip.getAreaTooltip(), arrayList); |
|
|
|
|
dealMapTooltipJS(attrMapTooltip.getLineTooltip(), arrayList); |
|
|
|
|
dealMapTooltipJS(attrMapTooltip.getPointTooltip(), arrayList); |
|
|
|
|
|
|
|
|
|
//处理两种地图的标签——点地图、区域地图(流向地图没有标签)
|
|
|
|
|
dealMapLabelJS(attrMapLabel.getAreaLabel(), arrayList); |
|
|
|
|
dealMapLabelJS(attrMapLabel.getPointLabel(), arrayList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 用于处理地图类型图表中的标签中的JS |
|
|
|
|
* |
|
|
|
|
* @param label 地图类型的标签(点地图、区域地图) |
|
|
|
|
* @param arrayList 用于存储htmlLabel的数组 |
|
|
|
|
*/ |
|
|
|
|
private static void dealMapLabelJS(AttrLabel label, List<Pair<VanChartHtmlLabel, String>> arrayList) { |
|
|
|
|
if (isAttrLabelValid(label)) { |
|
|
|
|
arrayList.add(new Pair<>(label.getContent().getHtmlLabel(), STYLE_LABEL)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 用于处理地图类型图表中的数据点提示中的JS |
|
|
|
|
* |
|
|
|
|
* @param tooltip 地图类型的数据点提示(点地图、流向地图、区域地图) |
|
|
|
|
* @param arrayList 用于存储htmlLabel的数组 |
|
|
|
|
*/ |
|
|
|
|
private static void dealMapTooltipJS(AttrTooltip tooltip, List<Pair<VanChartHtmlLabel, String>> arrayList) { |
|
|
|
|
if (isToolTipValid(tooltip)) { |
|
|
|
|
arrayList.add(new Pair<>(tooltip.getContent().getHtmlLabel(), STYLE_TOOLTIP_CUSTOM)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void addAttrToolTipCondition2Array(VanChartPlot plot, List<Pair<VanChartHtmlLabel, String>> arrayList) { |
|
|
|
|
if (isToolTipValid(plot)) { |
|
|
|
|
arrayList.add(new Pair<>(((AttrTooltip) plot.getAttrTooltipFromConditionCollection()).getContent().getHtmlLabel(), |
|
|
|
|
Toolkit.i18nText("Fine-Design_Chart_Tooltip") + "-" + Toolkit.i18nText("Fine-Design_Basic_Custom"))); |
|
|
|
|
if (isToolTipValid(plot.getAttrTooltipFromConditionCollection())) { |
|
|
|
|
arrayList.add(new Pair<>(((AttrTooltip) plot.getAttrTooltipFromConditionCollection()).getContent().getHtmlLabel(), STYLE_TOOLTIP_CUSTOM)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static boolean isToolTipValid(VanChartPlot plot) { |
|
|
|
|
return plot.getAttrTooltipFromConditionCollection() != null && ((AttrTooltip) plot.getAttrTooltipFromConditionCollection()).isEnable() && plot.getAttrTooltipFromConditionCollection() instanceof AttrTooltip; |
|
|
|
|
private static boolean isToolTipValid(DataSeriesCondition tooltip) { |
|
|
|
|
return tooltip instanceof AttrTooltip && ((AttrTooltip) tooltip).isEnable() && ((AttrTooltip) tooltip).getContent() != null && ((AttrTooltip) tooltip).getContent().getHtmlLabel() != null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void addAttrLabelDetail2Array(VanChartPlot plot, List<Pair<VanChartHtmlLabel, String>> arrayList) { |
|
|
|
|
if (isLabelDetailValid(plot)) { |
|
|
|
|
arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getAttrLabelDetail().getContent().getHtmlLabel(), Toolkit.i18nText("Fine-Design_Chart_Value_Label"))); |
|
|
|
|
arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getAttrLabelDetail().getContent().getHtmlLabel(), STYLE_LABEL)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -152,7 +218,7 @@ public class SearchJSUtils {
|
|
|
|
|
|
|
|
|
|
private static void addAttrSecondLabelDetail2Array(VanChartPlot plot, List<Pair<VanChartHtmlLabel, String>> arrayList) { |
|
|
|
|
if (isSecondLabelDetailValid(plot)) { |
|
|
|
|
arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getSecondLabelDetail().getContent().getHtmlLabel(), Toolkit.i18nText("Fine-Design_Chart_Category_Label"))); |
|
|
|
|
arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getSecondLabelDetail().getContent().getHtmlLabel(), CATEGORY_LABEL)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -194,7 +260,7 @@ public class SearchJSUtils {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static boolean isAttrLabelValid(AttrLabel label) { |
|
|
|
|
return label.isEnable() && label.getContent() != null && label.getContent().getHtmlLabel() != null; |
|
|
|
|
return label != null && label.isEnable() && label.getContent() != null && label.getContent().getHtmlLabel() != null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|