精华内容
下载资源
问答
  • 列表统计图插件是指数据列表和统计图表在一个界面上显示,类似EXCEL式统计图功能。 是一般查询插件和一般统计插件的功能结合。本插件只要用语句统计列表数据,统计图会自动根据列表数据形成,列表数据和统计图在...
    定义

    列表和统计图插件是指数据列表和统计图表在一个界面上显示,类似EXCEL式统计图功能。
    是一般查询插件和一般统计插件的功能结合。本插件只要用语句统计列表数据,统计图会自动根据列表数据形成,列表数据和统计图在同一个界面。
    同一般查询类插件一样,本插件也只需输入一个SQL语句即可完成整个查询统计逻辑、结果列表样式、模块界面样式、查询参数等所有功能。
    可自定义条件进行数据过滤,自定义的条件可以是设置让用户输入的参数,也可将一个日期字段加到条件中,让用户选择数据日期范围进行过滤。
    数据管理方案:可分页、分组(拖动列分组)、排序(点击列头排序)、打印等。可导出数据到EXCEL、PDF等。
    数据查询方案:可设置左侧分类树查询,可简单模糊查询,可自定义条件进行高级查询,可保存查询语句以后再用。
    界面样式方案:左侧分类树和右侧高级查询可收起隐藏,以扩大中间的数据管理界面。

    界面样式

    天纵智能开发平台插件
    展开全文
  • 1 var pageSize = 20;... 5 *点击统计图时,弹出一个窗口,显示统计的详情列表信息, 6 *该方法为项目中所有的统计图共享,参数type是一个字符串,用于区分是哪个统计图调用的 7 */ 8 function showDetai...
      1 var pageSize = 20;//初始化每页数据条数
      2 var winTitle = '';//初始化窗口标题
      3 
      4 /**
      5  *点击统计图时,弹出一个窗口,显示统计的详情列表信息,
      6  *该方法为项目中所有的统计图共享,参数type是一个字符串,用于区分是哪个统计图调用的
      7  */
      8 function showDetails(type){
      9     
     10     setWindowTitle(type);//设置窗口标题
     11     
     12     var panel;
     13     if (type.split("_")[0] == "stdMngStatistics") {
     14         var gridStore = createStore("gridStore", type);//获取数据
     15         loadGridStoreByOrgCodeAndIncludeSubOrgs(gridStore);
     16         gridStore.load(function(){
     17             panel = createGrid(gridStore);//创建面板
     18             showWindow(panel);//显示窗口
     19         });    
     20     }
     21 }
     22 
     23 //设置窗口标题
     24 function setWindowTitle(type){
     25     if(type == "stdMngStatistics"){
     26         winTitle = "规范管理人员";
     27     }
     28 }        
     29 
     30 //设置参数
     31 function loadGridStoreByOrgCodeAndIncludeSubOrgs(gridStore){
     32     var proxy = gridStore.getProxy();
     33     proxy.setExtraParam("orgCode",selectedOrgCode);// 管理机构编码
     34     proxy.setExtraParam("includeSubOrgs",selectedIncludeSubOrgs);// 是否包含下级机构
     35 }
     36 
     37 //获取数据
     38 function createStore(storeId, type){
     39     return new Ext.data.JsonStore({
     40         storeId: storeId,
     41         remoteSort : true,
     42         pageSize : pageSize,
     43         proxy: {
     44             type: 'ajax',
     45             url : baseUrl + '/app/report/statisticsDetails/' + encodeURI(encodeURI(type)),
     46             actionMethods: {
     47                 read : 'POST'
     48             },
     49             reader: {
     50                  type: 'json',
     51                  totalProperty : 'totalElements',
     52                  root: 'content'
     53             },
     54             extraParams:{
     55                 limit : pageSize
     56             },
     57             batchActions : false
     58         },
     59         fields : ['id' , 'ehrId' , 'personName', 'gender', 'birthDate', 'innerCode', 'svcFlwMental' , 'svcFlwCommonDto' ,
     60             'family', 'idNumber', 'homeTel', 'ehrIntegrity' , 'hasAsmYear', 'hasAsmOldS' , 'hasAsmOldA' , 'hasSvcExam1', 'mngOrgName' ,
     61             'dateCreated', 'ehrDetails' , 'hasFirstSoap' , 'hasFlwChronic' , 'hasAsmYear' , 'svcAsmOldS' , 'svcChronicList' , 'svcChronic','hasVSvcFlwChronicWf',
     62             'grHealth', 'grHighRisk' , 'grChronicDisease' , 'grOld' , 'grMaternity' ,
     63             'grChildren','grMentalDisorder','grHandicapped','cdHypertension','cdDiabetesMellitus',
     64             'cdCoronaryDisease','cdCerebralApoplexy','cdOther', 'curContract']
     65     });
     66 }
     67 
     68 //创建面板
     69 function createGrid(gridStore){
     70     var sm = new Ext.selection.RowModel();
     71     return Ext.create('Ext.grid.Panel', {
     72           border : false,
     73         xtype : 'grid',
     74         store : gridStore,
     75         loadMask : true, 
     76         stripeRows : true, 
     77         viewConfig: {
     78             forceFit : true
     79         },
     80         listeners : {
     81             itemdblclick : function(a, b, c, rowindex, e){
     82                 e.preventDefault();
     83                 openModalDialog(baseUrl+'/app/ehr/index/'+gridStore.getAt(rowindex).get('id'));
     84                 gridStore.reload();
     85             }
     86         } ,
     87         selModel : sm,
     88         columns:[
     89             new Ext.grid.RowNumberer({
     90                     header: '序号',
     91                     width: 45,        //序号列宽
     92                     align: 'center'    //序号居中
     93                 }),
     94             {text : '姓名',dataIndex : 'personName', sortable:true },
     95             {text : '性别',dataIndex : 'gender', renderer : genderRenderer ,maxWidth : 60 , sortable:true },
     96             {text : '出生日期',dataIndex : 'birthDate', sortable:true },
     97             {text : '健康分类',dataIndex : 'ehrClassify', renderer : ehrClassifyHealthRenderer, sortable:false},
     98             {text : '人群分类',dataIndex : 'ehrClassify', renderer : ehrClassifyGrRenderer, sortable:false},
     99             {text : '慢病分类',dataIndex : 'ehrClassify', renderer : ehrClassifyCdRenderer, sortable:false},
    100             {text : '签约',dataIndex : 'curContract', maxWidth : 60, renderer : curContractRenderer, sortable:false},
    101             {text : '建档日期',dataIndex : 'dateCreated', sortable:true },
    102             {text : '档案完整度',dataIndex : 'ehrIntegrity', renderer : ehrIntegrityRenderer, sortable:true },
    103             {text : '证件类型' , dataIndex : 'ehrDetails' , hidden : true , renderer : idTypeRenderer, sortable:false},
    104             {text : '证件号码' , dataIndex : 'idNumber' , hidden : true, sortable:false},
    105             {text : '内部建档号',dataIndex : 'innerCode' , hidden : true , sortable:true },
    106             {text : '联系电话',dataIndex : 'homeTel', hidden : true, sortable:false},
    107             {text : '管理机构' , dataIndex : 'mngOrgName' , hidden : true, sortable:false}
    108         ],
    109         bbar : new Ext.PagingToolbar({
    110             store : gridStore,  
    111             displayInfo : true,
    112             showUerItemsBeforeDisplayInfo: true,
    113             displayMsg : "第 {0} - {1} 条  共 {2}条",
    114             emptyMsg : "没有符合条件的记录"
    115         })
    116     });
    117 }
    118 
    119 //显示统计列表窗口
    120 function showWindow(panel){
    121     Ext.create('Ext.window.Window', {
    122         modal :true,    //弹出窗口后,不能对非本窗口内容进行操作
    123         title: winTitle,
    124         constrainHeader:true,    //所有查询统计中弹窗的拖动范围限定
    125         height: 620,
    126         width: 880,
    127         layout : 'fit',
    128         items : [panel]
    129     }).show();
    130 }

     

    展开全文
  • 使用Apache poi生成excel并绘制折线统计图,扇形统计图功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左...

    使用Apache poi生成excel并绘制折线统计图,扇形统计图

    使用Apache poi生成excel并绘制折线统计图,扇形统计图

    1.Gradle dependencies

    	// https://mvnrepository.com/artifact/org.apache.poi/poi
    	compile group: 'org.apache.poi', name: 'poi', version: '4.0.1'
    	// https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml
    	compile group: 'org.apache.poi', name: 'poi-ooxml', version: '4.0.1'
    	// https://mvnrepository.com/artifact/org.projectlombok/lombok
    	compile group: 'org.projectlombok', name: 'lombok', version: '1.18.4'
    

    2.import

    	import java.awt.Color;
    	import java.io.File;
    	import java.io.FileOutputStream;
    	import java.io.IOException;
    	import java.io.OutputStream;
    	import java.util.HashMap;
    	import java.util.List;
    	import java.util.Map;
    	
    	import org.apache.poi.ss.usermodel.BorderStyle;
    	import org.apache.poi.ss.usermodel.Cell;
    	import org.apache.poi.ss.usermodel.FillPatternType;
    	import org.apache.poi.ss.usermodel.Row;
    	import org.apache.poi.ss.util.CellRangeAddress;
    	import org.apache.poi.xddf.usermodel.chart.AxisCrosses;
    	import org.apache.poi.xddf.usermodel.chart.AxisPosition;
    	import org.apache.poi.xddf.usermodel.chart.ChartTypes;
    	import org.apache.poi.xddf.usermodel.chart.LegendPosition;
    	import org.apache.poi.xddf.usermodel.chart.MarkerStyle;
    	import org.apache.poi.xddf.usermodel.chart.XDDFCategoryAxis;
    	import org.apache.poi.xddf.usermodel.chart.XDDFChartLegend;
    	import org.apache.poi.xddf.usermodel.chart.XDDFDataSource;
    	import org.apache.poi.xddf.usermodel.chart.XDDFDataSourcesFactory;
    	import org.apache.poi.xddf.usermodel.chart.XDDFLineChartData;
    	import org.apache.poi.xddf.usermodel.chart.XDDFNumericalDataSource;
    	import org.apache.poi.xddf.usermodel.chart.XDDFValueAxis;
    	import org.apache.poi.xssf.usermodel.XSSFCellStyle;
    	import org.apache.poi.xssf.usermodel.XSSFChart;
    	import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
    	import org.apache.poi.xssf.usermodel.XSSFColor;
    	import org.apache.poi.xssf.usermodel.XSSFDrawing;
    	import org.apache.poi.xssf.usermodel.XSSFFont;
    	import org.apache.poi.xssf.usermodel.XSSFSheet;
    	import org.apache.poi.xssf.usermodel.XSSFWorkbook;
    	import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
    	import org.openxmlformats.schemas.drawingml.x2006.chart.CTBoolean;
    	import org.openxmlformats.schemas.drawingml.x2006.chart.CTChart;
    	import org.openxmlformats.schemas.drawingml.x2006.chart.CTLegend;
    	import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
    	import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumRef;
    	import org.openxmlformats.schemas.drawingml.x2006.chart.CTPieChart;
    	import org.openxmlformats.schemas.drawingml.x2006.chart.CTPieSer;
    	import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
    	import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
    	import org.openxmlformats.schemas.drawingml.x2006.chart.CTStrRef;
    	import org.openxmlformats.schemas.drawingml.x2006.chart.STLegendPos;
    	import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
    	import org.springframework.stereotype.Service;
    	
    	import lombok.extern.slf4j.Slf4j;
    

    3.class

    	public class MyExcleChart2{
    	
    	private static Color titleBackColor = new Color(155,194,230);	//表头背景色
    
    	public static void doWork(List<String> title,List<String> styleList, Map<String, List<Object>> day2ColValueList, File file,
    			String sheetName,XSSFWorkbook wb,int dateNum) throws IOException {
    		OutputStream out = null;
    		try{
    			int sheetIndex = wb.getSheetIndex(sheetName);
    			if(sheetIndex >= 0){
    				wb.removeSheetAt(sheetIndex);
    			}
    			int sheetNum = wb.getNumberOfSheets();
    			XSSFSheet sheet = wb.createSheet();
    			wb.setSheetName(sheetNum, sheetName);
        		out = new FileOutputStream(file);    
    
    			//设置内容样式
        		XSSFCellStyle  style = setBorder(wb);
    			
    			//设置表头字体
    			XSSFFont font = wb.createFont();
    			font.setBold(true);	//加粗
    			//设置表头样式
    			XSSFCellStyle headStyle = setBorder(wb);
    			headStyle.setFillForegroundColor(new XSSFColor(titleBackColor));
    			headStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    			headStyle.setFont(font);
    			
    			//隐藏列
        		hiddenColumn(sheet,sheetName);
    			
    			Row row;
    			Cell cell = null;
    			row = sheet.createRow(0);
    			//写入表头
    			int titleColIndex=0;
                for(String t:title) {
                	cell = row.createCell((short) titleColIndex);
                	cell.setCellValue(t);
                	cell.setCellStyle(headStyle);
                	titleColIndex++;
                } 
                //写入数据
                int rowIndex = 1;
                for(String key:day2ColValueList.keySet()){
                	row = sheet.createRow(rowIndex);
                	
                	List<Object> dataList = day2ColValueList.get(key);
                	cell = row.createCell(0);
                	cell.setCellStyle(style);
                	cell.setCellValue(rowIndex);
                	
                	int cellIndex = 1;
                	for(Object s : dataList){
                		//填充单元格
                		String cellstyle = styleList.get(dataList.indexOf(s)+1);
                		cell = row.createCell(cellIndex);
                		cell.setCellStyle(style);
                		//此处可以对特殊的行进行处理
                		if("speciaRowName".equals(key)&&cellIndex>9){
                			cell = row.createCell(0); cell.setCellStyle(style); cell.setCellValue("speciaRowName");
                			cell = row.createCell(1); cell.setCellStyle(style); cell.setCellValue("");
                			cell = row.createCell(2); cell.setCellStyle(style); cell.setCellValue("");
                			cell = row.createCell(3); cell.setCellStyle(style); cell.setCellValue("");
                			cell = row.createCell(4); cell.setCellStyle(style); cell.setCellValue("");
                			cell = row.createCell(cellIndex); cell.setCellStyle(style); double dble = (double)s; cell.setCellValue(dble);
                		}else if("int".equals(cellstyle)&&null!=s){
                			int num = (int) s;
                			cell.setCellValue(num);
                		}else if("double".equals(cellstyle)&&null!=s){
                			double dble = (double)s;
                			cell.setCellValue(dble);
                		}else{
                			cell.setCellValue(null==s?"":(String)s);
                		}
                		cellIndex ++;
                	}
                	rowIndex ++;
                }
                //绘制图表
                if(day2ColValueList.size()>0){
                	drawChart(sheet, sheetName, day2ColValueList, titleColIndex,dateNum);
                }
                wb.write(out);
    		} catch (Exception e) {
    			e.printStackTrace();
    		} finally {  
    		    try {
    				out.close();
    			} catch (IOException e) {
    				e.printStackTrace();
    			}
    		}  
    	}
    	
    	private static void drawChart(XSSFSheet sheet, String sheetName, Map<String, List<Object>> day2ColValueList,
    			int titleSize,int dateNum) {
    		Map<String, Integer> paramMap = new HashMap<String, Integer>();// 折线图入参
    		Map<String, Object> pieParamMap = new HashMap<String, Object>();// 扇形图入参
    		//此处可以分sheet处理数据
    		if ("sheetname1".equals(sheetName)) {//sheetname1,需要显示折线图和扇形图
    			paramMap.put("numstartcol", 5);
    			paramMap.put("numendcol", 5+dateNum-1);
    			paramMap.put("prostartcol", 5+dateNum);
    			paramMap.put("proendcol", 5+dateNum+dateNum-1);
    			// 业务汇总表,需要统计身份核查、高清人像、银行卡、手机实名四个业务的折线图
    			for (String key : day2ColValueList.keySet()) {
    				if ("类型1业务1".equals(key)) {// 人像比对认证走势折线图
    					// 折线图x轴单位起止列(numstartcol,numendcol),以及计费笔数数据所在行列
    					paramMap.put("col1", 0);
    					paramMap.put("col2", 7);
    					paramMap.put("row1", day2ColValueList.size()+2);
    					paramMap.put("row2", day2ColValueList.size()+19);
    					paramMap.put("numstartrow", 1);
    					paramMap.put("numendrow", 1);
    					paramMap.put("numstartrow2", 2);
    					paramMap.put("numendrow2", 2);
    					// 折线图净收入所在行列
    					paramMap.put("prostartrow", 1);
    					paramMap.put("proendrow", 1);
    					paramMap.put("prostartrow2", 2);
    					paramMap.put("proendrow2", 2);
    					drawLineChart(sheet, "业务1", paramMap);
    				} else if ("类型1业务2".equals(key)) {// 银行卡认证走势折线图
    					paramMap.put("col1", 8);
    					paramMap.put("col2", 15);
    					paramMap.put("row1", day2ColValueList.size()+2);
    					paramMap.put("row2", day2ColValueList.size()+19);
    					paramMap.put("numstartrow", 3);
    					paramMap.put("numendrow", 3);
    					paramMap.put("numstartrow2", 4);
    					paramMap.put("numendrow2", 4);
    					paramMap.put("prostartrow", 3);
    					paramMap.put("proendrow", 3);
    					paramMap.put("prostartrow2", 4);
    					paramMap.put("proendrow2", 4);
    					drawLineChart(sheet, "业务2", paramMap);
    				} 
    			}
    			//柱状图
    			paramMap.put("col1", 15);
    			paramMap.put("col2", 23);
    			paramMap.put("row1", day2ColValueList.size()+2);
    			paramMap.put("row2", day2ColValueList.size()+19);
    			paramMap.put("numstartrow", 1);
    			paramMap.put("numendrow", 1);
    			paramMap.put("prostartrow", 1);
    			paramMap.put("proendrow", 1);
    //			drawBarChart(sheet, "业务1", paramMap);
    			
    			// 扇形图
    			pieParamMap.put("col1", 0);
    			pieParamMap.put("col2", 7);
    			pieParamMap.put("row1", day2ColValueList.size()+20);
    			pieParamMap.put("row2", day2ColValueList.size()+39);
    			pieParamMap.put("data1", "sheetname1!$C$1");
    			pieParamMap.put("data2", "sheetname1!$C$2:$C$3");
    			pieParamMap.put("data3", "sheetname1!$D$2:$D$3");
    			drawPieChart(sheet, "类型1各业务交易量占比", pieParamMap);
    			pieParamMap.put("col1", 8);
    			pieParamMap.put("col2", 15);
    			pieParamMap.put("data3", "sheetname1!$E$2:$E$3");
    			drawPieChart(sheet, "类型1各业务净收入占比", pieParamMap);
    			pieParamMap.put("col1", 0);
    			pieParamMap.put("col2", 7);
    			pieParamMap.put("row1", day2ColValueList.size()+40);
    			pieParamMap.put("row2", day2ColValueList.size()+59);
    			pieParamMap.put("data2", "sheetname1!$C$4:$C$5");
    			pieParamMap.put("data3", "sheetname1!$D$4:$D$5");
    			drawPieChart(sheet, "类型2各业务交易量占比", pieParamMap);
    			pieParamMap.put("col1", 8);
    			pieParamMap.put("col2", 15);
    			pieParamMap.put("data3", "sheetname1!$e$4:$e$5");
    			drawPieChart(sheet, "类型2各业务净收入占比", pieParamMap);
    		} 
    	}
    
    	/**
    	 * 绘制扇形图
    	 * @param sheet sheet
    	 * @param string 标题
    	 * @param paramMap 各种起始截止行列
    	 * col1 col2 row1 row2 图片坐标
    	 * data1  种类划分标志所在列
    	 * data2  各分类名
    	 * data3  各分类数值
    	 */
    	private static void drawPieChart(XSSFSheet sheet, String title, Map<String, Object> pieParamMap) {
    		int col1 = (int) pieParamMap.get("col1");int col2 = (int) pieParamMap.get("col2");
    		int row1 = (int) pieParamMap.get("row1");int row2 = (int) pieParamMap.get("row2");
    		String data1 = (String) pieParamMap.get("data1");
    		String data2 = (String) pieParamMap.get("data2");
    		String data3 = (String) pieParamMap.get("data3");
    		
    		XSSFDrawing drawing = sheet.createDrawingPatriarch();
    		XSSFClientAnchor anchor = (XSSFClientAnchor) drawing.createAnchor(0, 0, 0, 0, col1, row1, col2, row2);
    		
    		XSSFChart chart = drawing.createChart(anchor);
    		chart.setTitleText(title);
    		chart.setTitleOverlay(false);
    
    		CTChart ctChart = ((XSSFChart) chart).getCTChart();
    		CTPlotArea ctPlotArea = ctChart.getPlotArea();
    		CTPieChart ctPieChart = ctPlotArea.addNewPieChart();
    		CTBoolean ctBoolean = ctPieChart.addNewVaryColors();
    		ctBoolean.setVal(true);
    
    		CTPieSer ctPieSer = ctPieChart.addNewSer();
    		CTSerTx ctSerTx = ctPieSer.addNewTx();
    		CTStrRef ctStrRefTx = ctSerTx.addNewStrRef();
    		ctStrRefTx.setF(data1);
    		ctPieSer.addNewIdx().setVal(0);
    		CTAxDataSource cttAxDataSource = ctPieSer.addNewCat();
    		CTStrRef ctStrRef = cttAxDataSource.addNewStrRef();
    		ctStrRef.setF(data2); // 第一行为标题
    		CTNumDataSource ctNumDataSource = ctPieSer.addNewVal();
    		CTNumRef ctNumRef = ctNumDataSource.addNewNumRef();
    		ctNumRef.setF(data3); // 第一行为标题
    
    		ctPieSer.addNewDLbls().addNewShowLeaderLines();// 有无此行代码,图上是否显示文字
    
    		// legend图注
    		CTLegend ctLegend = ctChart.addNewLegend();
    		ctLegend.addNewLegendPos().setVal(STLegendPos.TR);
    		ctLegend.addNewOverlay().setVal(true);
    
    		ctPieSer.addNewExplosion().setVal(1);// 各块之间间隙大小
    		ctPieSer.addNewOrder().setVal(0);//
    
    		CTShapeProperties cTShapeProperties = CTShapeProperties.Factory.newInstance();
    		ctPieSer.addNewSpPr().set(cTShapeProperties);
    	}
    
    	/**
    	 * 绘制折线图
    	 * @param sheet sheet
    	 * @param desc	横轴描述
    	 * @param 各种起始截止行列,包含如下内容:
    	 * 		int numstartrow,int numendrow,int numstartcol,int numendcol,//需要绘图的计费笔数起始截止行列
    			int prostartrow,int proendrow,int prostartcol,int proendcol,//需要绘图的业务净收入起始截止行列
    			int col1,int row1,int row2 //绘图的起始行列
    	 */
    	private static void drawLineChart(XSSFSheet sheet,String desc,Map<String,Integer> paramMap) {
    		int col1 = paramMap.get("col1"),col2 = paramMap.get("col2"), row1=paramMap.get("row1"),row2 = paramMap.get("row2"),//绘图所在坐标,默认宽度为12列
    			//双折线图x轴单位起止列(numstartcol,numendcol),以及第一类数据所在行列	
    			numstartrow = paramMap.get("numstartrow"),numendrow = paramMap.get("numendrow"),numstartcol = paramMap.get("numstartcol"),numendcol = paramMap.get("numendcol"),
    			//双折线图数据2所在行列
    			prostartrow = paramMap.get("prostartrow"),proendrow = paramMap.get("proendrow"),prostartcol = paramMap.get("prostartcol"),proendcol = paramMap.get("proendcol");
    		
    		int dx1=0;
    		int dy1=0;
    		int dx2=0;
    		int dy2=0;
    		XSSFDrawing drawing = sheet.createDrawingPatriarch();
    		XSSFClientAnchor anchor = drawing.createAnchor(dx1, dy1, dx2, dy2, col1, row1, col2, row2);
    
            XSSFChart chart = drawing.createChart(anchor);
            XDDFChartLegend legend = chart.getOrAddLegend();
            legend.setPosition(LegendPosition.TOP_RIGHT);
    
            // Use a category axis for the bottom axis.
            XDDFCategoryAxis bottomAxis = chart.createCategoryAxis(AxisPosition.TOP);//底部X轴
            bottomAxis.setTitle(desc+"交易情况汇总"); // https://stackoverflow.com/questions/32010765
            
            XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT);//左侧Y轴
            leftAxis.setTitle("交易量/金额");
            leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);
            
            XDDFLineChartData leftdata = (XDDFLineChartData) chart.createData(ChartTypes.LINE, bottomAxis, leftAxis);
            
            /填充数据
    		CellRangeAddress cellRangeAddress=new CellRangeAddress(0, 0, numstartcol, numendcol);
    		XDDFDataSource<String> xs = XDDFDataSourcesFactory.fromStringCellRange(sheet, cellRangeAddress);//日期
    		
    		CellRangeAddress dataCellRangeAddress=new CellRangeAddress(numstartrow, numendrow, numstartcol, numendcol);
    		XDDFNumericalDataSource<Double> ys1 = XDDFDataSourcesFactory.fromNumericCellRange(sheet,dataCellRangeAddress);//纵轴为各个数据
            XDDFLineChartData.Series series1 = (XDDFLineChartData.Series) leftdata.addSeries(xs, ys1);
            series1.setTitle("交易量总计(笔)", null); // https://stackoverflow.com/questions/21855842
            series1.setSmooth(false); // https://stackoverflow.com/questions/29014848
            series1.setMarkerStyle(MarkerStyle.DASH); // https://stackoverflow.com/questions/39636138
            
            CellRangeAddress dataCellRangeAddress2=new CellRangeAddress(prostartrow, proendrow,prostartcol,proendcol);
            XDDFNumericalDataSource<Double> ys2 = XDDFDataSourcesFactory.fromNumericCellRange(sheet,dataCellRangeAddress2);//纵轴为各个数据
            XDDFLineChartData.Series series2 = (XDDFLineChartData.Series) leftdata.addSeries(xs, ys2);
            series2.setTitle("收入总计(元)", null); // https://stackoverflow.com/questions/21855842
            series2.setSmooth(false); // https://stackoverflow.com/questions/29014848
            series2.setMarkerStyle(MarkerStyle.DASH); // https://stackoverflow.com/questions/39636138
            
            if(null!=paramMap.get("numstartrow2")&&null!=paramMap.get("numendrow2")&&null!=paramMap.get("prostartrow2")&&null!=paramMap.get("proendrow2")){
    			int numstartrow2 = paramMap.get("numstartrow2"), numendrow2 = paramMap.get("numendrow2"),
    				prostartrow2 = paramMap.get("prostartrow2"), proendrow2 = paramMap.get("proendrow2");
    			series1.setTitle("类型1交易量总计(笔)", null); // https://stackoverflow.com/questions/21855842
    			series2.setTitle("类型1收入总计(元)", null); // https://stackoverflow.com/questions/21855842
    			CellRangeAddress dataCellRangeAddress3=new CellRangeAddress(numstartrow2, numendrow2, numstartcol, numendcol);
    			XDDFNumericalDataSource<Double> ys3 = XDDFDataSourcesFactory.fromNumericCellRange(sheet,dataCellRangeAddress3);//纵轴为各个数据
    	        XDDFLineChartData.Series series3 = (XDDFLineChartData.Series) leftdata.addSeries(xs, ys3);
    	        series3.setTitle("类型2交易量总计(笔)", null); // https://stackoverflow.com/questions/21855842
    	        series3.setSmooth(false); // https://stackoverflow.com/questions/29014848
    	        series3.setMarkerStyle(MarkerStyle.DASH); // https://stackoverflow.com/questions/39636138
    	        
    	        CellRangeAddress dataCellRangeAddress4=new CellRangeAddress(prostartrow2, proendrow2,prostartcol,proendcol);
    	        XDDFNumericalDataSource<Double> ys4 = XDDFDataSourcesFactory.fromNumericCellRange(sheet,dataCellRangeAddress4);//纵轴为各个数据
    	        XDDFLineChartData.Series series4 = (XDDFLineChartData.Series) leftdata.addSeries(xs, ys4);
    	        series4.setTitle("类型2收入总计(元)", null); // https://stackoverflow.com/questions/21855842
    	        series4.setSmooth(false); // https://stackoverflow.com/questions/29014848
    	        series4.setMarkerStyle(MarkerStyle.DASH); // https://stackoverflow.com/questions/39636138
    	        chart.plot(leftdata);
    	        chart.plot(leftdata);  
            }
            chart.plot(leftdata);
            chart.plot(leftdata);
    	}
    	/**
    	 * 柱状图
    	 * @param sheet
    	 * @param desc
    	 * @param paramMap
    	 */
    	
    	private static void drawBarChart(XSSFSheet sheet,String desc,Map<String,Integer> paramMap) {
    		int col1 = paramMap.get("col1"),col2 = paramMap.get("col2"), row1=paramMap.get("row1"),row2 = paramMap.get("row2"),//绘图所在坐标,默认宽度为12列
    				numstartrow = paramMap.get("numstartrow"),numendrow = paramMap.get("numendrow"),numstartcol = paramMap.get("numstartcol"),numendcol = paramMap.get("numendcol"),
    				prostartrow = paramMap.get("prostartrow"),proendrow = paramMap.get("proendrow"),prostartcol = paramMap.get("prostartcol"),proendcol = paramMap.get("proendcol");
    			
    			int dx1=0;
    			int dy1=0;
    			int dx2=0;
    			int dy2=0;
    			XSSFDrawing drawing = sheet.createDrawingPatriarch();
    			XSSFClientAnchor anchor = drawing.createAnchor(dx1, dy1, dx2, dy2, col1, row1, col2, row2);
    
    	        XSSFChart chart = drawing.createChart(anchor);
    	        XDDFChartLegend legend = chart.getOrAddLegend();
    	        legend.setPosition(LegendPosition.TOP_RIGHT);
    
    	        // Use a category axis for the bottom axis.
    	        XDDFCategoryAxis bottomAxis = chart.createCategoryAxis(AxisPosition.TOP);//底部X轴
    	        bottomAxis.setTitle(desc+"交易情况汇总"); // https://stackoverflow.com/questions/32010765
    	        
    	        XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT);//左侧Y轴
    	        leftAxis.setTitle("交易量/金额");
    	        leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);
    	        
    	        XDDFBarChartData data = (XDDFBarChartData) chart.createData(ChartTypes.BAR, bottomAxis, leftAxis);
    			CellRangeAddress cellRangeAddress=new CellRangeAddress(numstartrow, numendrow, numstartcol, numendcol);
    			XDDFDataSource<String> xs = XDDFDataSourcesFactory.fromStringCellRange(sheet, cellRangeAddress);//横轴为第一列日期
    			
    			CellRangeAddress dataCellRangeAddress=new CellRangeAddress(numstartrow, numendrow, numstartcol, numendcol);
    			XDDFNumericalDataSource<Double> ys1 = XDDFDataSourcesFactory.fromNumericCellRange(sheet,dataCellRangeAddress);//纵轴为各个数据
    	        XDDFBarChartData.Series series1 = (XDDFBarChartData.Series) data.addSeries(xs, ys1);
    	        series1.setTitle("交易量总计(笔)", null); // https://stackoverflow.com/questions/21855842
    	        
    	        CellRangeAddress dataCellRangeAddress2=new CellRangeAddress(prostartrow, proendrow,prostartcol,proendcol);
    	        XDDFNumericalDataSource<Double> ys2 = XDDFDataSourcesFactory.fromNumericCellRange(sheet,dataCellRangeAddress2);//纵轴为各个数据
    	        XDDFBarChartData.Series series2 = (XDDFBarChartData.Series) data.addSeries(xs, ys2);
    	        series2.setTitle("收入总计(元)", null); // https://stackoverflow.com/questions/21855842
    /*            
                for(int col=1;col<2;col++) {//数据列数:第一列为日期,其他列为对应数据。
        			CellRangeAddress dataCellRangeAddress=new CellRangeAddress(prostartrow, proendrow, prostartcol, proendcol);
    	            XDDFNumericalDataSource<Double> ys = XDDFDataSourcesFactory.fromNumericCellRange(sheet,dataCellRangeAddress);//纵轴为各个数据
    	            XDDFChartData.Series series1 = data.addSeries(xs, ys);
    	            series1.setTitle("111", null);
                }*/
                chart.plot(data);
                // in order to transform a bar chart into a column chart, you just need to change the bar direction
                XDDFBarChartData bar = (XDDFBarChartData) data;
                bar.setBarDirection(BarDirection.COL);
    	}
    	/**
    	 * 隐藏列
    	 * @param sheet
    	 * @param sheetName
    	 */
    	private static void hiddenColumn(XSSFSheet sheet, String sheetName) {
    		/*if(sheetName.equals("sheetname2")){//需要隐藏列
    			sheet.setColumnHidden(3, true);
    			sheet.setColumnHidden(4, true);
    			sheet.setColumnHidden(5, true);
    			sheet.setColumnHidden(6, true);
    			sheet.setColumnHidden(7, true);
    			sheet.setColumnHidden(8, true);
    		}*/
    	}
    
    	/**
    	 * 设置边框
    	 */
    	private static XSSFCellStyle setBorder(XSSFWorkbook wb){
    		XSSFCellStyle style = wb.createCellStyle();
    		style.setBorderBottom(BorderStyle.THIN);	//边框
    		style.setBorderTop(BorderStyle.THIN);		//边框
    		style.setBorderLeft(BorderStyle.THIN);		//边框
    		style.setBorderRight(BorderStyle.THIN);		//边框
    		return style;
    	}
    
    }
    

    4.测试类

    	import java.io.File;
    import java.util.Arrays;
    import java.util.LinkedHashMap;
    import java.util.List;
    import java.util.Map;
    
    import org.apache.poi.xssf.usermodel.XSSFWorkbook;
    
    public class MyBarChartTest {
    	
    	public static void main(String args[]) {
    		String sheetName = "sheetname1";
    		try (XSSFWorkbook wb = new XSSFWorkbook()){
    			String  filePathDaily = "C:/Users/Administrator/Desktop/jfree/";
    			String fileName = "exceltest.xlsx";
    			
    			File filePath = new File(filePathDaily);
    			if(!filePath.exists()&&!filePath.isDirectory()){
    				filePath.mkdir();
    			}
    			//1.统计昨日交易量
    			File file = new File(filePathDaily+fileName);
    			
    			List<String> title=Arrays.asList("序号","类型","业务","合计:交易量","合计:收入",
    					"2019-01-01","2019-01-02","2019-01-03","2019-01-04","2019-01-05",
    					"2019-01-01收入","2019-01-02收入","2019-01-03收入","2019-01-04收入","2019-01-05收入");
    			List<String> titleStyle=Arrays.asList("int","String","String","int","double",
    					"int","int","int","int","int",
    					"double","double","double","double","double");
    			List<String> dates = Arrays.asList("2019-01-01","2019-01-02","2019-01-03","2019-01-04","2019-01-05");
    			
    			Map<String, List<Object>> day2ColValueList=new LinkedHashMap<String, List<Object>>();
    			day2ColValueList.put("类型1业务1",Arrays.asList("类型1","业务1",500,1000.00,100,50,100,150,100,200.00,150.00,200.00,250.00,200.00));
    			day2ColValueList.put("类型1业务2",Arrays.asList("类型1","业务2",400,800.00,80,60,80,100,80,160.00,130.00,160.00,190.00,160.00));
    			day2ColValueList.put("类型2业务1",Arrays.asList("类型2","业务1",600,1200.00,120,70,120,170,120,240.00,170.00,240.00,290.00,240.00));
    			day2ColValueList.put("类型2业务2",Arrays.asList("类型2","业务2",200,400.00,40,140,40,80,40,80.00,100.00,80.00,60.00,80.00));
    			MyExcleChart2.doWork(title, titleStyle, day2ColValueList,file,sheetName,wb,dates.size());
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    
    }
    
    

    5.结果展示
    在这里插入图片描述
    6.生成柱状折线图

      	<dependency>
    	  <groupId>org.apache.poi</groupId>
    	  <artifactId>poi</artifactId>
    	  <version>3.17</version>
    	</dependency>
    	<dependency>
    	  <groupId>org.apache.poi</groupId>
    	  <artifactId>poi-scratchpad</artifactId>
    	  <version>3.17</version>
    	</dependency>
    	<dependency>
    	  <groupId>org.apache.poi</groupId>
    	  <artifactId>poi-ooxml</artifactId>
    	  <version>3.17</version>
    	</dependency>
    	<dependency>
    	  <groupId>fr.opensagres.xdocreport</groupId>
    	  <artifactId>xdocreport</artifactId>
    	  <version>1.0.6</version>
    	</dependency>
    	<dependency>  
            <groupId> fr.opensagres.xdocreport</groupId>  
            <artifactId> org.apache.poi.xwpf.converter.core</artifactId>  
            <version> 1.0.6</version>  
    	</dependency>  
    	<dependency>
    		<groupId>fr.opensagres.xdocreport</groupId>
    		<artifactId>org.apache.poi.xwpf.converter.xhtml</artifactId>
    		<version>1.0.6</version>
    		</dependency>
    	<dependency>
    	  <groupId>org.apache.poi</groupId>
    	  <artifactId>poi-ooxml-schemas</artifactId>
    	  <version>3.17</version>
    	</dependency>
    	<dependency>
    	  <groupId>org.apache.poi</groupId>
    	  <artifactId>ooxml-schemas</artifactId>
    	  <version>1.3</version>
    	</dependency>
    
    package excel.test.com;
    
    import java.io.FileOutputStream;
    
    import org.apache.poi.ss.usermodel.Cell;
    import org.apache.poi.ss.usermodel.Chart;
    import org.apache.poi.ss.usermodel.Row;
    import org.apache.poi.ss.usermodel.Workbook;
    import org.apache.poi.xssf.usermodel.XSSFChart;
    import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
    import org.apache.poi.xssf.usermodel.XSSFDrawing;
    import org.apache.poi.xssf.usermodel.XSSFSheet;
    import org.apache.poi.xssf.usermodel.XSSFWorkbook;
    import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
    import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart;
    import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarSer;
    import org.openxmlformats.schemas.drawingml.x2006.chart.CTBoolean;
    import org.openxmlformats.schemas.drawingml.x2006.chart.CTCatAx;
    import org.openxmlformats.schemas.drawingml.x2006.chart.CTChart;
    import org.openxmlformats.schemas.drawingml.x2006.chart.CTLegend;
    import org.openxmlformats.schemas.drawingml.x2006.chart.CTLineChart;
    import org.openxmlformats.schemas.drawingml.x2006.chart.CTLineSer;
    import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
    import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumRef;
    import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
    import org.openxmlformats.schemas.drawingml.x2006.chart.CTScaling;
    import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
    import org.openxmlformats.schemas.drawingml.x2006.chart.CTStrRef;
    import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx;
    import org.openxmlformats.schemas.drawingml.x2006.chart.STAxPos;
    import org.openxmlformats.schemas.drawingml.x2006.chart.STBarDir;
    import org.openxmlformats.schemas.drawingml.x2006.chart.STCrosses;
    import org.openxmlformats.schemas.drawingml.x2006.chart.STLegendPos;
    import org.openxmlformats.schemas.drawingml.x2006.chart.STOrientation;
    import org.openxmlformats.schemas.drawingml.x2006.chart.STTickLblPos;
    
    public class BarAndLineChart2 {
    
        public static void main(String[] args) throws Exception {
        	XSSFWorkbook wb = new XSSFWorkbook();
            XSSFSheet sheet = wb.createSheet("Sheet1");
    
            Row row;
            Cell cell;
    
            row = sheet.createRow(0);
            row.createCell(0);
            row.createCell(1).setCellValue("Bars");
            row.createCell(2).setCellValue("Lines");
    
            for (int r = 1; r < 7; r++) {
                row = sheet.createRow(r);
                cell = row.createCell(0);
                cell.setCellValue("C" + r);
                cell = row.createCell(1);
                cell.setCellValue(new java.util.Random().nextDouble());
                cell = row.createCell(2);
                cell.setCellValue(new java.util.Random().nextDouble()*10d);
            }
    
            XSSFDrawing drawing = sheet.createDrawingPatriarch();
    //        ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 4, 0, 11, 15);
            XSSFClientAnchor anchor = (XSSFClientAnchor) drawing.createAnchor(0, 0, 0, 0, 4, 0, 11, 15);
    
            Chart chart = drawing.createChart(anchor);
    
            CTChart ctChart = ((XSSFChart)chart).getCTChart();  
            CTPlotArea ctPlotArea = ctChart.getPlotArea();
    
            //the bar chart
            CTBarChart ctBarChart = ctPlotArea.addNewBarChart();
            CTBoolean ctBoolean = ctBarChart.addNewVaryColors();
            ctBoolean.setVal(true);
            ctBarChart.addNewBarDir().setVal(STBarDir.COL);
    
            //the bar series
            CTBarSer ctBarSer = ctBarChart.addNewSer();
            CTSerTx ctSerTx = ctBarSer.addNewTx();
            CTStrRef ctStrRef = ctSerTx.addNewStrRef();
            ctStrRef.setF("Sheet1!$B$1");
            ctBarSer.addNewIdx().setVal(0);  
            CTAxDataSource cttAxDataSource = ctBarSer.addNewCat();
            ctStrRef = cttAxDataSource.addNewStrRef();
            ctStrRef.setF("Sheet1!$A$2:$A$7"); 
            CTNumDataSource ctNumDataSource = ctBarSer.addNewVal();
            CTNumRef ctNumRef = ctNumDataSource.addNewNumRef();
            ctNumRef.setF("Sheet1!$B$2:$B$7");
    
            //at least the border lines in Libreoffice Calc ;-)
            ctBarSer.addNewSpPr().addNewLn().addNewSolidFill().addNewSrgbClr().setVal(new byte[] {0,0,0});   
    
            //telling the BarChart that it has axes and giving them Ids
            ctBarChart.addNewAxId().setVal(123456); //cat axis 1 (bars)
            ctBarChart.addNewAxId().setVal(123457); //val axis 1 (left)
    
            //the line chart
            CTLineChart ctLineChart = ctPlotArea.addNewLineChart();
            ctBoolean = ctLineChart.addNewVaryColors();
            ctBoolean.setVal(true);
    
            //the line series
            CTLineSer ctLineSer = ctLineChart.addNewSer();
            ctSerTx = ctLineSer.addNewTx();
            ctStrRef = ctSerTx.addNewStrRef();
            ctStrRef.setF("Sheet1!$C$1");
            ctLineSer.addNewIdx().setVal(1);  
            cttAxDataSource = ctLineSer.addNewCat();
            ctStrRef = cttAxDataSource.addNewStrRef();
            ctStrRef.setF("Sheet1!$A$2:$A$7"); 
            ctNumDataSource = ctLineSer.addNewVal();
            ctNumRef = ctNumDataSource.addNewNumRef();
            ctNumRef.setF("Sheet1!$C$2:$C$7");
    
            //at least the border lines in Libreoffice Calc ;-)
            ctLineSer.addNewSpPr().addNewLn().addNewSolidFill().addNewSrgbClr().setVal(new byte[] {0,0,0});   
    
            //telling the LineChart that it has axes and giving them Ids
            ctLineChart.addNewAxId().setVal(123458); //cat axis 2 (lines)
            ctLineChart.addNewAxId().setVal(123459); //val axis 2 (right)
    
            //cat axis 1 (bars)
            CTCatAx ctCatAx = ctPlotArea.addNewCatAx(); 
            ctCatAx.addNewAxId().setVal(123456); //id of the cat axis
            CTScaling ctScaling = ctCatAx.addNewScaling();
            ctScaling.addNewOrientation().setVal(STOrientation.MIN_MAX);
            ctCatAx.addNewDelete().setVal(false);
            ctCatAx.addNewAxPos().setVal(STAxPos.B);
            ctCatAx.addNewCrossAx().setVal(123457); //id of the val axis
            ctCatAx.addNewTickLblPos().setVal(STTickLblPos.NEXT_TO);
    
            //val axis 1 (left)
            CTValAx ctValAx = ctPlotArea.addNewValAx(); 
            ctValAx.addNewAxId().setVal(123457); //id of the val axis
            ctScaling = ctValAx.addNewScaling();
            ctScaling.addNewOrientation().setVal(STOrientation.MIN_MAX);
            ctValAx.addNewDelete().setVal(false);
            ctValAx.addNewAxPos().setVal(STAxPos.L);
            ctValAx.addNewCrossAx().setVal(123456); //id of the cat axis
            ctValAx.addNewCrosses().setVal(STCrosses.AUTO_ZERO); //this val axis crosses the cat axis at zero
            ctValAx.addNewTickLblPos().setVal(STTickLblPos.NEXT_TO);
    
            //cat axis 2 (lines)
            ctCatAx = ctPlotArea.addNewCatAx(); 
            ctCatAx.addNewAxId().setVal(123458); //id of the cat axis
            ctScaling = ctCatAx.addNewScaling();
            ctScaling.addNewOrientation().setVal(STOrientation.MIN_MAX);
            ctCatAx.addNewDelete().setVal(true); //this cat axis is deleted
            ctCatAx.addNewAxPos().setVal(STAxPos.B);
            ctCatAx.addNewCrossAx().setVal(123459); //id of the val axis
            ctCatAx.addNewTickLblPos().setVal(STTickLblPos.NEXT_TO);
    
             //val axis 2 (right)
            ctValAx = ctPlotArea.addNewValAx(); 
            ctValAx.addNewAxId().setVal(123459); //id of the val axis
            ctScaling = ctValAx.addNewScaling();
            ctScaling.addNewOrientation().setVal(STOrientation.MIN_MAX);
            ctValAx.addNewDelete().setVal(false);
            ctValAx.addNewAxPos().setVal(STAxPos.R);
            ctValAx.addNewCrossAx().setVal(123458); //id of the cat axis
            ctValAx.addNewCrosses().setVal(STCrosses.MAX); //this val axis crosses the cat axis at max value
            ctValAx.addNewTickLblPos().setVal(STTickLblPos.NEXT_TO);
    
            //legend
            CTLegend ctLegend = ctChart.addNewLegend();
            ctLegend.addNewLegendPos().setVal(STLegendPos.B);
            ctLegend.addNewOverlay().setVal(false);
    
            FileOutputStream fileOut = new FileOutputStream("BarAndLineChart2.xlsx");
            wb.write(fileOut);
            fileOut.close();
        }
    }
    
    展开全文
  • ![图片说明]... 求大神帮忙,如何实现如所示的查询会议室使用情况的列表? 选择日期后,点击“查询”,“横标题”显示7天的日期,“列标题”显示会议室编号,内容填充会议室的使用情况。
  • 用临时列表进行统计

    2019-05-08 13:30:55
    下面我来介绍一下如何用临时列表来进行各种类型的统计。 代码如下所示: public ActionResult nianfentongji(BsgridPage bsgridPage)//年份统计 { List<tongji> myLists = new List<tongji&...

    下面我来介绍一下如何用临时列表来进行各种类型的统计。

    代码如下图所示:

     

     

    
    public ActionResult nianfentongji(BsgridPage bsgridPage)//年份统计
            {
    
                List<tongji> myLists = new List<tongji>();//声明一个临时列表
                if (Session["myLists"] != null)
                {
                    myLists = Session["myLists"] as List<tongji>;
                }
                var Date = myModel.YW_Sell.OrderByDescending(m => m.Data).Where(m=>m.SellstateID==3).Select(T => T.Data).ToList();
                
                List<string> list2 = new List<string>();//声明一个string临时列表
                for (int i = 0; i < Date.Count; i++)
                {
                    string str = Convert.ToDateTime(Date[i]).ToString("yyyy");
                    list2.Add(str);//添加到string临时列表
                }
                list2=list2.Distinct().ToList();//获取到的年份去重复
                List<tongji> tongji = new List<VO.tongji>();
                for (int i = 0; i < list2.Count; i++)
                {
                    tongji tong = new tongji();
                    tong.Name = list2[i];
                    tongji.Add(tong);
                }
                for (int i = 0; i < tongji.Count; i++)
                {
                    var time = tongji[i].Name;
                    
                    var list = (from tbSelldetails in myModel.YW_Selldetails
                                join tbSell in myModel.YW_Sell on tbSelldetails.SellID equals tbSell.SellID
                                join tbcommoditydetail in myModel.SYS_commoditydetail on tbSelldetails.CommoditydetailID equals tbcommoditydetail.CommoditydetailID
                                join tbcommodity in myModel.PW_commodity on tbcommoditydetail.commodityID equals tbcommodity.commodityID
                                join tbBrand in myModel.BS_Brand on tbcommodity.BrandID equals tbBrand.BrandID
                                where tbSell.Data.ToString().Trim().Contains(time.Trim())&&tbSell.SellstateID==3
                                select new tongji
                                {
                                    bb = tbSelldetails.Amount * tbcommodity.DiscountPrice,
                                    Amount = tbSelldetails.Amount,
                                    cc = tbSelldetails.Amount * tbcommoditydetail.Stockprice,
                                }).ToList();
                    var alldd = (int)list.Sum(m => m.Amount);
                    var allbb = (decimal)list.Sum(m => m.bb);
                    var allcc = (decimal)list.Sum(m => m.cc);
                    tongji listFile = new tongji
                    {
                        Name = tongji[i].Name,
                        alldd = alldd,
                        allbb = allbb,
                        allcc = allcc,
                        maolijine = allbb - allcc,
                        maolili1 = ((allbb - allcc) / allbb)
                    };
                    myLists.Add(listFile);//添加到临时列表
                    Session["listFile"] = myLists;
    
                }
                if (myLists != null)
                {
                    int EndIndex = bsgridPage.GetEndIndex();
                    if (EndIndex >= myLists.Count)
                    {
                        EndIndex = myLists.Count - 1;
                    }
                    List<tongji> list = new List<tongji>();
                    for (int i = bsgridPage.GetStartIndex(); i <= EndIndex; i++)
                    {
                        list.Add(myLists[i]);
                    }
                    Bsgrid<tongji> bsgrid = new Bsgrid<tongji>();
                    if (myLists != null)
                    {
                        bsgrid.totalRows = myLists.Count;
                    }
                    else
                    {
                        bsgrid.totalRows = 0;
                    }
                    bsgrid.success = true;
    
                    bsgrid.curPage = bsgridPage.curPage;
    
                    bsgrid.data = list;
    
                    return Json(bsgrid, JsonRequestBehavior.AllowGet);
                }
                return Json("", JsonRequestBehavior.AllowGet);
    
            }
    

    代码仅跟参考,谢谢。

    展开全文
  • matplotlib常用统计图

    2019-01-05 11:32:52
    假设通过爬虫你获取到了北京2016年3,10月份每天白天的最高气温(分别位于列表a,b), 那么此时如何寻找出气温和随时间(天)变化的某种规律? 散点与拆线的区别是使用scatter方法 from matplotlib import pyplot ...
  • 内存数据做统计专题主要有两个属性使用,ThemeGraph.memoryKeys键列表内的数值代表需要做统计信息地物的SmID值,ThemeGraphItem.memoryDoubleValues值列表里存入的就是需要做专题信息的内存数据,这些内存数据来自...
  • 在高年级小学数学课中,有关于柱状的内容,现在用Python turtle来实现柱状效果from turtle import *from random import randintdata = []length = 10# 可以定义初始化数据集合的函数并返回列表def init_data(num...
  • } } // 给changeObj对象添加children属性,并赋值一个由接口返回列表中对象组成的数组 changeObj.children=self.subTableData;self.tableData.push(changeObj); } // 存放子表格数据的数组每次父表元素之后都置空 ...
  • 数据分析第三讲 matplotlib常用统计图 1.绘制散点图 使用的方法:scatter(x,y) 假设通过爬虫你获取到了长沙2018年10,11月份每天白天的最高气温(分别位于列表a,b),那么 此时如何寻找出气温和随时间变化的某种规律 a ...
  • 统计插件.fas

    2019-10-10 14:00:27
    用于统计cad中的块,列表给出图例,名称,数量,便于cad中的各种块数量统计
  • 最初的统计图 然后我异步Ajax加载另外一个统计图(饼图),结果饼图叠在柱形图上面了。(两种图共用一个div) 问题总结: 因为共用一个宿主div,柱形图和饼图出现了干扰,加载饼图时,还能看到原来的柱形图。 二...
  • 假设某地3,10月份每天白天的最高气温(分别位于列表a, b),那么此时如何寻找气温随时间变化的某种规律? a = [17,16, 11, 12, 11, 12, 6, 6, 7, 8, 9, 12, 15, 14, 17, 18, 21, 16, 17, 20, 14, 15, 15, 15, 19,...
  • 统计图钻取效果实现

    2018-09-26 20:42:53
    当然,润乾报表也支持这个功能,前面小编有介绍过列表钻取,今天小编主要介绍如何利用润乾报表设计器在报表中实现图形钻取。 下面我们以订单分布为例,举例说明: 实际的需求是要求我们首先以柱呈现出每个人的总...
  • 优秀课程案例可以看下边书籍如何用scratch画柱形统计图一、学习目标1、现有6个班的成绩列表(成绩由随机数产生),如何用scratch绘制成绩的柱形统计图;2、学习随机数的用法;学习列表...
  • 如何用scratch画扇形统计图一、学习目标1、有六个班,每班人数是50-100间的随机数,用扇形统计图统计出各班人数所占的比例图(各班人数列表假设是一个集合,集合的性质决定元素互异性,每...
  • 1.横板条形统计图 实现方式 1.将数据存放在列表里,把数据除以300 2.输出数据标题名称 3.将除以300后的数据再乘一个符号(输出几个符号),这样能更直观的的查看数据 4.输出符号(也可以将符号加上背景颜色,...
  • 如何用scratch画折线统计图一、学习目标1、现有10天内的温度(温度数由随机数产生),如何用scratch绘制折线统计图;2、学习随机数的用法;学习列表;学习画笔工具。3、能够用scr...
  • 假设你获取了250部电影的时长(列表a中),希望统计出这些电影时长的分布状态(比如时长为100分钟到120分钟电影的数量,出现的频率)等信息,你应该如何呈现这些数据? a=[131, 98, 125, 131, 124, 139, 131, 117, 128, 108,...
  • 文章目录matplotlib常用统计图散点图条形图横着的条形图多次条形图直方图能绘制直方图吗只能绘制条形图直方图更多应用场景更多的绘图工具了解matplotlib常见问题总结matplotlib使用的流程总结matplotlib更多的图形...
  • 假设你获取到了2017年内地电影票房前20的电影(列表a)和电影票房数据(列表b),那么如何更加直观的展示该数据? a = ["战狼2","速度与激情8","功夫瑜伽","西游伏妖篇","变形金刚5:最后的骑士","摔跤吧!爸爸","加勒比...
  • 关于Qt中统计图QChart的背景隐藏

    千次阅读 2018-08-27 15:13:37
    之前由于业务需求,所以需要一个背景为透明的统计图,在网上找了下只找到了用setBackgroundBrush的,但是很明显,改背景颜色用这个函数可以做到,但是透明不行,仔细翻了下官方文档和函数列表,发现了...
  • 假设通过爬虫你获取到了北京2016年3,10月份每天白天的最高气温(分别位于列表a,b),那么此时如何寻找出气温和随时间(天)变化的某种规律? a = [11,17,16,11,12,11,12,6,6,7,8,9,12,15,14,17,18,21,16,17,20,14,15,15,15...
  • 例如CAD制图时,如何快 速统计图块数量?今天小编就和大家分享一下,加载CAD工具箱来辅 助制图,能够快 速帮助我们完成图块数量的统计,非 常的实 用方便。具体演示操作如下: 打开绘制CAD图纸 我们先运行AUTOCAD...
  • 这是在Linux或BSD上运行的开源网络模拟器和网络仿真器的列表。请在这个页面发表评论,让我知道我没有包括在这个列表中的任何其他开源网络仿真工具。本文来自http://www.brianlinkletter.com,中文同步更新Cloonix所...
  • 假设你知道了列表a中电影分别在2017-09-14(b_14), 2017-09-15(b_15), 2017-09-16(b_16)三天的票房,为了展示列表中电影本身的票房以及同其他电影的数据对比情况,应该如何更加直观的呈现该数据? a = ["猩球崛起3:终极...
  • 子文件夹里面是图片, 现在需要统计每个子文件夹中图片的个数。 import os path = 'D:/testin/common-mobile-web-app-icons/' #父文件夹路径 all_folds = os.listdir(path) #解析出父文件夹中所有的文件名称,并以...
  • 使用直方图统计像素

    2015-08-12 21:45:23
    (1) calcHist(),第1个参数为原数组区域列表;第二个参数为有计算几个原数组;参数3为需要统计的通道索引数;参数4为操作掩码,第5个参数为存放目标直方矩阵;参数6为需要计算的直方的维数;参数7为每一维的bin...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 3,191
精华内容 1,276
关键字:

列表统计图