关键代码:

        /// <summary>
        /// 创建基准线ConstantLine
        /// </summary>
        /// <param name="chart">ChartControl</param>
        /// <param name="ctAxisValue">基准线数值</param>
        /// <param name="ctLegendText">基准线图例文字</param>
        /// <param name="ctTitle">基准线文字</param>
        /// <param name="ctTitleColor">基准线字体颜色</param>
        /// <param name="ctLineColor">基准线颜色</param>
        /// <param name="ctLineStyle">基准线样式</param>
        public static void CreateConstantLine(this ChartControl chart, int ctAxisValue, string ctLegendText, string ctTitle, Color ctTitleColor, Color ctLineColor, DashStyle ctLineStyle)
        {
            XYDiagram _diagram = (XYDiagram)chart.Diagram;
            if (_diagram != null)
            {
                ConstantLine _ctLine = new ConstantLine();

                _ctLine.AxisValue = ctAxisValue;
                _ctLine.Visible = true;
                _ctLine.ShowInLegend = true;
                _ctLine.LegendText = ctLegendText;
                _ctLine.ShowBehind = false;

                _ctLine.Title.Visible = true;
                _ctLine.Title.Text = ctTitle;
                _ctLine.Title.TextColor = ctTitleColor;
                _ctLine.Title.Antialiasing = false;
                _ctLine.Title.Font = new Font("Tahoma", 14, FontStyle.Bold);
                _ctLine.Title.ShowBelowLine = true;
                _ctLine.Title.Alignment = ConstantLineTitleAlignment.Far;

                _ctLine.Color = ctLineColor;
                _ctLine.LineStyle.DashStyle = ctLineStyle;
                _ctLine.LineStyle.Thickness = 2;

                _diagram.AxisY.ConstantLines.Add(_ctLine);
            }
        }

代码使用:

chartControl1.CreateConstantLine(25, "理论利润", "理论利润", Color.Red, Color.Red, DashStyle.Dash);

运行效果:

希望有所帮助!谢谢!

[DevExpress]ChartControl之基准线示例的更多相关文章

  1. [DevExpress]ChartControl之柱状图示例

    关键代码: using System; using System.Data; using System.Windows.Forms; using CSharpUtilHelpV2; using Dev ...

  2. [DevExpress]ChartControl之SeriesTemplate示例

    关键代码: using System; using System.Data; using System.Windows.Forms; using CSharpUtilHelpV2; using Dev ...

  3. [DevExpress]ChartControl之滚动条示例

    关键代码: /// <summary> /// 设置ChartControl滚动条[默认X,Y轴都出现] /// </summary> /// <param name=& ...

  4. DevExpress ChartControl大数据加载时有哪些性能优化方法

    DevExpress ChartControl加载大数据量数据时的性能优化方法有哪些? 关于图表优化,可从以下几个方面解决: 1.关闭不需要的可视化的元素(如LineMarkers, Labels等) ...

  5. [DevExpress]ChartControl之时间轴示例

    关键代码: using System; using System.Data; using System.Windows.Forms; using DevExpress.XtraCharts; name ...

  6. [DevExpress]ChartControl之创建X,Y轴Title示例

    关键代码: /// <summary> /// 设置X轴Title /// </summary> /// <param name="chart"> ...

  7. [DevExpress]ChartControl之饼状图百分比示例

    关键代码: using System; using System.Data; using System.Windows.Forms; using DevExpress.XtraCharts; name ...

  8. DevExpress .NET界面开发示例大全

    说到做.net界面开发,很多人应该都会想到DevExpress. 它的 .net界面开发系列一共有7个版本:WinForms.ASP.NET.MVC.WPF.Silverlight.Windows 8 ...

  9. 初识Devexpress ChartControl 之 动态添加stepline及TextAnnotation

    最近在用devexpress 第三方软件做项目. devexpress 的控件使用简单.功能强大.类型丰富.界面优美.扩展性强.今天主要是动态生成了一条StepLine.生成后的效果(能力不强,所以做 ...

随机推荐

  1. 数据库插入某些数据会变成?,或则select无法读出数据库中的某些数据

    如果你想在数据库中插入“uɷ”,这个字符,直接插入 insert into table value (‘uɷ’),是不行的,这样插入的后果是打开数据后会显示为u?.当你面对这个问题的时候是不是第一个想 ...

  2. PHP: 深入pack/unpack 字节序

    http://my.oschina.net/goal/blog/195749?p=1 目录[-] 写在前面的话 什么是字节序 MSB和LSB 大端序 小端序 网络字节序 主机字节序 总结 pack/u ...

  3. c# TCP/IP编程

    这东西很多朋友都有写过了,我也就写着玩玩,就当做个笔记吧.不废话了. TCP/IP在数据通信中被广泛的使用,自然得包含客户端和服务端,当然,自己自言自语不是什么不可以,可那样貌似有点神经. 好了,那就 ...

  4. View绘制详解(五),draw方法细节详解之View的滚动/滑动问题

    关于View绘制系列的文章已经完成了四篇了,前面四篇文章主要带小伙伴们熟悉一下View的体系的整体框架.View的测量以及布局等过程,从本篇博客开始,我们就来看看View的绘制过程.View的绘制涉及 ...

  5. 属性声明(property declarations), 自定义属性,自动生成 get 和 set 方法,getter 和 setter

    属性声明(property declarations), 自定义属性,自动生成 get 和 set 方法,getter 和 setter 一.普通的get 和set 属性. 一般的get 和set 属 ...

  6. 显示创建一个表的SQL语句

    显示创建数据库中包的语句,从而可以方便的对表的结构进行修改和复制(当然还有其他的方式) 显示表结构: 显示创建表语句: show create table tablename;

  7. [未完成]plugin.xml文件

    此文章部分转自:http://fxzcollege6.iteye.com/blog/2013055 关于plugin.xml文件我还总结过一篇文章:http://www.cnblogs.com/Dre ...

  8. 定义label标签宽度需要设置display:inline-block;

    label{    display:inline-block;     width:120px;    line-height:22px;    text-align: right;}

  9. Xcode编译时出现cannot run using the selected device提示

    很多文章说这个管用: 1) Project->Info->Deployment Target->iOS Deployment Target更改为<=设备的版本号; 2) Tar ...

  10. Ehcache(2.9.x) - API Developer Guide, Class Loading

    About Class Loading Class loading, within the plethora of environments that Ehcache can be running, ...