|
@@ -1,5 +1,6 @@
|
|
|
package com.lc.ibps.components.verification.excel;
|
|
package com.lc.ibps.components.verification.excel;
|
|
|
|
|
|
|
|
|
|
+import com.lc.ibps.components.poi.excel.entity.params.ExcelExportEntity;
|
|
|
import com.lc.ibps.components.verification.funcs.xValue;
|
|
import com.lc.ibps.components.verification.funcs.xValue;
|
|
|
import com.lc.ibps.components.verification.model.InspectionItemVO;
|
|
import com.lc.ibps.components.verification.model.InspectionItemVO;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
@@ -10,9 +11,10 @@ import org.openxmlformats.schemas.drawingml.x2006.chart.*;
|
|
|
import org.openxmlformats.schemas.drawingml.x2006.main.STSchemeColorVal;
|
|
import org.openxmlformats.schemas.drawingml.x2006.main.STSchemeColorVal;
|
|
|
|
|
|
|
|
public class CreateExcelScatterChart {
|
|
public class CreateExcelScatterChart {
|
|
|
- public static void create(Sheet sheet, InspectionItemVO item) {
|
|
|
|
|
-
|
|
|
|
|
|
|
+ public static void createLRE(Sheet sheet, InspectionItemVO item) {
|
|
|
|
|
+ ExcelExportEntity entity = new ExcelExportEntity("图表", "chart");
|
|
|
Row row = sheet.createRow(sheet.getLastRowNum() + 1);
|
|
Row row = sheet.createRow(sheet.getLastRowNum() + 1);
|
|
|
|
|
+
|
|
|
for (int i = 0; i < item.getItemCalcVO().getTargetValue().length; i++) {
|
|
for (int i = 0; i < item.getItemCalcVO().getTargetValue().length; i++) {
|
|
|
final xValue value = item.getItemCalcVO().getTargetValue()[i];
|
|
final xValue value = item.getItemCalcVO().getTargetValue()[i];
|
|
|
Cell cell = row.createCell(i);
|
|
Cell cell = row.createCell(i);
|
|
@@ -32,12 +34,13 @@ public class CreateExcelScatterChart {
|
|
|
row.setZeroHeight(true);
|
|
row.setZeroHeight(true);
|
|
|
|
|
|
|
|
row = sheet.createRow(sheet.getLastRowNum() + 1);
|
|
row = sheet.createRow(sheet.getLastRowNum() + 1);
|
|
|
|
|
+ row.setHeight((short) (entity.getHeight() * 50));
|
|
|
Cell cell = row.createCell(0);
|
|
Cell cell = row.createCell(0);
|
|
|
cell.setCellValue("线性回归图");
|
|
cell.setCellValue("线性回归图");
|
|
|
cell.setCellType(CellType.STRING);
|
|
cell.setCellType(CellType.STRING);
|
|
|
|
|
|
|
|
Drawing<?> drawing = sheet.createDrawingPatriarch();
|
|
Drawing<?> drawing = sheet.createDrawingPatriarch();
|
|
|
- ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, sheet.getLastRowNum() + 1, 6, sheet.getLastRowNum() + 16);
|
|
|
|
|
|
|
+ ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, sheet.getLastRowNum() + 1, 6, sheet.getLastRowNum() + 9);
|
|
|
|
|
|
|
|
Chart chart = drawing.createChart(anchor);
|
|
Chart chart = drawing.createChart(anchor);
|
|
|
ChartLegend legend = chart.getOrCreateLegend();
|
|
ChartLegend legend = chart.getOrCreateLegend();
|
|
@@ -74,10 +77,85 @@ public class CreateExcelScatterChart {
|
|
|
final CTTrendline trendline = ctChart.getPlotArea().getScatterChartArray(0).getSerArray(0)
|
|
final CTTrendline trendline = ctChart.getPlotArea().getScatterChartArray(0).getSerArray(0)
|
|
|
.addNewTrendline();
|
|
.addNewTrendline();
|
|
|
trendline.addNewDispRSqr().setVal(true);
|
|
trendline.addNewDispRSqr().setVal(true);
|
|
|
- trendline.addNewIntercept().setVal(0.1767);
|
|
|
|
|
|
|
+ trendline.addNewIntercept().setVal(item.getItemCalcVO().getA().getDoub());
|
|
|
trendline.addNewDispEq().setVal(true);
|
|
trendline.addNewDispEq().setVal(true);
|
|
|
trendline.addNewSpPr().addNewLn().addNewSolidFill().addNewSchemeClr().setVal(STSchemeColorVal.Enum.forInt(5));
|
|
trendline.addNewSpPr().addNewLn().addNewSolidFill().addNewSchemeClr().setVal(STSchemeColorVal.Enum.forInt(5));
|
|
|
trendline.addNewTrendlineType()
|
|
trendline.addNewTrendlineType()
|
|
|
.setVal(org.openxmlformats.schemas.drawingml.x2006.chart.STTrendlineType.LINEAR);
|
|
.setVal(org.openxmlformats.schemas.drawingml.x2006.chart.STTrendlineType.LINEAR);
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < 8; i++) {
|
|
|
|
|
+
|
|
|
|
|
+ row = sheet.createRow(sheet.getLastRowNum() + 1);
|
|
|
|
|
+ row.setHeight((short) (entity.getHeight() * 50));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static void createVarianceChart(Sheet sheet, InspectionItemVO item) {
|
|
|
|
|
+ ExcelExportEntity entity = new ExcelExportEntity("图表", "chart");
|
|
|
|
|
+ Row row = sheet.createRow(sheet.getLastRowNum() + 1);
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < item.getItemCalcVO().getTargetValue().length; i++) {
|
|
|
|
|
+ final xValue value = item.getItemCalcVO().getTargetValue()[i];
|
|
|
|
|
+ Cell cell = row.createCell(i);
|
|
|
|
|
+ cell.setCellValue(value.getDoub());
|
|
|
|
|
+ cell.setCellType(CellType.NUMERIC);
|
|
|
|
|
+ }
|
|
|
|
|
+ row.setZeroHeight(true);
|
|
|
|
|
+ int rowNum = row.getRowNum();
|
|
|
|
|
+
|
|
|
|
|
+ row = sheet.createRow(sheet.getLastRowNum() + 1);
|
|
|
|
|
+ for (int i = 0; i < item.getItemCalcVO().getSpecimensValue().length; i++) {
|
|
|
|
|
+ final xValue value = item.getItemCalcVO().getSpecimensValue()[i];
|
|
|
|
|
+ Cell cell = row.createCell(i);
|
|
|
|
|
+ cell.setCellValue(item.getRecord().get(item.getConfig().getSpecimensName()[i]).getRelDev().getDoub());
|
|
|
|
|
+ cell.setCellType(CellType.NUMERIC);
|
|
|
|
|
+ }
|
|
|
|
|
+ row.setZeroHeight(true);
|
|
|
|
|
+
|
|
|
|
|
+ row = sheet.createRow(sheet.getLastRowNum() + 1);
|
|
|
|
|
+ row.setHeight((short) (entity.getHeight() * 50));
|
|
|
|
|
+ Cell cell = row.createCell(0);
|
|
|
|
|
+ cell.setCellValue("差异图");
|
|
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
|
|
+
|
|
|
|
|
+ Drawing<?> drawing = sheet.createDrawingPatriarch();
|
|
|
|
|
+ ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, sheet.getLastRowNum() + 1, 6, sheet.getLastRowNum() + 9);
|
|
|
|
|
+
|
|
|
|
|
+ Chart chart = drawing.createChart(anchor);
|
|
|
|
|
+ ChartLegend legend = chart.getOrCreateLegend();
|
|
|
|
|
+ legend.setPosition(LegendPosition.TOP_RIGHT);
|
|
|
|
|
+
|
|
|
|
|
+ ScatterChartData data = chart.getChartDataFactory().createScatterChartData();
|
|
|
|
|
+
|
|
|
|
|
+ ValueAxis bottomAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.BOTTOM);
|
|
|
|
|
+ ValueAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);
|
|
|
|
|
+
|
|
|
|
|
+ leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);
|
|
|
|
|
+ bottomAxis.setCrosses(AxisCrosses.AUTO_ZERO);
|
|
|
|
|
+ ChartDataSource<Number> xs = DataSources.fromNumericCellRange(sheet, new CellRangeAddress(rowNum, rowNum, 0, item.getConfig().getSpecimensNum()-1));
|
|
|
|
|
+ ChartDataSource<Number> ys = DataSources.fromNumericCellRange(sheet, new CellRangeAddress(rowNum+1, rowNum+1, 0, item.getConfig().getSpecimensNum()-1));
|
|
|
|
|
+
|
|
|
|
|
+ ScatterChartSeries chartSeries = data.addSerie(xs, ys);
|
|
|
|
|
+ chartSeries.setTitle("差异图");
|
|
|
|
|
+ chart.plot(data, bottomAxis, leftAxis);
|
|
|
|
|
+
|
|
|
|
|
+ final CTChart ctChart = ((XSSFChart) chart).getCTChart();
|
|
|
|
|
+ ctChart.unsetLegend();
|
|
|
|
|
+ ctChart.getPlotVisOnly().setVal(false);
|
|
|
|
|
+ //set line properties of first scatter chart data serie to no fill:
|
|
|
|
|
+ CTScatterSer[] scatterChartSeries = ctChart.getPlotArea().getScatterChartArray(0).getSerArray();
|
|
|
|
|
+ for (int i = 0; i < scatterChartSeries.length; i++) {
|
|
|
|
|
+ scatterChartSeries[i].addNewSpPr().addNewLn().addNewNoFill();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for(CTValAx ax: ctChart.getPlotArea().getValAxList()){
|
|
|
|
|
+ ax.addNewMajorGridlines();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < 8; i++) {
|
|
|
|
|
+
|
|
|
|
|
+ row = sheet.createRow(sheet.getLastRowNum() + 1);
|
|
|
|
|
+ row.setHeight((short) (entity.getHeight() * 50));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|