zlp 询价单折线图等
This commit is contained in:
parent
a06208f61f
commit
da2cf3906b
@ -0,0 +1,216 @@
|
||||
package yem.wmc.ydn.formplugin.dynamic;
|
||||
|
||||
import kd.bos.bill.AbstractBillPlugIn;
|
||||
import kd.bos.form.chart.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author zlp
|
||||
* @Date 2024/12/24 17:10
|
||||
* @PackageName:yem.wmc.ydn.formplugin.dynamic
|
||||
* @ClassName: PtqnanalysisDynamic
|
||||
* @Description: 商品报价分析(折线图)
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class PtqnanalysisDynamic extends AbstractBillPlugIn {
|
||||
@Override
|
||||
public void afterCreateNewData(EventObject e) {
|
||||
PointLineChart pointLineChart = this.getControl("yem_pointlinechartap");
|
||||
PointLineChartHelper pointLineChartHelper = new PointLineChartHelper();
|
||||
pointLineChartHelper.drawChart(pointLineChart);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PointLineChartHelper {
|
||||
public void drawChart(PointLineChart pointLineChart) {
|
||||
|
||||
boolean isX = true;
|
||||
|
||||
// 创建分类轴,X轴方式展现
|
||||
Axis categoryAxis = this.createCategoryAxis(pointLineChart, "月度", isX);
|
||||
|
||||
// 设置分类轴nametextstyle属性,
|
||||
Map<String, Object> nametextstyle = new HashMap<>();
|
||||
nametextstyle.put("color", "#000000");
|
||||
// nametextstyle.put("fontStyle", "italic");
|
||||
nametextstyle.put("fontSize", 18);
|
||||
categoryAxis.setPropValue("nameTextStyle", nametextstyle);
|
||||
|
||||
// 设置分类轴名称位置属性,end表示在最后
|
||||
categoryAxis.setPropValue("nameLocation", new String("end"));
|
||||
|
||||
// 设置分类轴分类值显示位置,bottom表示在下
|
||||
categoryAxis.setPropValue("position", "bottom");
|
||||
// 设置分类轴分类值liaxisLabel属性
|
||||
Map<String, Object> axislabel = new HashMap<>();
|
||||
Map<String, Object> textstyle = new HashMap<>();
|
||||
textstyle.put("color", "#000000");
|
||||
textstyle.put("fontSize", "16");
|
||||
axislabel.put("textStyle", textstyle);
|
||||
categoryAxis.setPropValue("axisLabel", axislabel);
|
||||
|
||||
// 创建数据轴,name为其名字。
|
||||
Axis ValueAxis = this.createValueAxis(pointLineChart, "千(元)", !isX);
|
||||
// 设置数据轴的nameTextStyle属性
|
||||
Map<String, Object> yAxisnametextstyle = new HashMap<>();
|
||||
yAxisnametextstyle.put("color", "#000000");
|
||||
yAxisnametextstyle.put("fontSize", 18);
|
||||
// yAxisnametextstyle.put("fontStyle", "oblique");
|
||||
ValueAxis.setPropValue("nameTextStyle", yAxisnametextstyle);
|
||||
|
||||
// 设置分类轴数据
|
||||
categoryAxis.setCategorys(contructCatetoryData());
|
||||
|
||||
// 创建折线并赋值
|
||||
this.createLineSeries(pointLineChart, "最高价", contructValueData(), "red");
|
||||
|
||||
// 创建多个折线按如下方式添加
|
||||
this.createLineSeries(pointLineChart, "最低价", contructValue2Data(), "#0000CD");
|
||||
List<BigDecimal> list = new ArrayList<>();
|
||||
list.add(new BigDecimal(3000));
|
||||
list.add(new BigDecimal(3500));
|
||||
list.add(new BigDecimal(2800));
|
||||
list.add(new BigDecimal(2700));
|
||||
list.add(new BigDecimal(3100));
|
||||
list.add(new BigDecimal(3000));
|
||||
|
||||
|
||||
this.createLineSeries(pointLineChart,"平均价",list , "#282828");
|
||||
|
||||
// 设置图的边距
|
||||
pointLineChart.setMargin(Position.right, "80px");
|
||||
pointLineChart.setMargin(Position.top, "80px");
|
||||
pointLineChart.setMargin(Position.left, "80px");
|
||||
pointLineChart.setShowLegend(true);
|
||||
// 设置图例的位置
|
||||
pointLineChart.setLegendPropValue("top", "8%");
|
||||
// 设置图例中文字的字体大小和颜色等
|
||||
Map<String, Object> legendtextstyle = new HashMap<>();
|
||||
legendtextstyle.put("fontSize", 18);
|
||||
legendtextstyle.put("color", "#000000");
|
||||
pointLineChart.setLegendPropValue("textStyle", legendtextstyle);
|
||||
|
||||
// 刷新图标
|
||||
pointLineChart.refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建类目型坐标轴
|
||||
*
|
||||
* @param name
|
||||
* 坐标轴名称
|
||||
* @param isx
|
||||
* 是否X轴,ture创建X轴,false创建Y轴
|
||||
*/
|
||||
private Axis createCategoryAxis(PointLineChart pointLineChart, String name, boolean isx) {
|
||||
Axis axis = null;
|
||||
if (isx)
|
||||
axis = pointLineChart.createXAxis(name, AxisType.category);
|
||||
else
|
||||
axis = pointLineChart.createYAxis(name, AxisType.category);
|
||||
|
||||
// 创建一个map存储x轴的复杂属性的属性-值对
|
||||
Map<String, Object> axisTick = new HashMap<>();
|
||||
axisTick.put("interval", Integer.valueOf(0));
|
||||
|
||||
axisTick.put("show", true);
|
||||
axisTick.put("grid", Position.left);
|
||||
axis.setPropValue("axisTick", axisTick);
|
||||
return axis;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建值类型坐标轴
|
||||
*
|
||||
* @param name
|
||||
* 坐标轴名称
|
||||
* @param isx
|
||||
* 是否X轴,ture创建X轴,false创建Y轴
|
||||
*/
|
||||
private Axis createValueAxis(PointLineChart pointLineChart, String name, boolean isx) {
|
||||
Axis axis = null;
|
||||
if (isx)
|
||||
axis = pointLineChart.createXAxis(name, AxisType.value);
|
||||
else
|
||||
axis = pointLineChart.createYAxis(name, AxisType.value);
|
||||
|
||||
// 创建一个map存储y轴的复杂属性的属性-值对
|
||||
Map<String, Object> axisTick = new HashMap<>();
|
||||
axisTick.put("show", true);
|
||||
axis.setPropValue("axisTick", axisTick);
|
||||
|
||||
// 创建一个map存储y轴的复杂属性的属性-值对
|
||||
Map<String, Object> splitLine = new HashMap<>();
|
||||
Map<String, Object> lineStyle = new HashMap<>();
|
||||
lineStyle.put("type", "dotted");
|
||||
lineStyle.put("color", "#E2E2E2");
|
||||
splitLine.put("lineStyle", lineStyle);
|
||||
axis.setPropValue("splitLine", splitLine);
|
||||
pointLineChart.setShowTooltip(true);
|
||||
return axis;
|
||||
}
|
||||
|
||||
private List<String> contructCatetoryData() {
|
||||
|
||||
// 此处需修改成实际分类数据,以下为案例数据
|
||||
List<String> categoryData = new ArrayList<>();
|
||||
categoryData.add("2019.1");
|
||||
categoryData.add("2019.2");
|
||||
categoryData.add("2019.3");
|
||||
categoryData.add("2019.4");
|
||||
categoryData.add("2019.5");
|
||||
categoryData.add("2019.6");
|
||||
return categoryData;
|
||||
};
|
||||
|
||||
private List<BigDecimal> contructValueData() {
|
||||
|
||||
// 此处需添加实际数构建,以下为案例数据
|
||||
List<BigDecimal> valueData = new ArrayList<>();
|
||||
|
||||
valueData.add(new BigDecimal(2566));
|
||||
valueData.add(new BigDecimal(1552));
|
||||
valueData.add(new BigDecimal(3786));
|
||||
valueData.add(new BigDecimal(2865));
|
||||
valueData.add(new BigDecimal(4098));
|
||||
valueData.add(new BigDecimal(7834));
|
||||
|
||||
return valueData;
|
||||
}
|
||||
|
||||
private List<BigDecimal> contructValue2Data() {
|
||||
|
||||
// 此处需添加实际数构建,以下为案例数据
|
||||
List<BigDecimal> valueData = new ArrayList<>();
|
||||
|
||||
valueData.add(new BigDecimal(934));
|
||||
valueData.add(new BigDecimal(1035));
|
||||
valueData.add(new BigDecimal(2342));
|
||||
valueData.add(new BigDecimal(2274));
|
||||
valueData.add(new BigDecimal(5067));
|
||||
valueData.add(new BigDecimal(6654));
|
||||
|
||||
return valueData;
|
||||
}
|
||||
|
||||
// 创建折线
|
||||
private void createLineSeries(PointLineChart pointLineChart, String name, List<BigDecimal> values, String color) {
|
||||
// 折线的名字
|
||||
LineSeries expireSeries = pointLineChart.createSeries(name);
|
||||
|
||||
// 设置折线上文本的相关属性
|
||||
Label label = new Label();
|
||||
label.setShow(true);
|
||||
label.setColor("#000000");
|
||||
expireSeries.setLabel(label);
|
||||
// 连线颜色
|
||||
expireSeries.setItemColor(color);
|
||||
// 动画效果
|
||||
expireSeries.setAnimationDuration(2000);
|
||||
// 该点纵坐标的值setData(Number[] data)
|
||||
expireSeries.setData((Number[]) values.toArray(new Number[0]));
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package yem.wmc.ydn.formplugin.dynamic;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
|
||||
import java.util.EventObject;
|
||||
|
||||
/**
|
||||
* @Author zlp
|
||||
* @Date 2024/12/24 16:02
|
||||
* @PackageName:yem.wmc.ydn.formplugin.dynamic
|
||||
* @ClassName: RepresentativeDynamic
|
||||
* @Description: zlp 代办统计卡片 表单插件
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class RepresentativeDynamic extends AbstractFormPlugin {
|
||||
@Override
|
||||
public void afterCreateNewData(EventObject e) {
|
||||
DynamicObject[] yem_ffm_inquiryWait = BusinessDataServiceHelper.load("yem_ffm_inquiry", "yem_supquonum,billstatus",
|
||||
new QFilter[]{
|
||||
new QFilter("billstatus", QCP.equals, "C"),
|
||||
// new QFilter("yem_supquonum", QCP.less_equals, 0)
|
||||
});
|
||||
DynamicObject[] yem_ffm_inquiryIn = BusinessDataServiceHelper.load("yem_ffm_inquiry", "yem_supquonum,billstatus",
|
||||
new QFilter[]{
|
||||
new QFilter("billstatus", QCP.equals, "C"),
|
||||
new QFilter("yem_supquonum", QCP.large_than, 0)
|
||||
});
|
||||
this.getModel().setValue("yem_pendingquotation",yem_ffm_inquiryWait.length);
|
||||
this.getModel().setValue("yem_inthequotation",yem_ffm_inquiryIn.length);
|
||||
}
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
package yem.wmc.ydn.formplugin.dynamic;
|
||||
|
||||
import kd.bos.bill.AbstractBillPlugIn;
|
||||
import kd.bos.form.chart.*;
|
||||
import kd.bos.form.control.Control;
|
||||
import kd.bos.form.control.events.ChartClickEvent;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author zlp
|
||||
* @Date 2024/12/24 17:32
|
||||
* @PackageName:yem.wmc.ydn.formplugin.dynamic
|
||||
* @ClassName: TnpnanalysisDynamic
|
||||
* @Description: 成交占比分析(横向柱状图)
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class TnpnanalysisDynamic extends AbstractBillPlugIn {
|
||||
|
||||
@Override
|
||||
public void click(EventObject evt) {
|
||||
String key = ((Control)evt.getSource()).getKey();
|
||||
if (key.equals("yem_histogramchartap")) {
|
||||
ChartClickEvent e = (ChartClickEvent)evt;
|
||||
this.getView().showMessage("SeriesName:" + e.getSeriesName() + "; Name: " + e.getName() + "; Value: " + e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCreateNewData(EventObject e) {
|
||||
Control _barchart = this.getControl("yem_histogramchartap");
|
||||
if (_barchart instanceof HistogramChart) {
|
||||
HistogramChart barchart = (HistogramChart) _barchart;
|
||||
// boolean isShowTitle = true;
|
||||
// barchart.setShowTitle(isShowTitle);
|
||||
boolean isShowLegend = true;
|
||||
barchart.setShowLegend(isShowLegend);
|
||||
boolean isLegendVertical = true;
|
||||
barchart.setLegendVertical(isLegendVertical);
|
||||
barchart.setShowTooltip(true);
|
||||
// 设置两个图例:支出,收入
|
||||
// Map<String, Object> legendData = new HashMap<>();
|
||||
// String[] data = {"支出", "收入"};
|
||||
// legendData.put("data", data);
|
||||
// barchart.setLegendPropValue("legend",legendData);
|
||||
|
||||
// 设置图例位置为中上
|
||||
barchart.setLegendAlign(XAlign.center, YAlign.top);
|
||||
// Map<String, Object> titlePropValue = new HashMap<>();// 主标题内容:text
|
||||
// titlePropValue.put("text", "条形图");
|
||||
|
||||
// 副标题内容:subtext
|
||||
// titlePropValue.put("subtext", "barchart");
|
||||
|
||||
// 点击副标题跳转的超链接:sublink
|
||||
// titlePropValue.put("sublink", "https://www.echartsjs.com/examples/zh/index.html#chart-type-bar");
|
||||
// barchart.setTitlePropValue("title", titlePropValue);
|
||||
|
||||
// 设置触发提示框的类型为axis:坐标轴触发
|
||||
// barchart.addTooltip("trigger", "axis");
|
||||
|
||||
// 设置指示器配置项为阴影,更多配置参考echarts官网再添加相应的参数即可
|
||||
// Map<String, Object> axisPointType = new HashMap<>();
|
||||
// axisPointType.put("type", "shadow");
|
||||
// barchart.addTooltip("axisPointer", axisPointType);
|
||||
|
||||
// 设置提示框浮层内容格式器,参数含义可查阅echarts官网,这里不一一列举
|
||||
// 字符串模板格式
|
||||
// List<Object> toolTipFuncPath = new ArrayList<>();
|
||||
// String formatter = "{b0}: {c0}<br />{b1}: {c1}";
|
||||
// barchart.addTooltip("formatter", formatter);
|
||||
// toolTipFuncPath.add("tooltip");
|
||||
// toolTipFuncPath.add("formatter");
|
||||
// barchart.addFuncPath(toolTipFuncPath);
|
||||
//
|
||||
//// 回调函数模式
|
||||
// List<Object> toolTipFuncPaths = new ArrayList<>();
|
||||
// String formatters = "function(param){if(param.dataIndex===0){return 'placeholder0';} if(param.dataIndex==1){return 'placeholder1';}if(param.dataIndex==2){return 'placeholder2'}}";
|
||||
// barchart.addTooltip("formatter", formatters);
|
||||
// toolTipFuncPath.add("tooltip");
|
||||
// toolTipFuncPath.add("formatter");
|
||||
// barchart.addFuncPath(toolTipFuncPath);
|
||||
|
||||
|
||||
// 设置X轴的坐标轴名称为日期,类型为category(类目),Y轴的名称为总量,类型为value
|
||||
Axis x = barchart.createXAxis("日期", AxisType.value);
|
||||
Axis y = barchart.createYAxis("总量",AxisType.category);
|
||||
|
||||
// 设置X轴类目数据(如果没有设置,则需要再series中设置)
|
||||
String[] datas = {"周一", "周二", "周三", "周四", "周五", "周六", "周日"};
|
||||
y.setPropValue("data", datas);
|
||||
|
||||
// 坐标轴刻度标签文字相关设置,格式化刻度标签显示内容
|
||||
// Map<String, Object> datad = new HashMap<>();
|
||||
// String dataFormatter = "function (params) {var level = placeholder0;var date = placeholder1;var job = placeholder2;return '职级:' + level[params[0].dataIndex] + '<br />' + '职级时长:' + date[params[0].dataIndex] + '<br />' + '职位:' + job[params[0].dataIndex];}";
|
||||
// datad.put("formatter", dataFormatter);
|
||||
// x.setPropValue("axisLabel", datad);
|
||||
|
||||
// 坐标轴刻度相关设置,设置是否显示坐标轴刻度
|
||||
// Map<String, Object> axisTick = new HashMap<>();
|
||||
// axisTick.put("show", false);
|
||||
// x.setPropValue("axisTick", axisTick);
|
||||
//
|
||||
//// 坐标轴线相关设置,设置坐标轴箭头样式
|
||||
// Map<String, Object> axisLine = new HashMap<>();
|
||||
// String[] symbolArr = {"none", "arrow"};
|
||||
// axisLine.put("symbol", symbolArr);
|
||||
// x.setPropValue("axisLine", axisLine);
|
||||
//
|
||||
//// 坐标轴在grid区域中的分隔线相关设置,设置分隔线不显示
|
||||
// Map<String, Object> splitLine = new HashMap<>();
|
||||
// splitLine.put("show", false);
|
||||
// x.setPropValue("splitLine", splitLine);
|
||||
// 创建系列为“辅助”的系列
|
||||
BarSeries barseries = barchart.createSeries("合同");
|
||||
Label label = new Label();
|
||||
label.setShow(false);
|
||||
barseries.setLabel(label);
|
||||
// 设置系列名称,用于tooltip的显示,legend 的图例筛选.
|
||||
barseries.setName("合同金额");
|
||||
|
||||
// 设置数据堆叠,同个类目轴上系列配置相同的stack值可以堆叠放置
|
||||
barseries.setStack("产品");
|
||||
|
||||
// 设置系列中数据的内容
|
||||
Number[] numbers = {1, 2, 3, 4, 5, 6};
|
||||
barseries.setData(numbers);
|
||||
|
||||
// 设置柱条颜色(直接设置颜色值和渐变设置)
|
||||
barseries.setColor("#000000");
|
||||
|
||||
BarSeries barseries2 = barchart.createSeries("询价单");
|
||||
Label label2 = new Label();
|
||||
label2.setShow(false);
|
||||
barseries2.setLabel(label);
|
||||
|
||||
// 设置系列名称,用于tooltip的显示,legend 的图例筛选.
|
||||
barseries2.setName("询价单金额");
|
||||
|
||||
// 设置数据堆叠,同个类目轴上系列配置相同的stack值可以堆叠放置
|
||||
barseries2.setStack("产品");
|
||||
|
||||
// 设置系列中数据的内容
|
||||
Number[] numbers2 = {5, 6, 7, 8, 9, 9};
|
||||
barseries2.setData(numbers2);
|
||||
|
||||
// 设置柱条颜色(直接设置颜色值和渐变设置)
|
||||
barseries2.setColor("#FFC107");
|
||||
// barseries.setColor("new echarts.graphic.LinearGradient(0, 0, 1, 0, [{offset: 0, color: '[#B177FF](http://fd.kingdee.com:9001/?key=%23B177FF)' },{offset: 1, color: '[#828FFF](http://fd.kingdee.com:9001/?key=%23828FFF)'}], false)");
|
||||
// barchart.setMerge(true);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user