最近在做一个关于图形统计的界面,主要用到的是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的统计图形的更多相关文章

  1. 4-Highcharts 3D图之3D普通饼图

    <!DOCTYPE> <html lang='en'> <head> <title>4-Highcharts 3D图之3D普通饼图</title& ...

  2. 物联网3D,物业基础设施3D运维,使用webgl(three.js)与物联网设备结合案例。搭建智慧楼宇,智慧园区,3D园区、3D物业设施,3D楼宇管理系统——第八课

    写在前面的废话: 很久没有更新文章了,这段时间一直忙于项目落地,虽然很忙,但是感觉没有总结,没有提炼的日子,总是让人感觉飘飘忽忽的. 所幸放下一些事,抽出一些时间,把近期的项目做一些整理与记录.也算是 ...

  3. Python制作统计图形

    转载自:http://www.dcharm.com/?p=15 Python一般使用Matplotlib制作统计图形,用它自己的说法是‘让简单的事情简单,让复杂的事情变得可能’.(你说国外的“码农”咋 ...

  4. 3-Highcharts 3D图之3D柱状图分组叠堆3D图

    <!DOCTYPE> <html lang='en'> <head> <title>3-Highcharts 3D图之3D柱状图分组叠堆3D图</ ...

  5. 2-Highcharts 3D图之3D柱状图带可调试倾斜角度

    <!DOCTYPE> <html lang='en'> <head> <title>2-Highcharts 3D图之3D柱状图带可调试倾斜角度< ...

  6. 3D Analyst Tools(3D Analyst 工具)

    3D Analyst 工具 工具里有又细分如下分类: 注:以下代码的参数需要另行配置,不能直接执行:Python2不支持中文变量! 1.3D 要素 # Process: 3D 内部 arcpy.Ins ...

  7. 如何用webgl(three.js)搭建一个3D库房,3D密集架,3D档案室(升级版)

    很长一段时间没有写3D库房,3D密集架相关的效果文章了,刚好最近有相关项目落地,索性总结一下 与之前我写的3D库房密集架文章<如何用webgl(three.js)搭建一个3D库房,3D密集架,3 ...

  8. webgl(three.js)3D光伏,3D太阳能能源,3D智慧光伏、光伏发电、清洁能源三维可视化解决方案——第十六课

    序: 能源是文明和发展的重要保障,人类命运不可避开的话题,无论是战争还是发展,都有它存在的身影.从石器时代到现代文明,人类的能源应用在进步,也在面临能源枯竭的危机与恐惧,而开发与应用可再生能源才是解决 ...

  9. 如何使用webgl(three.js)实现3D储能,3D储能站,3D智慧储能、储能柜的三维可视化解决方案——第十七课

    前言 上节课我们讲了<3D光伏发电>,与之配套的就是能量存储 这节课我们主要讲讲储能,储能站,在分布式能源系统中起到调节用对电的尖峰平谷进行削峰填谷的作用.特别是小型储能站,更加灵活,因地 ...

随机推荐

  1. 关注云端搜索技术:elasticsearch,nutch,hadoop,nosql,mongodb,hbase,cassandra 及Hadoop优化

    http://www.searchtech.pro/ Hadoop添加或调整的参数: 一.hadoop-env.sh1.hadoop的heapsize的设置,默认1000 # The maximum ...

  2. Docker存储驱动之AUFS简介

    简介 AUFS是曾是Docker默认的首选存储驱动.它非常稳定.有很多真实场景的部署.很强的社区支持.它有以下主要优点: 极短的容器启动时间. 有效的存储利用率. 有效的内存利用率. 虽然如此,但由于 ...

  3. 每天一个linux命令(55)--at命令

    在Windows系统中,Windows提供了计划任务这一功能,在控制面板  ->  性能与维护  ->  任务计划,它的功能就是安排自动运行的任务.通过 ‘ 添加任务计划’ 的一步步引导, ...

  4. spring exception

    Spring MVC异常处理SimpleMappingExceptionResolver[转] (2012-12-07 13:45:33) 转载▼ 标签: 杂谈 分类: 技术分享 Spring3.0中 ...

  5. 跨专业学习编程的苦逼生活 QWQ嘤嘤嘤

    一串串小小的代码,竟然可以做出辣么多的东西,彻底颠覆了我的世界观.人生观.价值观. 话不多说,一个例子证明一切>>>> <!DOCTYPE html> <ht ...

  6. 1740: [Usaco2005 mar]Yogurt factory 奶酪工厂

    1740: [Usaco2005 mar]Yogurt factory 奶酪工厂 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 119  Solved:  ...

  7. 关于easyUI的datebox加失去焦点事件即click、blur等

    想实现日期框easyui-datebox手动输入值,手动输入失去焦点判断输入值是否合法 例如<input id="txtDate" type="text" ...

  8. wx模块小实例

    功能介绍: 查询数据库表数据,提取数据并显示 main.py(执行文件) #coding:gbk __author__ = 'Hito' import querySmscode import wx c ...

  9. WPF: 在 MVVM 设计中实现对 ListViewItem 双击事件的响应

    ListView 控件最常用的事件是 SelectionChanged:如果采用 MVVM 模式来设计 WPF 应用,通常,我们可以使用行为(如 InvokeCommandAction)并结合命令来实 ...

  10. 使用Java语言开发微信公众平台(四)——图文消息的发送与响应

    在上一篇文章中,我们实现了被关注回复与关键词回复功能.在用户关注的时候自动推送功能菜单,并根据用户输入的关键词,回复特定信息.但是,我们只能回复文本消息给用户,如何才回复一条图文消息呢?本周,我们一起 ...