标签:style blog http color os ar 使用 sp 2014
关键代码:
/// <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之基准线示例
标签:style blog http color os ar 使用 sp 2014
原文地址:http://www.cnblogs.com/Yan-Zhiwei/p/4042578.html