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光伏发电>,与之配套的就是能量存储 这节课我们主要讲讲储能,储能站,在分布式能源系统中起到调节用对电的尖峰平谷进行削峰填谷的作用.特别是小型储能站,更加灵活,因地 ...
随机推荐
- .Net异步编程知多少
1. 引言 最近在学习Abp框架,发现Abp框架的很多Api都提供了同步异步两种写法.异步编程说起来,大家可能都会说异步编程性能好.但好在哪里,引入了什么问题,以及如何使用,想必也未必能答的上来. 自 ...
- 2017 CVTE春招内推专场 C/C++软件开发岗笔试编程题
先来一波吐槽:选择题全是不定项选择,考的内容在我看来,"反正我接受唔到咯". 比如: 1.Windows操作系统某个通信机制(具体题目忘了,反正答案我选了个熟悉的名词"消 ...
- SimpleDateFormat的线程安全问题与解决方案
SimpleDateFormat 是 Java 中一个常用的类,该类用来对日期字符串进行解析和格式化输出,但如果使用不小心会导致非常微妙和难以调试的问题. 因为 DateFormat 和 Simple ...
- JavaScript代码规范和性能整理
性能 Js在性能方面有多要注意的地方: 避免全局查找 Js性能优化最重要的就是注意全局查找,因为作用域的查找是先找局部作用域在没有找到之后在去上一级作用域查找直到全局作用域,所以全局作用域查找的性能消 ...
- VS2008与opencv结合使用的方法
使用平台:win7(32位)系统,opencv 2.3.1,vs 2008. 目前在需要在vs上运行KCF视觉跟踪算法,其中有用到opencv的库,刚刚开始遇到的如下问题: 1. 计算机无法找到ope ...
- mfc---获取当前时间
CTime t = CTime::GetCurrentTime(); CString strTime = t.format("%Y/&m%d" %h:%M:%S);
- Visual Studio 20周年软件趋势随想
从2002年开始,.net让开发人员能快速构建和部署应用程序,便捷的开发windows和web服务器应用,同时著名的hacker Miguel de Icaza ,Miguel 为了GNOME项目启动 ...
- 2060: [Usaco2010 Nov]Visiting Cows 拜访奶牛
2060: [Usaco2010 Nov]Visiting Cows 拜访奶牛 Time Limit: 3 Sec Memory Limit: 64 MBSubmit: 252 Solved: 1 ...
- 非服务器的定期校正时间 Anacron
与服务器不同,编程和办公用计算机不是连续24小时运行的.开关机的时间不固定,类似较时这样的任务无法保证运行. 对于这类机器,可以考虑使用 Anacron 进行设置. 在 Archlinux 中, An ...
- CDbConnection failed to open the DB connection
打开数据库失败 有我遇到的有寄给问题: 1 Not find Drive 2 SQLSTATE[28000] [1045] Access denied for user 'xxx'@'localhos ...