图表元素之间的关系:

根据DevExpress帮助文档中描述:

创建点图:

1、创建图表

/// <summary>
/// 创建图表
/// </summary>
private void CreatChart()
{// Create a new chart.图表控件ChartControl pointChart = new ChartControl();// Add the chart to the form.pointChart.Dock = DockStyle.Fill;//停靠方式this.Controls.Add(pointChart);//pointChart.RightToLeft = System.Windows.Forms.RightToLeft.Inherit;  //指示文本是否从右至左显示//添加 图表标题pointChart.Titles.Add(new ChartTitle());pointChart.Titles[0].Text = "A Point Chart";//Legend  调整图例pointChart.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.RightOutside; //获取或设置图表控件中的图例的水平对齐方式。pointChart.Legend.AlignmentVertical = LegendAlignmentVertical.Top;//获取或设置图表控件中的图例的竖直对齐方式。pointChart.Legend.Direction = LegendDirection.BottomToTop;//获取或设置在该图例中显示系列名称的方向。pointChart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;//是否在图表上显示图例Series series1 = CreateSeries("Series 1");//创建系列Series series2 = CreateSeries("Series 2");pointChart.Series.Add(series1);// Add the series to the chart.将点系列加入图表控件pointChart.Series.AddRange(new Series[] { series2 });//Diagram 对象等于 null (在 Visual Basic 中为 Nothing),直到图表至少拥有一个系列。SetDiagarm(pointChart);//设置图像CreateAxisY(series2, pointChart);// Add points to it.series1.Points.Add(new SeriesPoint(1, 10));series1.Points.Add(new SeriesPoint(2, 22));series1.Points.Add(new SeriesPoint(3, 14));series1.Points.Add(new SeriesPoint(4, 27));series1.Points.Add(new SeriesPoint(5, 15));series1.Points.Add(new SeriesPoint(6, 28));series1.Points.Add(new SeriesPoint(7, 15));SeriesPoint spoint = new SeriesPoint(8, 33);spoint.Color = Color.Red;//定制点的颜色series1.Points.Add(spoint);//系列2采用DataTable绑定// Create an empty table.DataTable table = new DataTable("Table1");// Add two columns to the table.table.Columns.Add("Argument", typeof(Int32));table.Columns.Add("Value", typeof(Int32));// Add data rows to the table.Random rnd = new Random();DataRow row = null;for (int i = 0; i < 10; i++){row = table.NewRow();row["Argument"] = i;row["Value"] = rnd.Next(30);table.Rows.Add(row);}// Specify data members to bind the series.series2.ArgumentScaleType = ScaleType.Numerical;series2.ArgumentDataMember = "Argument";//设置参数数据字段的名称series2.ValueScaleType = ScaleType.Numerical;series2.ValueDataMembers.AddRange(new string[] { "Value" });series2.DataSource = table;
}

2、创建系列

/// <summary>
/// 创建系列
/// </summary>
/// <param name="Caption">图形标题</param>
/// <returns></returns>
private Series CreateSeries(string Caption)
{// Create a point series.创建一个点系列Series series1 = new Series(Caption, ViewType.Point);series1.CrosshairEnabled = DevExpress.Utils.DefaultBoolean.Default; //获取或设置一个值,该值指定此系列是否启用十字准线游标。series1.CrosshairLabelVisibility = DevExpress.Utils.DefaultBoolean.True;//指定是否在特定的2D DEVExt.xCARTARTSs系列的图表上显示十字准线标签。series1.CrosshairLabelPattern = "坐标:({A},{V})";//获取或设置一个字符串表示指定要在当前系列的瞄准线标签中显示的文本的模式series1.CrosshairHighlightPoints = DevExpress.Utils.DefaultBoolean.Default;//获取或设置一个值,该值指定当十字准线光标悬停时,系列点是否突出显示。// Set the numerical argument scale type for the series,as it is qualitative, by default.series1.ArgumentScaleType = ScaleType.Numerical;   //指定系列的参数刻度类型。默认为(ScaleType.Auto)series1.ValueScaleType = ScaleType.Numerical;  //指定系列的取值刻度类型series1.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;  //是否显示系列点标签series1.LegendText = Caption;//设置标志系列的图例文本//调整 系列点标签PointSeriesLabel myLable1 = (PointSeriesLabel)series1.Label;myLable1.Angle = 0;//获取或设置控制数据点标签位置的角度myLable1.TextPattern = "坐标:({A},{V})";//获取或设置一个字符串,该字符串表示指定要在系列标注标签中显示的文本的模式。myLable1.Position = PointLabelPosition.Outside;//获取或设置点标记所在的位置。myLable1.ResolveOverlappingMode=ResolveOverlappingMode.Default;//启用系列标签的自动冲突检测和解决// 点系列视图属性设置PointSeriesView myView1 = (PointSeriesView)series1.View;//转换系列的视图类型为点类型myView1.PointMarkerOptions.Kind = MarkerKind.Star;//标记的形状myView1.PointMarkerOptions.StarPointCount = 5;//设置星形标记具有的点数myView1.PointMarkerOptions.Size = 8;//标记大小//在不同的窗格中显示系列//myView1.Pane—— 在 属性 窗口中展开 XYDiagramSeriesViewBase.Pane 属性的下拉菜单,并单击 New pane(新建窗格) 菜单项。return series1;
}

3、图像设置

/// <summary>
/// 图像设置
/// </summary>
/// <param name="pointChart">图表控件</param>
private void SetDiagarm(ChartControl pointChart)
{// Access the diagram's properties.把 Diagram 对象转换为所需的图象类型XYDiagram diagram = (XYDiagram)pointChart.Diagram;diagram.Rotated = false;//图像是否旋转diagram.EnableAxisXScrolling = true;//X轴是否允许滚动diagram.EnableAxisXZooming = true;//X轴是否允许缩放diagram.PaneLayoutDirection = PaneLayoutDirection.Horizontal;//窗格的对齐方式// Customize the appearance of the X-axis title.调整 X-轴AxisX xAxis = diagram.AxisX;//获取X轴xAxis.Alignment = AxisAlignment.Near;//指定轴相对于另一主轴的位置。属性 AxisAlignment.Zero 设置仅对主轴可用xAxis.Title.Text = "X轴";//设置轴标题xAxis.Title.Visibility = DevExpress.Utils.DefaultBoolean.True; //是否显示轴标题xAxis.Label.TextPattern = "";//防止过长的轴标签产生重叠xAxis.Label.Angle = -45;//设置轴标签文本旋转的角度xAxis.Label.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.Default;//获取或设置是否对轴标签的文本应用反走样(平滑)xAxis.Label.Staggered = true;//轴标签是否是交错排列的//轴取值的范围是自动确定的(当启用了  xAxis.WholeRange.Auto 属性时),也可以人工指定两个轴取值来限定轴的范围//xAxis.WholeRange.Auto = false;//xAxis.WholeRange.MaxValue = 70;//xAxis.WholeRange.MinValue = -70;//通过 AxisBase.Logarithmic 和 AxisBase.LogarithmicBase 属性,以对数来呈现轴的取值。//xAxis.Logarithmic = true;//xAxis.LogarithmicBase = 10;// Create a constant line. 设置常数线ConstantLine constantLine1 = new ConstantLine("Constant Line 1");xAxis.ConstantLines.Add(constantLine1);// Create a strip with its maximum and minimum axis value defined.数值带xAxis.Strips.Add(new Strip("Strip 1", 5, 15));// Enable automatic scale breaks creation, and define their maximum number.启用自动刻度分隔线diagram.AxisY.AutoScaleBreaks.Enabled = true;diagram.AxisY.AutoScaleBreaks.MaxCount = 5;// Add scale breaks to the Y-axis collection, with their Edge1 and Edge2 properties defined in the constructor.人工把刻度分隔线插入到轴中diagram.AxisY.ScaleBreaks.Add(new ScaleBreak("Scale Break 1", 10, 100));diagram.AxisY.ScaleBreaks.Add(new ScaleBreak("Scale Break 2", 110, 2000));// Customize the appearance of the axes' grid lines.网格显示和设置diagram.AxisY.GridLines.Visible = true;diagram.AxisY.GridLines.MinorVisible = true;// Customize the appearance of the axes' tickmarks.刻度线显示和设置diagram.AxisY.Tickmarks.Visible = false;diagram.AxisY.Tickmarks.MinorVisible = false;//定制窗格的滚动条的外观ScrollBarOptions scrollBarOptions = diagram.DefaultPane.ScrollBarOptions;scrollBarOptions.BackColor = Color.White;scrollBarOptions.BarColor = Color.Blue;scrollBarOptions.BorderColor = Color.Navy;scrollBarOptions.BarThickness = 15;scrollBarOptions.XAxisScrollBarAlignment = ScrollBarAlignment.Far;scrollBarOptions.XAxisScrollBarVisible = true;// Obtain a diagram and clear its collection of panes.diagram.Panes.Clear();// Create a pane for each series.for (int i = 1; i < pointChart.Series.Count; i++){XYDiagramPane pane = new XYDiagramPane("The Pane's Name");diagram.Panes.Add(pane);XYDiagramSeriesViewBase view = (XYDiagramSeriesViewBase)pointChart.Series[i].View;view.Pane = pane;}AxisY myAxis = ((XYDiagram)pointChart.Diagram).AxisY;
}

4、创建辅助轴

/// <summary>
/// 创建图表的第二坐标系
/// </summary>
/// <param name="series">Series对象</param>
/// <returns></returns>
private SecondaryAxisY CreateAxisY(Series series, ChartControl chartControl)
{// Create secondary axes, and add them to the chart's Diagram.SecondaryAxisY myAxis = new SecondaryAxisY(series.Name);((XYDiagram)chartControl.Diagram).SecondaryAxesY.Add(myAxis);// Assign the series2 to the created axes.((PointSeriesView)series.View).AxisY = myAxis;//为当前系列指定Y轴myAxis.Title.Text = "A Secondary Y-Axis";myAxis.Title.Alignment = StringAlignment.Far; //顶部对齐myAxis.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;myAxis.Title.Font = new Font("宋体", 9.0f);series.View.Color = Color.Green;Color color = series.View.Color;//设置坐标的颜色和图表线条颜色一致myAxis.Title.TextColor = color;myAxis.Label.TextColor = color;myAxis.Color = color;return myAxis;
}

Dev中ChartControl——属性熟悉与简单应用相关推荐

  1. Dev中ChartControl添加限定线

    1.单击Y轴,设置属性 2.点击ConstantLines属性,打开"Constant Line Collection Editor"界面 3.点击Add添加线条 4.通过设置Ap ...

  2. 熟悉html css,编写HTML和CSS的前端开发中不一定熟悉JavaScript

    原标题:编写HTML和CSS的前端开发中不一定熟悉JavaScript 作为前端开发人员,HTML.css.Java是必备的知识技能,但是现实工作工作中并非所有的前端都知道Java,根据外国一个网站的 ...

  3. java中使用配置文件_Java中使用Properties配置文件的简单方法

    Java中使用Properties配置文件的简单方法 properties Properties文件是java中的一种配置文件,文件后缀为".properties",文件的内容格式 ...

  4. 【CSS】CSS中alt属性和title属性用法

    你对CSS中的alt属性和title属性的使用是否熟悉,这里和大家分享一下两者的使用,CSS中alt属性只能用在img.area和input元素中(包括applet元素),对于input元素,alt属 ...

  5. Iframe用法的详细讲解(属性、透明、自适应高度)和html中滚动条属性设置

    Iframe 用法的详细讲解(属性.透明.自适应高度)和html中滚动条属性设置 scrollbar属性.样式详解 1. overflow内容溢出时的设置(设定被设定对象是否显示滚动条) overfl ...

  6. CSS3中font-face属性的用法详解

    CSS3中font-face属性的用法详解 @font-face是CSS3中的一个模块,主要是把自定义的Web字体嵌入到你的网页中,随着@font-face模块的出现,我们在Web的开发中使用字体不怕 ...

  7. html的meta总结,html标签中meta属性使用介绍和   动态替换字符串

    http://www.haorooms.com/post/html_meta_ds http://www.haorooms.com/archives里面的东西比较多,需要细看一下 http://www ...

  8. 理解 Kotlin 中的属性(property)

    这篇文章是一时兴起想写的,因为我发现我对Kotlin的属性理解一直有误 Java 中的属性是什么(property) 首先我们要搞清楚在 Java 中属性是什么,在 Java 中类的属性不是指一个字段 ...

  9. JavaScript中的属性:如何遍历属性

    JavaScript中的属性:如何遍历属性 在JavaScript中,遍历一个对象的属性往往没有在其他语言中遍历一个哈希(有些语言称为字典)的键那么简单.这主要有两个方面的原因:一个是,JavaScr ...

  10. C# 控件开发中常用属性整理

    Browsable 适用于属性和事件,指定属性或事件是否应该显示在属性浏览器中. Category 适用于属性和事件,指定类别的名称,在该类别中将对属性或事件进行分组.当使用了类别时,组件属性和事件可 ...

最新文章

  1. NR 5G 身份标识
  2. docker查询mysql 有哪些版本的镜像_CentOS安装Docker环境和mysql镜像的记录
  3. 计时器Chronometer和时钟(AnalogClock和DigitalClock)
  4. Java类型FloatDouble
  5. [转]我们为什么要用vue,他解决了什么问题,如何使用它?
  6. 递归应用场景和调用机制
  7. 水土保持功能评估中k值的计算公式
  8. html5表单修改颜色,在css中更改输入搜索表单的背景色
  9. mdac版本过低怎么解决_工业铝型材硬度过低怎么解决
  10. 伍德里奇计量经济学导论之计算机操作题的R语言实现(简单线性回归)
  11. lammps数据后处理:Python ovito 计算输出位错线长度
  12. java实现三进制转十进制
  13. KubeSphere介绍和基于K8S的安装
  14. B站最全Redis教程全集(2021最新版)(图灵学院诸葛)学习笔记一--五种数据结构与应用场景
  15. Android Miracast 花屏问题分析
  16. 老子云打造3D技术云服务平台,加速三维互联网变革进程
  17. 【阿里云·云原生架构·白皮书】保姆级解读 一、 云原生架构定义
  18. win32 24内存管理和文件操作
  19. 使用POI对excel文件进行读取
  20. ROOK-01 集群简单搭建和卸载

热门文章

  1. 谷歌推出全能扒谱AI:只要听一遍歌曲,钢琴小提琴的乐谱全有了
  2. Python编程:从入门到实践 11-3
  3. 一种基于 JEP 和可配置公式实现用户自定义字段的解决方案
  4. Hyperion神器之SmartView产品(中篇)
  5. mac 自带连接ftp服务器,Mac自带FTP工具使用
  6. win10计算机管理看不见蓝牙,解决win10蓝牙开关不见了的方法
  7. java调用iec61850_IEC61850开发实战(三)
  8. 尚硅谷大数据之数据质量管理
  9. c语言标准流程图,c语言设计流程图!设计流程图
  10. en55032最新标准下载_欧盟EMC标准EN55032介绍。