public string SavePersonCompanyTicketChart(string userName, int reportId, DateTime startDate, DateTime endDate) { AccountController ac = new AccountController(); string realName = ac.GetRealName(userName); //读取两周的数据,自己客户的票量,按照日期展示曲线图 OtaCrmModel db = new OtaCrmModel(); var companyNames = from c in db.OtaCompany where c.SalesUserName == realName select c.CompanyName; var q = from p in db.AgentGradeOperation where p.statDate.Value >= startDate && p.statDate.Value <= endDate && companyNames.Contains(p.agentName) group p by p.statDate into g orderby g.Key select new { ticketSum = g.Sum(b => b.CurDateTicketCount.Value), ticketDay = g.Key }; List <string> dateList = new List <string>(); List <int> ticketSumList = new List <int>(); foreach (var item in q) { dateList.Add(item.ticketDay.Value.ToString("yyyyMMdd")); ticketSumList.Add(item.ticketSum); } System.Web.Helpers.Chart chart = new System.Web.Helpers.Chart(width: 500, height: 300, theme: ChartTheme.Blue, themePath: null); chart.AddTitle(text: userName + "客户票量统计", name: userName + "_CompanyTicketSum"); chart.AddSeries(name: "票量" , chartType: "Column" , chartArea: "" , axisLabel: "张" , legend: "票量合计" , markerStep: 1 , xValue: dateList , xField: "日期" , yValues: ticketSumList , yFields: "票量"); string filePath = Server.MapPath("~/CompanyImages/Reports/" + reportId.ToString()); CompanyBusinessDailyPhotoesController cbd = new CompanyBusinessDailyPhotoesController(); cbd.CreateFolderIfNeeded(filePath); string fileName = userName + "_CompanyTicketSum_" + startDate.ToString("yyyyMMdd") + "_" + endDate.ToString("yyyyMMdd") + ".jpg"; chart.Save(path: Path.Combine(filePath, fileName), format: "jpeg"); return(fileName); }
private string generateSchoolChart(string[] sources, int[] sourceCounts) { string uuid = Guid.NewGuid().ToString(); var filePath = getChartPath(uuid); //Theme to hide slice labels string chartTheme = @"<Chart> <Series> <Series Name=""Programs"" ChartType=""Pie"" LegendText=""#VALX (#PERCENT{P2})"" CustomProperties=""PieLabelStyle=Disabled""> </Series> </Series> <Legends> <Legend _Template_=""All"" Docking=""Bottom""> </Legend> </Legends> </Chart>"; var myChart = new System.Web.Helpers.Chart(width: 250, height: 400, theme: chartTheme); myChart.AddTitle("Candidates Selected"); myChart.AddSeries( "Programs", chartType: SeriesChartType.Pie.ToString(), xValue: sources, yValues: sourceCounts ); myChart.AddLegend("Programs"); myChart.Save(filePath, "jpg"); return uuid; }