[DevExpress]ChartControl之滚动条示例

关键代码:

        /// <summary>
        /// 设置ChartControl滚动条【默认X,Y轴都出现】
        /// </summary>
        /// <param name="chart">ChartControl</param>
        /// <param name="backColor">滚动条背景颜色</param>
        /// <param name="barColor">滚动条颜色</param>
        /// <param name="borderColor">滚动条边框颜色</param>
        /// <param name="barThickness">滚动条宽度</param>
        public static ScrollBarOptions SetScrollBar(this ChartControl chart, Color backColor, Color barColor, Color borderColor, int barThickness)
        {
            XYDiagram _diagram = (XYDiagram)chart.Diagram;
            if (_diagram != null)
            {
                _diagram.EnableAxisXScrolling = true;
                _diagram.EnableAxisYScrolling = true;
                _diagram.EnableAxisXZooming = true;
                _diagram.EnableAxisYZooming = true;
                ScrollBarOptions _scrollBarOptions = _diagram.DefaultPane.ScrollBarOptions;
                _scrollBarOptions.BackColor = backColor;
                _scrollBarOptions.BarColor = barColor;
                _scrollBarOptions.BorderColor = borderColor;
                _scrollBarOptions.BarThickness = barThickness;
                return _scrollBarOptions;
            }
            return null;
        }
        /// <summary>
        /// 设置ChartControl X轴滚动条
        /// </summary>
        /// <param name="chart">ChartControl</param>
        /// <param name="backColor">滚动条背景颜色</param>
        /// <param name="barColor">滚动条颜色</param>
        /// <param name="borderColor">滚动条边框颜色</param>
        /// <param name="barThickness">滚动条宽度</param>
        /// <param name="barAlignment">滚动条位置</param>
        public static void SetAxisXScrollBar(this ChartControl chart, Color backColor, Color barColor, Color borderColor, int barThickness, ScrollBarAlignment barAlignment)
        {
            ScrollBarOptions _scrollBarOptions = SetScrollBar(chart, backColor, barColor, borderColor, barThickness);
            if (_scrollBarOptions != null)
            {
                _scrollBarOptions.XAxisScrollBarAlignment = barAlignment;
                _scrollBarOptions.XAxisScrollBarVisible = true;
                _scrollBarOptions.YAxisScrollBarVisible = false;
            }
        }
        /// <summary>
        /// 设置ChartControl Y轴滚动条
        /// </summary>
        /// <param name="chart">ChartControl</param>
        /// <param name="backColor">滚动条背景颜色</param>
        /// <param name="barColor">滚动条颜色</param>
        /// <param name="borderColor">滚动条边框颜色</param>
        /// <param name="barThickness">滚动条宽度</param>
        /// <param name="barAlignment">滚动条位置</param>
        public static void SetAxisYScrollBar(this ChartControl chart, Color backColor, Color barColor, Color borderColor, int barThickness, ScrollBarAlignment barAlignment)
        {
            ScrollBarOptions _scrollBarOptions = SetScrollBar(chart, backColor, barColor, borderColor, barThickness);
            if (_scrollBarOptions != null)
            {
                _scrollBarOptions.XAxisScrollBarVisible = false;
                _scrollBarOptions.YAxisScrollBarVisible = true;
                _scrollBarOptions.YAxisScrollBarAlignment = barAlignment;
            }
        }

运行效果:

希望有所帮助,谢谢!

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

时间: 2025-01-09 07:02:29

[DevExpress]ChartControl之滚动条示例的相关文章

[DevExpress]ChartControl之基准线示例

关键代码: /// <summary> /// 创建基准线ConstantLine /// </summary> /// <param name="chart">ChartControl</param> /// <param name="ctAxisValue">基准线数值</param> /// <param name="ctLegendText">基准线图例文

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

DevExpress ChartControl加载大数据量数据时的性能优化方法有哪些? 关于图表优化,可从以下几个方面解决: 1.关闭不需要的可视化的元素(如LineMarkers, Labels等): Series.View.LineMarkerOptions.Visible =false. 2. 关闭图表的滚动与缩放功能,手动调整范围,这样将大大减少所需计算的个数. 3. 将 ChartControl.RefreshDataOnRepaint属性设为false 4. 将 ChartContr

[DevExpress]ChartControl之时间轴示例

关键代码: using System; using System.Data; using System.Windows.Forms; using DevExpress.XtraCharts; namespace DevExpressChart { public partial class winDateTime : Form { public winDateTime() { InitializeComponent(); } private void winDateTime_Load(object

[DevExpress]ChartControl之自定义Tooltip示例

关键代码: /// <summary> /// 自定义ChartControl的Tooltip /// </summary> /// <param name="chart">ChartControl</param> /// <param name="e">MouseEventArgs</param> /// <param name="tooltip">ToolTi

[DevExpress]ChartControl之创建Strip示例

关键代码: /// <summary> /// 创建Strip /// </summary> /// <param name="chart">ChartControl</param> /// <param name="strip">Strip</param> /// <param name="stripLable">Strip文字</param> //

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

关键代码: /// <summary> /// 设置X轴Title /// </summary> /// <param name="chart">ChartControl</param> /// <param name="titleText">Title文字</param> /// <param name="titleColor">Title文字颜色</pa

WPF DevExpress ChartControl使用之XYDiagram

WPF使用Dev和WinForm有许多不同,相对而言,WPF要更简单和炫酷一点,我只做了一点基本的功能,没有仔细的研究,这里只介绍一下WPF Dev ChartControl绘制XYDiagram的基础. XYDiagramControl.xaml页面 <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microso

devexpress显示缓冲滚动条与实现类似QQ消息推送效果

1.一般在项目中处理大数据,或者查询大量数据时,耗时会很长,这个时候缓冲条是必不可少的.这里展示一个devexpress不错的缓冲条,如图所示: 使用到了控件splashScreenManager,运行代码如下: splashScreenManager1.ShowWaitForm(); Thread.Sleep(5000);//需长时间运行的代码,这里用线程控制运行时间代替 splashScreenManager1.CloseWaitForm(); 2.有时候一些消息推送功能也能给一个系统加分不

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

最近在用devexpress 第三方软件做项目. devexpress 的控件使用简单.功能强大.类型丰富.界面优美.扩展性强.今天主要是动态生成了一条StepLine.生成后的效果(能力不强,所以做的比较简单.): 首先,建立一个form(普通的或ribbonform均可),然后拖拽一个chartControl到form中.右键run warzid.然后将预设的线条删除(因为我们要动态添加). 然后查看form代码.在构造函数中添加方法调用InitCharControl(); 然后新建Init