关键代码:

        /// <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. int a[5]={}, &a+1与(int*)a+1的区别

    #include <iostream> #include <typeinfo> using namespace std; int main() { int b, *pb; ch ...

  2. 初步认知MySQL metadata lock(MDL)

    http://blog.itpub.net/26515977/viewspace-1208250/ 概述 随着5.5.3引入MDL,更多的Query被“Waiting for table metada ...

  3. 十六款值得关注的NoSQL与NewSQL数据库--转载

    原文地址:http://tech.it168.com/a2014/0929/1670/000001670840_all.shtml [IT168 评论]传统关系型数据库在诞生之时并未考虑到如今如火如荼 ...

  4. cocos2dx新建android项目lib拷贝、访问权限等问题集

    win7上面搭建cocos2dx的android项目,用create-android-project.bat新建一个项目时,出现了访问权限和项目无lib的问题. 解决方案: 1.项目无lib问题. 当 ...

  5. Android(java)学习笔记116:PC_Phone通信程序报错

    1.首先我写的程序代码如下: package com.himi.udpsend; import java.net.DatagramPacket; import java.net.DatagramSoc ...

  6. Redis' High Availability

    Redis Sentinel is a system designed to help managing Redis instances. It performs the following thre ...

  7. [改善Java代码]不推荐使用binarySearch对列表进行检索

    对一个列表进行检索时,我们使用的最多的是indexOf方法,它简单好用,而且也不会出错,虽然它只能检索到第一个符合条件的值,但是我们可以生成子列表后再检索.这样也就可以查找到所有符合条件的值了. Co ...

  8. JAVA基础之理解JNI原理

    JNI是JAVA标准平台中的一个重要功能,它弥补了JAVA的与平台无关这一重大优点的不足,在JAVA实现跨平台的同时,也能与其它语言(如C.C++)的动态库进行交互,给其它语言发挥优势的机会. 有了J ...

  9. ActiveMQ 的安装

    1. 在 http://activemq.apache.org/ 下载 ActiveMQ.Windows 系统选择下载 apache-activemq-x.x.x-bin.zip,Unix/Linux ...

  10. ios中Raw文件系统常用文件夹

    1.[/Applications] 常用软件的安装目录 2.[/Applications/Preferences.app/zh_CN.lproj] 软件Preferences.app的中文汉化文件存放 ...