博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
DevExpress之ChartControl用法
阅读量:7282 次
发布时间:2019-06-30

本文共 2314 字,大约阅读时间需要 7 分钟。

DevExpress中的ChartControl顾名思义就是数据基于图表展示,其关键在于Series上的处理。

using System;using System.Drawing;using DevExpress.XtraCharts;namespace DevExpressUtilHelpV3{public static class ChartToolV3{/// /// 创建Series/// /// ChartControl/// Series名字『诸如:理论电量』/// seriesType『枚举』/// 数据源/// ChartControl的X轴绑定/// ChartControl的Y轴绑定public static void CreateSeries(this ChartControl chat, string seriesName, ViewType seriesType, object dataSource, string xBindName, string yBindName){CreateSeries(chat, seriesName, seriesType, dataSource, xBindName, yBindName, null);}/// /// 创建Series/// /// ChartControl/// Series名字『诸如:理论电量』/// seriesType『枚举』/// 数据源/// ChartControl的X轴绑定/// ChartControl的Y轴绑定/// Series自定义『委托』public static void CreateSeries(this ChartControl chat, string seriesName, ViewType seriesType, object dataSource, string xBindName, string yBindName, Action
createSeriesRule){if (chat == null)throw new ArgumentNullException("chat");if (string.IsNullOrEmpty(seriesName))throw new ArgumentNullException("seriesType");if (string.IsNullOrEmpty(xBindName))throw new ArgumentNullException("xBindName");if (string.IsNullOrEmpty(yBindName))throw new ArgumentNullException("yBindName");Series _series = new Series(seriesName, seriesType);_series.ArgumentScaleType = ScaleType.Qualitative;_series.ArgumentDataMember = xBindName;_series.ValueDataMembers[0] = yBindName;_series.DataSource = dataSource;if (createSeriesRule != null)createSeriesRule(_series);chat.Series.Add(_series);}}}

代码使用示例如下:

public Form1(){InitializeComponent();}private void Form1_Load(object sender, EventArgs e){DataTable _dt = CreateTestDB();chartControl1.CreateSeries("理论功率", ViewType.Spline, _dt, "time", "Power");chartControl1.CreateSeries("实际功率", ViewType.Spline, _dt, "time", "ActulPower");}/// /// 准备数据源/// /// 
DataTable
private DataTable CreateTestDB(){DataTable _testData = new DataTable();_testData.Columns.Add(new DataColumn("time", typeof(string)));_testData.Columns.Add(new DataColumn("Power", typeof(decimal)));_testData.Columns.Add(new DataColumn("ActulPower", typeof(decimal)));Random _rm = new Random();for (int i = 0; i < 24; i++){DataRow _drNew = _testData.NewRow();_drNew["time"] = string.Format("{0}点", i);_drNew["Power"] = 250;_drNew["ActulPower"] = _rm.Next(220, 245);_testData.Rows.Add(_drNew);}return _testData;}

 

转载地址:http://fnkjm.baihongyu.com/

你可能感兴趣的文章
第二节 表操作及约束
查看>>
Linux运维之道之网络基础学习1.1
查看>>
数据结构--数组类实现
查看>>
mongo3 安装
查看>>
8.24上海交大新一期PDU活动圆满结束
查看>>
java开发之javaSE基本语法
查看>>
三层交换机密码恢复
查看>>
Linux日常运维管理技巧: w命令-查看系统负载、vmstat命令、top命令、sar命令
查看>>
CentOS6.8手工安装X Window
查看>>
Hibernate的学习笔记(2)
查看>>
python入门(一)pycharm的安装
查看>>
26期20180702 shell特殊符号 cut sort_wc_uniq trr_tr_spli
查看>>
堡垒机搭建有哪些注意事项?
查看>>
检测内存的使用率
查看>>
Android studio 新建 模拟器HAX kernel moudle is not inst
查看>>
虚拟,混合和SD-WAN如何比较和对比
查看>>
Zookeeper架构及FastLeaderElection机制
查看>>
tomcat安装配置
查看>>
push-消息推送
查看>>
Hierarchical or taxonomy data filter
查看>>