关于Lightning Chart 的 ClipAreas 与 DataBreaking

想要实现的效果:

实现方式一:

使用DataBreaking实现

(1)曲线启用DataBreaking

_chart.ViewXY.PointLineSeries[0].DataBreaking.Enabled = true;

(2)向曲线添加数据点时设置如下:

         要中断的位置对应的Y轴值是double.NaN,X轴值按正常方式设置


            //Convert 'Now' to X value 
            double _previousX = _chart.ViewXY.XAxes[0].DateTimeToAxisValue(lasttime);

            //Store the X value
            points[0].X = _previousX;


            if (statusStop)
            {
                //Randomize and store Y value 
                points[0].Y = double.NaN;
            }
            else
            {
                //Randomize and store Y value 
                points[0].Y = CalculateYValue();
            }

            //Add the new point into end of first PointLineSeries
            _chart.ViewXY.PointLineSeries[0].AddPoints(points, false);

实现方式二:

使用ClipArea实现: 

        /// <summary>
        /// 当前的状态:运行状态,或暂停状态
        /// </summary>
        bool statusStop = false;

        /// <summary>
        /// 中断对象列表
        /// </summary>
        List<ClipArea> clips = new List<ClipArea>();

        private void btnStartOrPause_Click(object sender, EventArgs e)
        { 
            if ((sender as Button).Text == "开始")
            {
                this.timer1.Enabled = true;
                (sender as Button).Text = "停止";

                DateTime time = DateTime.Now;

                double d1 = _chart.ViewXY.XAxes[0].DateTimeToAxisValue(lasttime);
                double d2 = _chart.ViewXY.XAxes[0].DateTimeToAxisValue(time);


                _chart.BeginUpdate();

                ClipArea clipArea = new ClipArea(d1, d2, ClipDirection.X);

                clips.Add(clipArea);
                
                _chart.ViewXY.PointLineSeries[0].SetClipAreas(clips.ToArray()); 
                _chart.EndUpdate();
            }
            else
            {
                this.timer1.Enabled = false;
                (sender as Button).Text = "开始";
            }
        }


文档上关于DataBreaking的介绍:

文档上关于ClipArea的介绍:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值