Bar 3D 和Pie 3D的统计图形
最近在做一个关于图形统计的界面,主要用到的是Dev控件ChartControl(功能很强大,能解决基本和复杂图形统计问题)。
ChartControl主要有Diagram、Series、Legend三个重要属性
diagram主要是用来控制图形X、Y、Z轴显示的样式和是否允许旋转以及旋转的角度和绕那个轴旋转。
series主要是用来给chartcontrol控件增加各种图形,图形的种类用viewtype来控制。
legend主要是用来说明图形的分类(可以说是图例)。
第一部分是以饼状图来分类显示各种情况所占的百分比:例如最近一段时间水果占销售总量的百分比是多少等等。

代码主要是先实例化chartcontrol,再对chartcontrol进行属性赋值最后进行绑定数据,代码如下:
ChartControl staticsChart = new ChartControl();//create the chart control
Series series1 = null;
Series series2 = null;
Series series3 = null;
Series series4 = null;
/// <summary>
/// config the format for doughnut3D
/// </summary>
private void AddDoughnut3D()
{
series1= new Series("Doughnut Sereis 1", ViewType.Doughnut3D);//add series1
ChangeTheDouguntData();
staticsChart.Series.Add(series1);
series1.Label.TextPattern = "{A}{VP:0%}";
((Doughnut3DSeriesView)series1.View).HoleRadiusPercent=;
//((Doughnut3DSeriesView)series1.View).ExplodedPoints.Add(series1.Points[0]);export diagram
((SimpleDiagram3D)staticsChart.Diagram).RotationType = RotationType.UseAngles;
((SimpleDiagram3D)staticsChart.Diagram).RotationAngleX = -;
SetChartFormat();
}
private void SetChartFormat()
{
staticsChart.CrosshairOptions.ShowArgumentLabels = true;
staticsChart.CrosshairOptions.ShowArgumentLine = true;
staticsChart.CrosshairOptions.ShowCrosshairLabels = true;
staticsChart.BackColor = Color.Transparent;
staticsChart.PaletteBaseColorNumber = ;
staticsChart.PaletteName = "Green";
staticsChart.Titles.Clear();
ChartTitle chartTitle1 = new ChartTitle();
staticsChart.Text = "Data Graphics";
staticsChart.Titles.Add(chartTitle1);
staticsChart.Legend.UseCheckBoxes = false;
staticsChart.Legend.Direction = LegendDirection.LeftToRight;
staticsChart.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Center;
staticsChart.Dock = DockStyle.Fill;
this.pnlAddDiagram.Controls.Add(staticsChart);
}
private void ChangeTheDouguntData()
{
DataTable diagramData = GetAllEmployeeDaySummary();
int attendanceNumber = ;
int delaysNumber = ;
int absencesNumber = ;
int exceptionNumber = ;
if (diagramData.Rows.Count > )
{
attendanceNumber = diagramData.Select("pc_code=2" + " and pc_results>0").Length;
delaysNumber = diagramData.Select("pc_code=6" + " and pc_results>0").Length;
absencesNumber = diagramData.Select("pc_code=8" + " and pc_results>0").Length;
exceptionNumber = diagramData.Select("pc_code in(11,12) " + " and pc_results>0").Length;
}
series1.Points.AddRange(new SeriesPoint[]{
new SeriesPoint("Attendance",attendanceNumber),
new SeriesPoint("Delays",delaysNumber),
new SeriesPoint("Absences",absencesNumber),
new SeriesPoint("Exception",exceptionNumber)});
}
第二部分是柱状图,思路和饼状图差不多,series设置的不一样。

实现代码:
private void AddBar3DChart()
{
series1 = new Series("Attendance", ViewType.Bar3D);
series2 = new Series("Delays", ViewType.Bar3D);
series3 = new Series("Absences", ViewType.Bar3D);
series4 = new Series("Exception", ViewType.Bar3D);
if (cmbType.SelectedIndex == )
{
ChangeEmployeeBarData();
}
else if (cmbType.SelectedIndex == )
{
ChangeDepartmentBarData();
}
staticsChart.Series.AddRange(new Series[] { series1, series2, series3, series4 });
//series1.Label.ResolveOverlappingMode = ResolveOverlappingMode.Default; #region set the series view's value
Bar3DSeriesView myView1 = (Bar3DSeriesView)series1.View;
myView1.BarDepthAuto = false;
myView1.BarDepth = 0.2;
myView1.BarWidth = 0.5;
Bar3DSeriesView myView2 = (Bar3DSeriesView)series2.View; myView2.BarDepthAuto = false;
myView2.BarDepth = 0.2;
myView2.BarWidth = 0.5;
Bar3DSeriesView myView3 = (Bar3DSeriesView)series3.View;
myView3.BarDepthAuto = false;
myView3.BarDepth = 0.2;
myView3.BarWidth = 0.5;
Bar3DSeriesView myView4 = (Bar3DSeriesView)series4.View;
myView4.BarDepthAuto = false;
myView4.BarDepth = 0.2;
myView4.BarWidth = 0.5;
#endregion XYDiagram3D myDiagram = (XYDiagram3D)staticsChart.Diagram;
myDiagram.RotationType = RotationType.UseAngles;
myDiagram.RotationOrder = RotationOrder.XYZ;
myDiagram.RotationAngleX = ;
myDiagram.RotationAngleY = ;
myDiagram.RotationAngleZ = ;
myDiagram.RuntimeScrolling = true;
SetChartFormat();
} private void ChangeDepartmentBarData()
{
List<Employee> empList = treeModule.CheckedEmps;
List<Department> depList = treeModule.CheckedDepartment;
DateTime fromDate = dteFromDate.DateTime;
DateTime endDate = dteEndDate.DateTime;
List<DaySummary> dsList = new DaySummaryBLL().GetEmployeesDailySummary(empList, fromDate, endDate);
List<Paycode> paycodeList = new PaycodeBLL().GetMainFields();
var dsPaycodeList = from ds in dsList
join p in paycodeList on ds.paycode.id equals p.id
where ds.pc_results >
orderby ds.employee.id ascending, ds.att_date descending
select new { ID = ds.employee.id, Minutes = ds.pc_results, Date = ds.att_date, Paycode = p.pc_code };
foreach (Department dep in depList)
{
int attendanceDay = ;
int delaysDay = ;
int absencesDay = ;
int ExceptionDay = ;
List<Employee> depEmpList = new EmployeeBLL().GetMainFields(string.Format("where e.department.id={0}", dep.id));
foreach (Employee employee in depEmpList)
{
attendanceDay += dsPaycodeList.Count(dspaycode => dspaycode.ID == employee.id && dspaycode.Paycode == );
delaysDay += dsPaycodeList.Count(dspaycode => dspaycode.ID == employee.id && dspaycode.Paycode == );
absencesDay += dsPaycodeList.Count(dspaycode => dspaycode.ID == employee.id && dspaycode.Paycode == );
ExceptionDay += dsPaycodeList.Count(dspaycode => dspaycode.ID == employee.id && dspaycode.Paycode == ) +
dsPaycodeList.Count(dspaycode => dspaycode.ID == employee.id && dspaycode.Paycode == );
}
series1.Points.Add(new SeriesPoint(dep.dept_name.ToString(), attendanceDay));
series2.Points.Add(new SeriesPoint(dep.dept_name.ToString(), delaysDay));
series3.Points.Add(new SeriesPoint(dep.dept_name.ToString(), absencesDay));
series4.Points.Add(new SeriesPoint(dep.dept_name.ToString(), ExceptionDay));
}
}
以上主要是提供一个思路怎么来解决这种图形统计类问题,以及怎么进行数据绑定,如有不对的地方请指出。
Bar 3D 和Pie 3D的统计图形的更多相关文章
- 4-Highcharts 3D图之3D普通饼图
<!DOCTYPE> <html lang='en'> <head> <title>4-Highcharts 3D图之3D普通饼图</title& ...
- 物联网3D,物业基础设施3D运维,使用webgl(three.js)与物联网设备结合案例。搭建智慧楼宇,智慧园区,3D园区、3D物业设施,3D楼宇管理系统——第八课
写在前面的废话: 很久没有更新文章了,这段时间一直忙于项目落地,虽然很忙,但是感觉没有总结,没有提炼的日子,总是让人感觉飘飘忽忽的. 所幸放下一些事,抽出一些时间,把近期的项目做一些整理与记录.也算是 ...
- Python制作统计图形
转载自:http://www.dcharm.com/?p=15 Python一般使用Matplotlib制作统计图形,用它自己的说法是‘让简单的事情简单,让复杂的事情变得可能’.(你说国外的“码农”咋 ...
- 3-Highcharts 3D图之3D柱状图分组叠堆3D图
<!DOCTYPE> <html lang='en'> <head> <title>3-Highcharts 3D图之3D柱状图分组叠堆3D图</ ...
- 2-Highcharts 3D图之3D柱状图带可调试倾斜角度
<!DOCTYPE> <html lang='en'> <head> <title>2-Highcharts 3D图之3D柱状图带可调试倾斜角度< ...
- 3D Analyst Tools(3D Analyst 工具)
3D Analyst 工具 工具里有又细分如下分类: 注:以下代码的参数需要另行配置,不能直接执行:Python2不支持中文变量! 1.3D 要素 # Process: 3D 内部 arcpy.Ins ...
- 如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室(升级版)
很长一段时间没有写3D库房,3D密集架相关的效果文章了,刚好最近有相关项目落地,索性总结一下 与之前我写的3D库房密集架文章<如何用webgl(three.js)搭建一个3D库房,3D密集架,3 ...
- webgl(three.js)3D光伏,3D太阳能能源,3D智慧光伏、光伏发电、清洁能源三维可视化解决方案——第十六课
序: 能源是文明和发展的重要保障,人类命运不可避开的话题,无论是战争还是发展,都有它存在的身影.从石器时代到现代文明,人类的能源应用在进步,也在面临能源枯竭的危机与恐惧,而开发与应用可再生能源才是解决 ...
- 如何使用webgl(three.js)实现3D储能,3D储能站,3D智慧储能、储能柜的三维可视化解决方案——第十七课
前言 上节课我们讲了<3D光伏发电>,与之配套的就是能量存储 这节课我们主要讲讲储能,储能站,在分布式能源系统中起到调节用对电的尖峰平谷进行削峰填谷的作用.特别是小型储能站,更加灵活,因地 ...
随机推荐
- Jemter性能测试
Jmeter 介绍 Jmeter 是一款使用Java开发的,开源免费的,测试工具, 主要用来做功能测试和性能测试(压力测试/负载测试). 而且用Jmeter 来测试 Restful API, 非常好 ...
- C# Redis之ServiceStack
前面几篇博客基本把redis基本操作学习了下,但一些高级应用并没有写进博客,例如持久化.虚拟内存等,像这些主要是通过配置文件来解决的,运维方向可能更侧重一些,对于开发者来说,可能就想知道怎么用C#来和 ...
- fastcgi的介绍,原理及配置
fastcgi介绍: CGI全称是“公共网关接口”(Common Gateway Interface),HTTP服务器与你的或其它机器上的程序进行“交谈”的一种工具,其程序一般运行在网络服务器上. C ...
- CORS(跨域资源共享)
Cors(Cross-origin Resource Sharing)基本思想是使用自定义的HTTP头部允许浏览器和服务器相互了解对方,从而决定响应成功与否. CORS与JSONP对比: 1.JSON ...
- Struts2环境的搭建
1. Struts2 获取http://struts.apache.org/download.cgiStruts-2.3.16.3-all.zip 了解主要目录 apps :该文件夹下包含了基于Str ...
- Extjs中grid前端分页使用PagingMemoryProxy【二】
在项目中遇到Grid前端分页,本人也是刚接触extjs没多久,为了实现效果,一直找了很久才实现出来,对于代码中的一些也不能详细的说明出来, 不知道能不能帮助到遇到同样问题的朋友,所以将例子代码 ...
- Linux服务器下Java环境搭建
前言: 在centOS下,像阿里云等都预先设置了jdk,不过不是SUN的java JDK,一般情况要重新装jdk,而且一般情况下自己装的Jdk相对来说易控制版本,稳定性更高.所以以下是我卸载预装jdk ...
- Digital Tutors - Creating an Action Adventure Puzzle in Unity学习笔记
遇到的问题: 1 第11节Scripting the pressure plates中需要获取子物体的Animator组件,教程使用的语句如下: ”SwitchAnim = GetComponentI ...
- 可扩展标记语言XML
XML简述 XML用于描述数据,是当前处理结构化文档信息的有力工具.与操作系统编程语言的开发平台无关,可以实现不同系统之间的数据交互. 结构 <?xml version="1.0&qu ...
- PHP无锁内存nosql---Yac的实战
无锁内存nosql---Yac的实战 最近在工作使用了yac,所以比较了下Memcache和Yac的高并发读写性能测试,发现Yac要比Memcache快很多(这里没有比较Yac和Apc的性能情况, 不 ...