From fed98c0dad5ecc6db8f4b7f5f125324b6ff61ae9 Mon Sep 17 00:00:00 2001 From: ublue Date: Fri, 18 Sep 2020 17:44:31 +0800 Subject: [PATCH] gzq --- .../codesdream/ase/model/chart/BarChart.java | 11 ++ .../com/codesdream/ase/model/chart/Chart.java | 13 +++ .../codesdream/ase/model/chart/FanChart.java | 8 ++ .../com/codesdream/ase/model/chart/Form.java | 9 ++ .../codesdream/ase/model/chart/LineChart.java | 9 ++ .../codesdream/ase/service/ParentService.java | 2 +- .../codesdream/ase/service/VisualService.java | 106 ++++++++++++++++++ 7 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/codesdream/ase/model/chart/BarChart.java create mode 100644 src/main/java/com/codesdream/ase/model/chart/Chart.java create mode 100644 src/main/java/com/codesdream/ase/model/chart/FanChart.java create mode 100644 src/main/java/com/codesdream/ase/model/chart/Form.java create mode 100644 src/main/java/com/codesdream/ase/model/chart/LineChart.java create mode 100644 src/main/java/com/codesdream/ase/service/VisualService.java diff --git a/src/main/java/com/codesdream/ase/model/chart/BarChart.java b/src/main/java/com/codesdream/ase/model/chart/BarChart.java new file mode 100644 index 0000000..581af71 --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/chart/BarChart.java @@ -0,0 +1,11 @@ +package com.codesdream.ase.model.chart; +import java.lang.String; +import java.util.List; + + + +public class BarChart extends Chart{ + public String[] x; + public String xname; + public String yname; +} diff --git a/src/main/java/com/codesdream/ase/model/chart/Chart.java b/src/main/java/com/codesdream/ase/model/chart/Chart.java new file mode 100644 index 0000000..98e26c4 --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/chart/Chart.java @@ -0,0 +1,13 @@ +package com.codesdream.ase.model.chart; +import java.util.List; +import java.lang.String; +import lombok.Data; + +@Data +public class Chart{ + public double[] y; + public String title; +} + + + diff --git a/src/main/java/com/codesdream/ase/model/chart/FanChart.java b/src/main/java/com/codesdream/ase/model/chart/FanChart.java new file mode 100644 index 0000000..de615ca --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/chart/FanChart.java @@ -0,0 +1,8 @@ +package com.codesdream.ase.model.chart; +import java.util.*; +import java.lang.String; + +public class FanChart extends Chart{ + + public String[] x; +} \ No newline at end of file diff --git a/src/main/java/com/codesdream/ase/model/chart/Form.java b/src/main/java/com/codesdream/ase/model/chart/Form.java new file mode 100644 index 0000000..a5d17ac --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/chart/Form.java @@ -0,0 +1,9 @@ +package com.codesdream.ase.model.chart; +import java.lang.String; + + +public class Form { + public String title; + public String[][] body; + +} diff --git a/src/main/java/com/codesdream/ase/model/chart/LineChart.java b/src/main/java/com/codesdream/ase/model/chart/LineChart.java new file mode 100644 index 0000000..b969f2a --- /dev/null +++ b/src/main/java/com/codesdream/ase/model/chart/LineChart.java @@ -0,0 +1,9 @@ +package com.codesdream.ase.model.chart; +import java.lang.String; +import java.util.List; + +public class LineChart extends Chart{ + public double[] x; + public String xname; + public String yname; +} \ No newline at end of file diff --git a/src/main/java/com/codesdream/ase/service/ParentService.java b/src/main/java/com/codesdream/ase/service/ParentService.java index 5556703..12cbc64 100644 --- a/src/main/java/com/codesdream/ase/service/ParentService.java +++ b/src/main/java/com/codesdream/ase/service/ParentService.java @@ -33,7 +33,7 @@ public class ParentService { * @param studentId 学生ID * @param parentId 家长id,一般为家长的电话 * @param parentName 家长姓名 - * @return 创建的家长实体 + * @return 创建的家长 */ public Parent createParent(int studentId, int parentId, String parentName){ diff --git a/src/main/java/com/codesdream/ase/service/VisualService.java b/src/main/java/com/codesdream/ase/service/VisualService.java new file mode 100644 index 0000000..32614fd --- /dev/null +++ b/src/main/java/com/codesdream/ase/service/VisualService.java @@ -0,0 +1,106 @@ +package com.codesdream.ase.service; +import com.codesdream.ase.exception.innerservererror.InvalidDataException; +import com.codesdream.ase.model.chart.BarChart; +import com.codesdream.ase.model.chart.LineChart; +import com.codesdream.ase.model.chart.FanChart; +import com.codesdream.ase.model.chart.Chart; +import com.codesdream.ase.model.chart.Form; +import org.springframework.stereotype.Service; +import java.lang.*; + +@Service + +public class VisualService { + + + /** + * 用于创建条形统计图的数据表 + * @author gzq + * @param data 一个表格,第一行为x,第二行为y,(只有两行,每行列数相同,类型为string) + * @param xname x坐标名称 + * @param yname y坐标名称 + * @return 创建的数据表对象 + */ + public BarChart createBarChart(Form data,String xname,String yname){ + BarChart r=new BarChart(); + r.title= data.title; + r.xname=xname; + r.yname=yname; + + if(data.body.length!=2){ + throw new InvalidDataException( "表格行数只能为2"); + } + int len=data.body[0].length; + try{ + for(int i=0;i