You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
913 lines
38 KiB
913 lines
38 KiB
package com.fr.plugin.pielinecomb; |
|
|
|
import com.bulenkov.iconloader.util.Base64Converter; |
|
import com.fr.base.Base64; |
|
import com.fr.base.BaseFormula; |
|
import com.fr.data.core.FormatField; |
|
import com.fr.extended.chart.*; |
|
import com.fr.general.ComparatorUtils; |
|
import com.fr.general.xml.GeneralXMLTools; |
|
import com.fr.js.NameJavaScriptGroup; |
|
import com.fr.json.JSONArray; |
|
import com.fr.json.JSONException; |
|
import com.fr.json.JSONObject; |
|
import com.fr.log.FineLoggerFactory; |
|
import com.fr.plugin.pielinecomb.comp.AbstractCustomChart; |
|
import com.fr.plugin.pielinecomb.comp.WebPageRender; |
|
import com.fr.plugin.pielinecomb.data.DataUtils; |
|
import com.fr.plugin.pielinecomb.data.LineDataConfig; |
|
import com.fr.plugin.pielinecomb.data.PieDataConfig; |
|
import com.fr.plugin.pielinecomb.vo.HyperLinkObject; |
|
import com.fr.plugin.transform.ExecuteFunctionRecord; |
|
import com.fr.plugin.transform.FunctionRecorder; |
|
import com.fr.script.Calculator; |
|
import com.fr.stable.AssistUtils; |
|
import com.fr.stable.StableUtils; |
|
import com.fr.stable.StringUtils; |
|
import com.fr.stable.web.Repository; |
|
import com.fr.stable.xml.XMLPrintWriter; |
|
import com.fr.stable.xml.XMLableReader; |
|
|
|
import java.awt.image.BufferedImage; |
|
import java.io.UnsupportedEncodingException; |
|
import java.math.RoundingMode; |
|
import java.text.Format; |
|
import java.util.ArrayList; |
|
import java.util.List; |
|
import java.util.stream.Collectors; |
|
|
|
/** |
|
* @author duan.jingliang |
|
* @date 2022/8/19 |
|
*/ |
|
@FunctionRecorder |
|
public class PieLineCombChart extends AbstractCustomChart<AbstractDataConfig> { |
|
|
|
private static final String ID = "PieLineCombChart"; |
|
private static final String NAME = "柱形折线组合图_定制_EK"; |
|
|
|
private static String BASE64_CHART_IMG = ""; |
|
|
|
/** |
|
* 图表类型 |
|
* */ |
|
private int chartType; |
|
/** |
|
* 数据集类型 |
|
* */ |
|
private String dataType; |
|
|
|
public static String PIE_DATA = "PieData"; |
|
public static String LINE_DATA = "LineData"; |
|
|
|
private JSONObject titleConf; |
|
private JSONObject legendConf; |
|
private JSONObject labelConf; |
|
private JSONObject seriesConf; |
|
private JSONObject axisConf; |
|
private JSONObject tipsConf; |
|
private JSONObject bgConf; |
|
|
|
private JSONObject styleCond; |
|
private HyperLinkObject linkConf; |
|
|
|
private StringFormula titleName; |
|
|
|
@Override |
|
protected String getChartID() { |
|
return ID; |
|
} |
|
|
|
@Override |
|
public String getChartName() { |
|
return NAME; |
|
} |
|
|
|
@ExecuteFunctionRecord |
|
@Override |
|
protected void addJSON(AbstractDataConfig dataConfig, JSONObject jsonObject, Repository repository, JSONPara jsonPara) throws JSONException { |
|
|
|
//Format format = getDataFormat(getAxisConf().getInt("xformattype"), getAxisConf().getString("xformatstr")); |
|
//String k = format.format(35666.666666D); |
|
|
|
JSONObject title = getTitleConf(); |
|
title.put("titlename", this.titleName.getResult()); |
|
|
|
jsonObject.put("titleConf", title); |
|
jsonObject.put("legendConf", getLegendConf()); |
|
jsonObject.put("labelConf", getLabelConf()); |
|
jsonObject.put("seriesConf", getSeriesConf()); |
|
jsonObject.put("axisConf", getAxisConf()); |
|
jsonObject.put("tipsConf", getTipsConf()); |
|
jsonObject.put("bgConf", getBgConf()); |
|
jsonObject.put("styleCond", getStyleCond()); |
|
|
|
addAutoLinkJSON(jsonObject, jsonPara); |
|
|
|
jsonObject.put("data", makeChartData()); |
|
} |
|
|
|
private JSONObject makeChartData() { |
|
|
|
PieDataConfig pieData = DataUtils.getDataConfig(PieLineCombChart.PIE_DATA, this); |
|
LineDataConfig lineData = DataUtils.getDataConfig(PieLineCombChart.LINE_DATA, this); |
|
|
|
JSONObject jsonObject = JSONObject.create(); |
|
if (chartType == 0) { |
|
JSONObject pieDataConf = makeSingleData(pieData, "pie"); |
|
JSONArray pieAxisXData = pieDataConf.getJSONArray("xAxisData"); |
|
JSONArray pieAxisXLabelData = JSONArray.create(); |
|
for (int i = 0; i < pieAxisXData.size(); i++) { |
|
Format format = getDataFormat(getAxisConf().getInt("xformattype"), getAxisConf().getString("xformatstr")); |
|
try { |
|
String label = format.format(pieAxisXData.get(i)); |
|
pieAxisXLabelData.put(label); |
|
} catch (Exception e) { |
|
e.printStackTrace(); |
|
pieAxisXLabelData.put(pieAxisXData.get(i)); |
|
} |
|
} |
|
pieDataConf.put("xAxisLabelData", pieAxisXLabelData); |
|
jsonObject.put("pie", pieDataConf); |
|
} else if (chartType == 1) { |
|
JSONObject pieDataConf = makeSingleData(lineData, "line"); |
|
JSONArray pieAxisXData = pieDataConf.getJSONArray("xAxisData"); |
|
JSONArray pieAxisXLabelData = JSONArray.create(); |
|
for (int i = 0; i < pieAxisXData.size(); i++) { |
|
Format format = getDataFormat(getAxisConf().getInt("xformattype"), getAxisConf().getString("xformatstr")); |
|
try { |
|
String label = format.format(pieAxisXData.get(i)); |
|
pieAxisXLabelData.put(label); |
|
} catch (Exception e) { |
|
e.printStackTrace(); |
|
pieAxisXLabelData.put(pieAxisXData.get(i)); |
|
} |
|
} |
|
pieDataConf.put("xAxisLabelData", pieAxisXLabelData); |
|
jsonObject.put("line", pieDataConf); |
|
} else { |
|
JSONObject pieDataConf = makeSingleData(pieData, "pie"); |
|
JSONArray pieAxisXData = pieDataConf.getJSONArray("xAxisData"); |
|
JSONArray pieAxisXLabelData = JSONArray.create(); |
|
for (int i = 0; i < pieAxisXData.size(); i++) { |
|
Format format = getDataFormat(getAxisConf().getInt("xformattype"), getAxisConf().getString("xformatstr")); |
|
try { |
|
String label = format.format(pieAxisXData.get(i)); |
|
pieAxisXLabelData.put(label); |
|
} catch (Exception e) { |
|
FineLoggerFactory.getLogger().warn("Data Format error!"); |
|
pieAxisXLabelData.put(pieAxisXData.get(i)); |
|
} |
|
} |
|
pieDataConf.put("xAxisLabelData", pieAxisXLabelData); |
|
jsonObject.put("pie", pieDataConf); |
|
|
|
pieDataConf = makeSingleData(lineData, "line"); |
|
pieAxisXData = pieDataConf.getJSONArray("xAxisData"); |
|
pieAxisXLabelData = JSONArray.create(); |
|
for (int i = 0; i < pieAxisXData.size(); i++) { |
|
Format format = getDataFormat(getAxisConf().getJSONObject("axisX").getInt("xformattype"), getAxisConf().getJSONObject("axisX").getString("xformatstr")); |
|
try { |
|
String label = format.format(pieAxisXData.get(i)); |
|
pieAxisXLabelData.put(label); |
|
} catch (Exception e) { |
|
e.printStackTrace(); |
|
pieAxisXLabelData.put(pieAxisXData.get(i)); |
|
} |
|
} |
|
pieDataConf.put("xAxisLabelData", pieAxisXLabelData); |
|
jsonObject.put("line", pieDataConf); |
|
} |
|
|
|
return jsonObject; |
|
} |
|
|
|
private JSONObject makeSingleData(AbstractDataConfig dataConfig, String dataName) { |
|
JSONObject jsonObject = JSONObject.create(); |
|
boolean isCustomName = false; |
|
ExtendedField categoryField = null; |
|
ExtendedField gridLineField = null; |
|
ExtendedField regionColorField = null; |
|
List<ExtendedField> customList = null; |
|
ExtendedField customName = null; |
|
ExtendedField customValue = null; |
|
|
|
if ("pie".equals(dataName)) { |
|
PieDataConfig pieData = (PieDataConfig)dataConfig; |
|
isCustomName = pieData.isCustomName(); |
|
categoryField = pieData.getCategory(); |
|
gridLineField = pieData.getGridline(); |
|
regionColorField = pieData.getRegioncolor(); |
|
customList = pieData.getCustomFields(); |
|
customName = pieData.getCustomNameField(); |
|
customValue = pieData.getCustomValueField(); |
|
} else if ("line".equals(dataName)) { |
|
LineDataConfig lineData = (LineDataConfig)dataConfig; |
|
isCustomName = lineData.isCustomName(); |
|
categoryField = lineData.getCategory(); |
|
gridLineField = lineData.getGridline(); |
|
regionColorField = lineData.getRegioncolor(); |
|
customList = lineData.getCustomFields(); |
|
customName = lineData.getCustomNameField(); |
|
customValue = lineData.getCustomValueField(); |
|
} |
|
if (isCustomName) { |
|
if (null != customList && customList.size() > 0) { |
|
JSONObject seriesObj = JSONObject.create(); |
|
JSONObject seriesObjIdx = JSONObject.create(); |
|
JSONArray gridLineData = JSONArray.create(); |
|
JSONObject regionColorData = JSONObject.create(); |
|
for (int i = 0; i < customList.size(); i++) { |
|
ExtendedField customField = customList.get(i); |
|
List categorys = categoryField.getValues(); |
|
List values = customField.getValues(); |
|
List gridLines = null == gridLineField ? null : gridLineField.getValues(); |
|
List regionColors = null == regionColorField ? null : regionColorField.getValues(); |
|
JSONArray seriesData = JSONArray.create(); |
|
int subEndIdx = customList.get(0).getValues().size(); |
|
for (int k = 0; k < subEndIdx; k++) { |
|
JSONArray seriesItem = JSONArray.create(); |
|
seriesItem.put(categorys.get(k)); |
|
seriesItem.put(values.get(k)); |
|
seriesData.put(seriesItem); |
|
if (i == 0 && null != gridLines && null != gridLines.get(k) |
|
&& StringUtils.isNotEmpty(gridLines.get(k).toString())) { |
|
gridLineData.put(categorys.get(k)); |
|
} |
|
if (i == 0 && null != regionColors && null != regionColors.get(k) |
|
&& StringUtils.isNotEmpty(regionColors.get(k).toString())) { |
|
regionColorData.put(categorys.get(k).toString(), regionColors.get(k)); |
|
} |
|
} |
|
seriesObj.put(customField.getCustomName(), seriesData); |
|
seriesObjIdx.put(customField.getCustomName(), i); |
|
} |
|
int subEndIdx = customList.get(0).getValues().size(); |
|
jsonObject.put("xAxisData", JSONArray.create(categoryField.getValues().subList(0, subEndIdx))); |
|
jsonObject.put("gridLine", gridLineData); |
|
jsonObject.put("regionColor", regionColorData); |
|
jsonObject.put("seriesData", seriesObj); |
|
jsonObject.put("seriesIndex", seriesObjIdx); |
|
} |
|
} else { |
|
List<Object> category = categoryField.getValues(); |
|
List<Object> gridLine = null == gridLineField ? null : gridLineField.getValues(); |
|
List<Object> regionColor = null == regionColorField ? null : regionColorField.getValues(); |
|
List<Object> name = customName.getValues(); |
|
List<Object> value = customValue.getValues(); |
|
if (null != category && category.size() > 0) { |
|
JSONObject seriesObj = JSONObject.create(); |
|
JSONObject seriesObjIdx = JSONObject.create(); |
|
if (null != name && name.size() > 0) { |
|
// 用字段值 |
|
List<Object> categoryNoDup = category.stream().distinct().collect(Collectors.toList()); |
|
List<Object> nameNoDup = name.stream().distinct().collect(Collectors.toList()); |
|
if (nameNoDup.size() > 1) { |
|
// 多系列 |
|
JSONArray gridLineData = JSONArray.create(); |
|
JSONObject regionColorData = JSONObject.create(); |
|
for (int i = 0; i < nameNoDup.size(); i++) { |
|
JSONArray tmpSeries = JSONArray.create(); |
|
for (int j = 0; j <categoryNoDup.size(); j++) { |
|
|
|
for (int k = 0; k < value.size(); k++) { |
|
if (categoryNoDup.get(j).equals(category.get(k)) |
|
&& nameNoDup.get(i).equals(name.get(k))) { |
|
JSONArray seriesItem = JSONArray.create(); |
|
seriesItem.put(category.get(k)); |
|
seriesItem.put(value.get(k)); |
|
tmpSeries.put(seriesItem); |
|
|
|
if (i == 0 && null != gridLine && null != gridLine.get(k) |
|
&& StringUtils.isNotEmpty(gridLine.get(k).toString())) { |
|
gridLineData.put(category.get(k)); |
|
} |
|
if (i == 0 && null != regionColor && null != regionColor.get(k) |
|
&& StringUtils.isNotEmpty(regionColor.get(k).toString())) { |
|
regionColorData.put(category.get(k).toString(), regionColor.get(k)); |
|
} |
|
break; |
|
} |
|
|
|
} |
|
} |
|
seriesObj.put(nameNoDup.get(i).toString(), tmpSeries); |
|
seriesObjIdx.put(nameNoDup.get(i).toString(), i); |
|
} |
|
jsonObject.put("seriesData", seriesObj); |
|
jsonObject.put("xAxisData", JSONArray.create(categoryNoDup)); |
|
jsonObject.put("gridLine", gridLineData); |
|
jsonObject.put("regionColor", regionColorData); |
|
jsonObject.put("seriesIndex", seriesObjIdx); |
|
} else { |
|
JSONArray seriesData = JSONArray.create(); |
|
JSONArray gridLineData = JSONArray.create(); |
|
JSONObject regionColorData = JSONObject.create(); |
|
for (int k = 0; k < category.size(); k++) { |
|
JSONArray seriesItem = JSONArray.create(); |
|
seriesItem.put(category.get(k)); |
|
seriesItem.put(value.get(k)); |
|
seriesData.put(seriesItem); |
|
|
|
if (null != gridLine && null != gridLine.get(k) |
|
&& StringUtils.isNotEmpty(gridLine.get(k).toString())) { |
|
gridLineData.put(category.get(k)); |
|
} |
|
if (null != regionColor && null != regionColor.get(k) |
|
&& StringUtils.isNotEmpty(regionColor.get(k).toString())) { |
|
regionColorData.put(category.get(k).toString(), regionColor.get(k)); |
|
} |
|
} |
|
seriesObj.put(nameNoDup.get(0).toString(), seriesData); |
|
seriesObjIdx.put(nameNoDup.get(0).toString(), 0); |
|
jsonObject.put("xAxisData", JSONArray.create(category)); |
|
jsonObject.put("gridLine", gridLineData); |
|
jsonObject.put("regionColor", regionColorData); |
|
jsonObject.put("seriesData", seriesObj); |
|
jsonObject.put("seriesIndex", seriesObjIdx); |
|
} |
|
|
|
} else if (null != value && value.size() > 0 && value.size() == category.size()) { |
|
|
|
JSONArray seriesData = JSONArray.create(); |
|
JSONArray gridLineData = JSONArray.create(); |
|
JSONObject regionColorData = JSONObject.create(); |
|
for (int k = 0; k < category.size(); k++) { |
|
JSONArray seriesItem = JSONArray.create(); |
|
seriesItem.put(category.get(k)); |
|
seriesItem.put(value.get(k)); |
|
seriesData.put(seriesItem); |
|
|
|
if (null != gridLine && null != gridLine.get(k) |
|
&& StringUtils.isNotEmpty(gridLine.get(k).toString())) { |
|
gridLineData.put(category.get(k)); |
|
} |
|
if (null != regionColor && null != regionColor.get(k) |
|
&& StringUtils.isNotEmpty(regionColor.get(k).toString())) { |
|
regionColorData.put(category.get(k).toString(), regionColor.get(k)); |
|
} |
|
} |
|
seriesObj.put("default", seriesData); |
|
seriesObjIdx.put("default", 0); |
|
jsonObject.put("xAxisData", JSONArray.create(category)); |
|
jsonObject.put("gridLine", gridLineData); |
|
jsonObject.put("regionColor", regionColorData); |
|
jsonObject.put("seriesData", seriesObj); |
|
jsonObject.put("seriesIndex", seriesObjIdx); |
|
} else { |
|
FineLoggerFactory.getLogger().error("PieLineCombChart data config error!"); |
|
} |
|
} |
|
} |
|
return jsonObject; |
|
} |
|
|
|
@Override |
|
protected BufferedImage getChartImage(Calculator cal, int width, int height) { |
|
BufferedImage image = null; |
|
try { |
|
synchronized (this) { |
|
|
|
JSONObject jsonObject = JSONObject.create(); |
|
|
|
jsonObject.put("data", makeChartData()); |
|
|
|
jsonObject.put("titleConf", getTitleConf()); |
|
jsonObject.put("legendConf", getLegendConf()); |
|
jsonObject.put("labelConf", getLabelConf()); |
|
jsonObject.put("seriesConf", getSeriesConf()); |
|
jsonObject.put("axisConf", getAxisConf()); |
|
jsonObject.put("tipsConf", getTipsConf()); |
|
jsonObject.put("bgConf", getBgConf()); |
|
jsonObject.put("styleCond", getStyleCond()); |
|
|
|
if (StringUtils.isNotEmpty(BASE64_CHART_IMG) && !WebPageRender.getInstance().isDataChanged(jsonObject)) { |
|
image = (BufferedImage) GeneralXMLTools.imageDecode(Base64Converter.decode(BASE64_CHART_IMG.getBytes())); |
|
} else { |
|
String imgStr = WebPageRender.getInstance().makeChartImage(jsonObject, width, height); |
|
if (StringUtils.isNotEmpty(imgStr)) { |
|
BASE64_CHART_IMG = imgStr; |
|
image = (BufferedImage) GeneralXMLTools.imageDecode(Base64Converter.decode(imgStr.getBytes())); |
|
} else { |
|
image = super.getDemoImage(); |
|
} |
|
} |
|
} |
|
} catch (Exception e) { |
|
e.printStackTrace(); |
|
image = super.getDemoImage(); |
|
} |
|
return image; |
|
} |
|
|
|
@Override |
|
protected String[] requiredJS() { |
|
return new String[]{ |
|
"com/fr/plugin/pielinecomb/web/PieLineCombChartWrapper.js" |
|
}; |
|
} |
|
|
|
@Override |
|
protected String wrapperName() { |
|
return "PieLineCombChartWrapper"; |
|
} |
|
|
|
private void addAutoLinkJSON(JSONObject paramJSONObject, JSONPara paramAbstractChart) |
|
throws JSONException { |
|
if (null != this.getLinkConf()) { |
|
NameJavaScriptGroup pieNameGroup = this.getLinkConf().getNameJavaScriptGroup(HyperLinkObject.CHART_TYPE_PIE); |
|
if (null != pieNameGroup) { |
|
ToHyperlinkJSONHelper.addECNameToLinkGroup(paramAbstractChart.ecName, paramAbstractChart.sheetIndex, pieNameGroup); |
|
paramJSONObject.put(HyperLinkObject.CHART_TYPE_PIE, ToHyperlinkJSONHelper.addAutoLinkJSON(pieNameGroup, hyperLinkParas())); |
|
} |
|
|
|
NameJavaScriptGroup lineNameGroup = this.getLinkConf().getNameJavaScriptGroup(HyperLinkObject.CHART_TYPE_LINE); |
|
if (null != lineNameGroup) { |
|
ToHyperlinkJSONHelper.addECNameToLinkGroup(paramAbstractChart.ecName, paramAbstractChart.sheetIndex, lineNameGroup); |
|
paramJSONObject.put(HyperLinkObject.CHART_TYPE_LINE, ToHyperlinkJSONHelper.addAutoLinkJSON(lineNameGroup, hyperLinkParas())); |
|
} |
|
} |
|
} |
|
|
|
@Override |
|
public NameJavaScriptGroup getHotHyperlink(String s) { |
|
return this.getLinkConf().getNameJavaScriptGroup(s); |
|
} |
|
|
|
@Override |
|
protected HyperLinkPara[] hyperLinkParas() { |
|
return new HyperLinkPara[]{ |
|
new HyperLinkPara() { |
|
@Override |
|
public String getName() { |
|
return "分类名"; |
|
} |
|
|
|
@Override |
|
public String getFormulaContent() { |
|
return "CATEGORY"; |
|
} |
|
|
|
@Override |
|
public String[] getProps() { |
|
return new String[]{"category"}; |
|
} |
|
}, |
|
new HyperLinkPara() { |
|
@Override |
|
public String getName() { |
|
return "系列名"; |
|
} |
|
|
|
@Override |
|
public String getFormulaContent() { |
|
return "SERIES"; |
|
} |
|
|
|
@Override |
|
public String[] getProps() { |
|
return new String[]{"series"}; |
|
} |
|
}, |
|
new HyperLinkPara() { |
|
@Override |
|
public String getName() { |
|
return "数值"; |
|
} |
|
|
|
@Override |
|
public String getFormulaContent() { |
|
return "VALUE"; |
|
} |
|
|
|
@Override |
|
public String[] getProps() { |
|
return new String[]{"value"}; |
|
} |
|
} |
|
}; |
|
} |
|
|
|
@Override |
|
protected void readAttr(XMLableReader xmLableReader) { |
|
super.readAttr(xmLableReader); |
|
this.chartType = xmLableReader.getAttrAsInt("chartType", 0); |
|
String jsonStr = xmLableReader.getAttrAsString("dataType", ""); |
|
if (StringUtils.isNotEmpty(jsonStr)) { |
|
this.setDataType(jsonStr); |
|
} |
|
|
|
jsonStr = xmLableReader.getAttrAsString("titleConf", ""); |
|
if (StringUtils.isNotEmpty(jsonStr)) { |
|
this.setTitleConf(new JSONObject(jsonStr)); |
|
} |
|
|
|
jsonStr = xmLableReader.getAttrAsString("legendConf", ""); |
|
if (StringUtils.isNotEmpty(jsonStr)) { |
|
this.setLegendConf(new JSONObject(jsonStr)); |
|
} |
|
|
|
jsonStr = xmLableReader.getAttrAsString("labelConf", ""); |
|
if (StringUtils.isNotEmpty(jsonStr)) { |
|
this.setLabelConf(new JSONObject(jsonStr)); |
|
} |
|
|
|
jsonStr = xmLableReader.getAttrAsString("seriesConf", ""); |
|
if (StringUtils.isNotEmpty(jsonStr)) { |
|
this.setSeriesConf(new JSONObject(jsonStr)); |
|
} |
|
|
|
try { |
|
jsonStr = xmLableReader.getAttrAsString("axisConf", ""); |
|
if (StringUtils.isNotEmpty(jsonStr)) { |
|
this.setAxisConf(new JSONObject(new String(Base64.decode(jsonStr), "UTF-8"))); |
|
} |
|
} catch (Exception e) { |
|
FineLoggerFactory.getLogger().warn(e.getMessage(), e); |
|
} |
|
|
|
jsonStr = xmLableReader.getAttrAsString("tipsConf", ""); |
|
if (StringUtils.isNotEmpty(jsonStr)) { |
|
this.setTipsConf(new JSONObject(jsonStr)); |
|
} |
|
|
|
jsonStr = xmLableReader.getAttrAsString("bgConf", ""); |
|
if (StringUtils.isNotEmpty(jsonStr)) { |
|
this.setBgConf(new JSONObject(jsonStr)); |
|
} |
|
|
|
try { |
|
jsonStr = xmLableReader.getAttrAsString("styleCond", ""); |
|
if (StringUtils.isNotEmpty(jsonStr)) { |
|
this.setStyleCond(new JSONObject(new String(Base64.decode(jsonStr), "UTF-8"))); |
|
} |
|
} catch (Exception e) { |
|
FineLoggerFactory.getLogger().warn(e.getMessage(), e); |
|
} |
|
|
|
if (null == linkConf) { |
|
linkConf = (HyperLinkObject) xmLableReader.readXMLObject(new HyperLinkObject()); |
|
} |
|
|
|
this.titleName = new StringFormula(this.getTitleConf().getString("titlename")); |
|
} |
|
|
|
@Override |
|
protected void writeAttr(XMLPrintWriter xmlPrintWriter) { |
|
super.writeAttr(xmlPrintWriter); |
|
xmlPrintWriter.attr("chartType", chartType); |
|
if (null != dataType) { |
|
xmlPrintWriter.attr("dataType", dataType); |
|
} |
|
if (null != titleConf) { |
|
xmlPrintWriter.attr("titleConf", titleConf.toString()); |
|
} |
|
if (null != legendConf) { |
|
xmlPrintWriter.attr("legendConf", legendConf.toString()); |
|
} |
|
if (null != labelConf) { |
|
xmlPrintWriter.attr("labelConf", labelConf.toString()); |
|
} |
|
if (null != seriesConf) { |
|
xmlPrintWriter.attr("seriesConf", seriesConf.toString()); |
|
} |
|
if (null != axisConf) { |
|
try { |
|
xmlPrintWriter.attr("axisConf", Base64.encode(axisConf.toString().getBytes("UTF-8"))); |
|
} catch (Exception e) { |
|
FineLoggerFactory.getLogger().warn(e.getMessage(), e); |
|
} |
|
} |
|
if (null != tipsConf) { |
|
xmlPrintWriter.attr("tipsConf", tipsConf.toString()); |
|
} |
|
if (null != bgConf) { |
|
xmlPrintWriter.attr("bgConf", bgConf.toString()); |
|
} |
|
|
|
if (null != styleCond) { |
|
try { |
|
xmlPrintWriter.attr("styleCond", Base64.encode(styleCond.toString().getBytes("UTF-8"))); |
|
} catch (Exception e) { |
|
FineLoggerFactory.getLogger().warn(e.getMessage(), e); |
|
} |
|
} |
|
|
|
if (null != linkConf) { |
|
linkConf.writeXML(xmlPrintWriter); |
|
} |
|
} |
|
|
|
@Override |
|
public boolean equals(Object o) { |
|
boolean isEq = super.equals(o) |
|
&& o instanceof PieLineCombChart |
|
&& ComparatorUtils.equals(((PieLineCombChart) o).getDataType(), this.dataType) |
|
&& ComparatorUtils.equals(((PieLineCombChart) o).getChartType(), this.chartType) |
|
&& ComparatorUtils.equals(((PieLineCombChart) o).getTitleConf(), this.titleConf) |
|
&& ComparatorUtils.equals(((PieLineCombChart) o).getLegendConf(), this.legendConf) |
|
&& ComparatorUtils.equals(((PieLineCombChart) o).getLabelConf(), this.labelConf) |
|
&& ComparatorUtils.equals(((PieLineCombChart) o).getSeriesConf(), this.seriesConf) |
|
&& ComparatorUtils.equals(((PieLineCombChart) o).getAxisConf(), this.axisConf) |
|
&& ComparatorUtils.equals(((PieLineCombChart) o).getTipsConf(), this.tipsConf) |
|
&& ComparatorUtils.equals(((PieLineCombChart) o).getBgConf(), this.bgConf) |
|
&& ComparatorUtils.equals(((PieLineCombChart) o).getStyleCond(), this.styleCond) |
|
&& ComparatorUtils.equals(((PieLineCombChart) o).getLinkConf(), this.linkConf) |
|
; |
|
return isEq; |
|
} |
|
|
|
@Override |
|
public int hashCode() { |
|
return super.hashCode() + AssistUtils.hashCode(new Object[]{this.dataType, this.chartType, this.titleConf, this.legendConf, this.labelConf, this.seriesConf, this.axisConf, this.tipsConf, this.bgConf, this.styleCond, this.linkConf}); |
|
} |
|
|
|
@Override |
|
public PieLineCombChart clone() throws CloneNotSupportedException { |
|
PieLineCombChart chart = (PieLineCombChart)super.clone(); |
|
if (this.linkConf != null) { |
|
chart.setLinkConf((HyperLinkObject) this.getLinkConf().clone()); |
|
} |
|
return chart; |
|
} |
|
|
|
@Override |
|
protected List<StringFormula> formulas() { |
|
List<StringFormula> formulaList = new ArrayList<StringFormula>(); |
|
formulaList.add(this.titleName); |
|
return formulaList; |
|
} |
|
|
|
@Override |
|
protected String demoImagePath() { |
|
return "com/fr/plugin/pielinecomb/images/demo.png"; |
|
} |
|
|
|
public Format getDataFormat(Integer type, String formatStr) { |
|
if (type == 7) { |
|
return FormatField.getInstance().getFormat(type, formatStr); |
|
} else if (StringUtils.isNotEmpty(formatStr)) { |
|
return FormatField.getInstance().getFormat(type, formatStr, RoundingMode.HALF_EVEN); |
|
} else { |
|
return null; |
|
} |
|
} |
|
|
|
public int getChartType() { |
|
return chartType; |
|
} |
|
|
|
public void setChartType(int chartType) { |
|
this.chartType = chartType; |
|
} |
|
|
|
public String getDataType() { |
|
return dataType; |
|
} |
|
|
|
public void setDataType(String dataType) { |
|
this.dataType = dataType; |
|
} |
|
|
|
public JSONObject getTitleConf() { |
|
if (null == titleConf) { |
|
titleConf = new JSONObject(); |
|
titleConf.put("titlevisiable", true); |
|
titleConf.put("titlename", "组合图"); |
|
titleConf.put("titleposition", 0); |
|
titleConf.put("titlesize", 16); |
|
titleConf.put("titlestyle", 1); |
|
titleConf.put("titlefamily", "微软雅黑"); |
|
titleConf.put("titlecolor", "#333300"); |
|
titleConf.put("titlebgcolor", "transparent"); |
|
titleConf.put("titleBgOpacity", 100); |
|
} |
|
return titleConf; |
|
} |
|
|
|
public void setTitleConf(JSONObject titleConf) { |
|
this.titleConf = titleConf; |
|
} |
|
|
|
public JSONObject getLegendConf() { |
|
if (null == legendConf) { |
|
legendConf = new JSONObject(); |
|
legendConf.put("legendalignment", 4); |
|
legendConf.put("legendcolor", "#000000"); |
|
legendConf.put("legendfamily", "微软雅黑"); |
|
legendConf.put("legendmargin", 20); |
|
legendConf.put("legendposition", 1); |
|
legendConf.put("legendsize", 12); |
|
legendConf.put("legendstyle", 0); |
|
legendConf.put("showlegend", true); |
|
} |
|
return legendConf; |
|
} |
|
|
|
public void setLegendConf(JSONObject legendConf) { |
|
this.legendConf = legendConf; |
|
} |
|
|
|
public JSONObject getLabelConf() { |
|
if (null == labelConf) { |
|
labelConf = new JSONObject(); |
|
labelConf.put("chartType", 1); |
|
labelConf.put("lineJsPane", ""); |
|
labelConf.put("linePosition", "top"); |
|
labelConf.put("lineValueType", 1); |
|
labelConf.put("linelabelcolor", "#000000"); |
|
labelConf.put("linelabelfamily", "微软雅黑"); |
|
labelConf.put("linelabelsize", 12); |
|
labelConf.put("linelabelstyle", 0); |
|
labelConf.put("pieDirection", 0); |
|
labelConf.put("pieJsPane", "return this.data[1]"); |
|
labelConf.put("piePosition", "insideTop"); |
|
labelConf.put("pieValueType", 1); |
|
labelConf.put("pielabelcolor", "#000000"); |
|
labelConf.put("pielabelfamily", "微软雅黑"); |
|
labelConf.put("pielabelsize", 12); |
|
labelConf.put("pielabelstyle", 0); |
|
labelConf.put("showLineCategory", false); |
|
labelConf.put("showLineLabel", true); |
|
labelConf.put("showLineSeries", false); |
|
labelConf.put("showLineValue", true); |
|
labelConf.put("showPieCategory", false); |
|
labelConf.put("showPieLabel", true); |
|
labelConf.put("showPieSeries", false); |
|
labelConf.put("showPieValue", true); |
|
} |
|
return labelConf; |
|
} |
|
|
|
public void setLabelConf(JSONObject labelConf) { |
|
this.labelConf = labelConf; |
|
} |
|
|
|
public JSONObject getSeriesConf() { |
|
if (null == seriesConf) { |
|
seriesConf = new JSONObject(); |
|
seriesConf.put("chartType", 2); |
|
seriesConf.put("lineCornerColor", "#ffff00"); |
|
seriesConf.put("lineCornerColorType", "系列色"); |
|
seriesConf.put("lineCornerRadius", 10); |
|
seriesConf.put("lineCornerShape", "默认"); |
|
seriesConf.put("lineCornerType", 0); |
|
seriesConf.put("lineType", "solid"); |
|
seriesConf.put("lineWidth", 1); |
|
seriesConf.put("pieFixWidth", 10); |
|
seriesConf.put("pieSeriesGapWidth", 30); |
|
seriesConf.put("pieWidthType", 1); |
|
seriesConf.put("seriesColorCustom", true); |
|
seriesConf.put("seriesColorList", "#63b2ee|#76da91|#f8cb7f|#f89588|#7cd6cf|#9192ab|#7898e1|#efa666|#eddd86|#9987ce"); |
|
seriesConf.put("seriesColorName", ""); |
|
} |
|
return seriesConf; |
|
} |
|
|
|
public void setSeriesConf(JSONObject seriesConf) { |
|
this.seriesConf = seriesConf; |
|
} |
|
|
|
public JSONObject getAxisConf() { |
|
if (null == axisConf) { |
|
axisConf = new JSONObject(); |
|
JSONObject axisX = JSONObject.create(); |
|
axisX.put("axisName", "X轴"); |
|
axisX.put("isLabelVisiable", true); |
|
axisX.put("isTitleVisiable", true); |
|
axisX.put("labelFormatType", 1); |
|
axisX.put("labelJsPane", ""); |
|
axisX.put("labelRotation", 0); |
|
axisX.put("labelcolor", "#000000"); |
|
axisX.put("labelfamily", "微软雅黑"); |
|
axisX.put("labelsize", 12); |
|
axisX.put("labelstyle", 0); |
|
axisX.put("titleAlignment", 4); |
|
axisX.put("titleName", "分类"); |
|
axisX.put("titleRotation", 0); |
|
axisX.put("titlecolor", "#000000"); |
|
axisX.put("titlefamily", "微软雅黑"); |
|
axisX.put("titlesize", 12); |
|
axisX.put("titlestyle", 0); |
|
axisX.put("xformatstr", ""); |
|
axisX.put("xformattype", 7); |
|
axisConf.put("axisX", axisX); |
|
|
|
JSONArray axisYList = JSONArray.create(); |
|
JSONObject axisY = JSONObject.create(); |
|
axisY.put("axisName", "Y轴"); |
|
axisY.put("intervalValue", ""); |
|
axisY.put("isLabelVisiable", true); |
|
axisY.put("isTitleVisiable", true); |
|
axisY.put("labelFormatType", 1); |
|
axisY.put("labelJsPane", "return this.value;"); |
|
axisY.put("labelRotation", 0); |
|
axisY.put("labelcolor", "#000000"); |
|
axisY.put("labelfamily", "微软雅黑"); |
|
axisY.put("labelsize", 12); |
|
axisY.put("labelstyle", 0); |
|
axisY.put("maxValue", ""); |
|
axisY.put("minValue", ""); |
|
axisY.put("position", "left"); |
|
axisY.put("showInterval", false); |
|
axisY.put("showMaxValue", false); |
|
axisY.put("showMinValue", false); |
|
axisY.put("titleAlignment", 2); |
|
axisY.put("titleName", "数量"); |
|
axisY.put("titleRotation", 0); |
|
axisY.put("titlecolor", "#000000"); |
|
axisY.put("titlefamily", "微软雅黑"); |
|
axisY.put("titlesize", 12); |
|
axisY.put("titlestyle", 0); |
|
axisY.put("yformatstr", "#0"); |
|
axisY.put("yformattype", 1); |
|
axisYList.put(axisY); |
|
axisConf.put("axisY", axisYList); |
|
} |
|
return axisConf; |
|
} |
|
|
|
public void setAxisConf(JSONObject axisConf) { |
|
this.axisConf = axisConf; |
|
} |
|
|
|
public JSONObject getTipsConf() { |
|
if (null == tipsConf) { |
|
tipsConf = JSONObject.create(); |
|
tipsConf.put("chartType", 1); |
|
JSONObject pie = JSONObject.create(); |
|
pie.put("bgColor", "#000000"); |
|
pie.put("bgOpacity", 35); |
|
pie.put("jsPane", ""); |
|
pie.put("showCategory", true); |
|
pie.put("showSeries", true); |
|
pie.put("showTip", true); |
|
pie.put("showValue", true); |
|
pie.put("tipcolor", "#ffffff"); |
|
pie.put("tipfamily", "微软雅黑"); |
|
pie.put("tipsize", 12); |
|
pie.put("tipstyle", 0); |
|
pie.put("valueType", 1); |
|
tipsConf.put("pie", pie); |
|
|
|
JSONObject line = JSONObject.create(); |
|
line.put("bgColor", "#000000"); |
|
line.put("bgOpacity", 30); |
|
line.put("jsPane", "0"); |
|
line.put("showCategory", false); |
|
line.put("showSeries", true); |
|
line.put("showTip", true); |
|
line.put("showValue", true); |
|
line.put("tipcolor", "#ffff00"); |
|
line.put("tipfamily", "微软雅黑"); |
|
line.put("tipsize", 12); |
|
line.put("tipstyle", 0); |
|
line.put("valueType", 1); |
|
tipsConf.put("line", line); |
|
} |
|
return tipsConf; |
|
} |
|
|
|
public void setTipsConf(JSONObject tipsConf) { |
|
this.tipsConf = tipsConf; |
|
} |
|
|
|
public JSONObject getBgConf() { |
|
if (bgConf == null) { |
|
bgConf = JSONObject.create(); |
|
bgConf.put("bgColor", "#ffffff"); |
|
bgConf.put("bgOpacity", 100); |
|
bgConf.put("chartType", 1); |
|
bgConf.put("fixHeight", 0); |
|
bgConf.put("gridXColor", "#c0c0c0"); |
|
bgConf.put("gridXColorCustom", false); |
|
bgConf.put("gridXColorList", "#2474a9|#97d1f7|#ef6c6c|#f9cd76|#6691e9|#7adbc8|#8861c3|#ffaec8|#936c61|#e4d354|#1d9992|#9ccc66"); |
|
bgConf.put("gridXColorName", "热情"); |
|
bgConf.put("gridYColor", "#c0c0c0"); |
|
} |
|
return bgConf; |
|
} |
|
|
|
public void setBgConf(JSONObject bgConf) { |
|
this.bgConf = bgConf; |
|
} |
|
|
|
public JSONObject getStyleCond() { |
|
if (null == styleCond) { |
|
styleCond = JSONObject.create(); |
|
} |
|
return styleCond; |
|
} |
|
|
|
public void setStyleCond(JSONObject styleCond) { |
|
this.styleCond = styleCond; |
|
} |
|
|
|
public HyperLinkObject getLinkConf() { |
|
return linkConf; |
|
} |
|
|
|
public void setLinkConf(HyperLinkObject linkConf) { |
|
this.linkConf = linkConf; |
|
} |
|
}
|
|
|