基本信息
源码名称:c# mvc 雷达图 报表 itextsharp实例
源码大小:0.53M
文件格式:.zip
开发语言:C#
更新时间:2015-10-22
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
itxtsharp
using System.Collections.Generic;
using System.Linq;
using System.Web.Helpers;
using System.Web.Mvc;
using MvcChartExample.Models;
using UICharting = System.Web.UI.DataVisualization.Charting;
namespace MvcChartExample.Controllers {
public class CustomerController : Controller {
private const int chartWidth = 380;
private const int chartHeight = 300;
public ActionResult Index() {
var customers = BuildDataScoure();
List<string> address = new List<string>();
List<int> customerCountByAddress = new List<int>();
var group = from customer in customers
group customer by customer.Address into AddressGroup
orderby AddressGroup.Key descending
select AddressGroup;
foreach (var item in group) {
address.Add(item.Key);
customerCountByAddress.Add(item.Count());
}
GeneratorLineChartPicure(address, customerCountByAddress);
GeneratorColumnChartPicure(address, customerCountByAddress);
GeneratorBarChartPicure(address, customerCountByAddress);
GeneratorPieChartPicure(address, customerCountByAddress);
return View();
}
private static void GeneratorLineChartPicure(List<string> address, List<int> customerCount) {
new Chart(width: chartWidth, height: chartHeight, theme: ChartTheme.Green)
.AddTitle("按地区分析客户源")
.AddSeries(
name: "Customer",
chartType: UICharting.SeriesChartType.Line.ToString(),
xValue: address,
yValues: customerCount)
.SetXAxis(title: "地区")
.SetYAxis(title: "客户个数")
.Save("~/Content/tempfiles/LineChart.jpeg");
}
private static void GeneratorColumnChartPicure(List<string> address, List<int> customerCount) {
new Chart(width: chartWidth, height: chartHeight, theme: ChartTheme.Green)
.AddTitle("按地区分析客户源")
.AddSeries(
name: "Customer",
chartType: UICharting.SeriesChartType.Column.ToString(),
xValue: address,
yValues: customerCount)
.SetXAxis(title: "地区")
.SetYAxis(title: "客户个数")
.Save("~/Content/tempfiles/ColumnChart.jpeg");
}
private static void GeneratorBarChartPicure(List<string> address, List<int> customerCount) {
new Chart(width: chartWidth, height: chartHeight, theme: ChartTheme.Blue)
.AddTitle("按地区分析客户源")
.AddSeries(
chartType: UICharting.SeriesChartType.Bar.ToString(),
legend: "Rainfall",
xValue: address,
yValues: customerCount)
.SetXAxis(title: "地区")
.SetYAxis(title: "客户个数")
.Save("~/Content/tempfiles/BarChart.jpeg");
}
private static void GeneratorPieChartPicure(List<string> address, List<int> customerCount) {
new Chart(width: chartWidth, height: chartHeight, theme: ChartTheme.Green)
.AddTitle("按地区分析客户源")
.AddSeries(
name: "Customer",
chartType: UICharting.SeriesChartType.Pie.ToString(),
xValue: address,
yValues: customerCount)
.SetXAxis(title: "地区")
.SetYAxis(title: "客户个数")
.Save("~/Content/tempfiles/PieChart.jpeg");
}
private static List<Customer> BuildDataScoure() {
int index = 1;
var citys = new string[] { "上海", "北京", "湖北", "湖南", "深圳", "广州", "四川" };
var customers = new List<Customer> {
new Customer{ Id=index ,Name="张三", Address=citys[0] },
new Customer{ Id=index ,Name="李四", Address=citys[0] },
new Customer{ Id=index ,Name="王五", Address=citys[0] },
new Customer{ Id=index ,Name="李明", Address=citys[2] },
new Customer{ Id=index ,Name="李嘉诚", Address=citys[2] },
new Customer{ Id=index ,Name="李连杰", Address=citys[0] },
new Customer{ Id=index ,Name="李小龙", Address=citys[0] },
new Customer{ Id=index ,Name="李宁", Address=citys[2] },
new Customer{ Id=index ,Name="李鹏", Address=citys[2] },
new Customer{ Id=index ,Name="李登辉", Address=citys[2] },
new Customer{ Id=index ,Name="李鹏",Address=citys[1] },
new Customer{ Id=index ,Name="李" index .ToString(),Address=citys[1] },
new Customer{ Id=index ,Name="李" index .ToString(),Address=citys[3] },
new Customer{ Id=index ,Name="李" index .ToString(),Address=citys[4] },
new Customer{ Id=index ,Name="李" index .ToString(),Address=citys[5] },
new Customer{ Id=index ,Name="李" index .ToString(),Address=citys[6] },
new Customer{ Id=index ,Name="李" index .ToString(),Address=citys[5] },
new Customer{ Id=index ,Name="李" index .ToString(),Address=citys[6] },
new Customer{ Id=index ,Name="李" index .ToString(),Address=citys[5] },
new Customer{ Id=index ,Name="李" index .ToString(),Address=citys[6] },
new Customer{ Id=index ,Name="李" index .ToString(),Address=citys[4] },
new Customer{ Id=index ,Name="李" index .ToString(),Address=citys[3] }
};
return customers;
}
}
}