关键代码:

        /// <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. B - Plane of Tanks: Pro

    Description Vasya has been playing Plane of Tanks with his friends the whole year. Now it is time to ...

  2. mybatisGenerator 代码自动生成报错 Result Maps collection already contains value for BaseResultMap【转】

    由于mybatis简单易学,比起Hibername来,更容易上手,代码也能自动生成.这几天研究了下代码自动生成的,参考: http://0609xiaohua.iteye.com/blog/14535 ...

  3. android 读取串口数据的服务

    2016-09-1813:10:03 继承Service,定义抽象方法onDataReceived,子类通过实现抽象方法获取接收到数据的回调. package com.zrsoft.liftad.se ...

  4. <Think Complexity> 用字典实现图

    今天在图书馆闲逛的时候偶然看见<Think Complexity>(复杂性思考)这本书,下午看了一会儿觉得很有意思.本书第二章讲的是用Python实现的图,特别写篇博客记录.   首先,图 ...

  5. linux注销开关机

    注销:exit 重启:reboot shutdown-r 表示延时分钟数   关机:halt shut -h  

  6. javaweb学习总结十一(JAXP对XML文档进行DOM解析)

    一:将内存中写好的xml文件读取到硬盘上 二:DOM方式对xml文件进行增删改查 1:添加节点(默认是在最后的子节点后面添加) @Test // 向元素中添加节点<version>1.0& ...

  7. LeetCode 319

    Bulb Switcher There are n bulbs that are initially off. You first turn on all the bulbs. Then, you t ...

  8. Window 中常见的dos命令

    在哪里操作dos命令:    win7---->开始---->所有程序---->附件---->命令提示符                              win7-- ...

  9. Asp.Net MVC 路由 【转】

    原文链接:http://www.asp.net/learn/mvc/ 在这篇教程中,我将为你介绍每个ASP.NET MVC应用程序都具有的一个重要功能,称作ASP.NET路由(ASP.NET Rout ...

  10. sql server 2008 查询语句的红色波浪线

    在 Microsoft sql server management studio 里点击“编辑”——“IntelliSense”——“刷新本地缓存” 就会发现红色波浪线没了(前提是你的代码没错)