ningshuxia
2025-03-31 d321346f204a69b1929cc39098a5d88f44509e7b
02-desktop/WinFrmUI/IStation.WinFrmUI.Monitor/00-Core/02-Monitor/Chart/TimeValueSwiftPlotChartView.cs
@@ -1,5 +1,4 @@
using DevExpress.XtraCharts;
using DevExpress.XtraSplashScreen;
using System;
using System.Collections.Generic;
using System.Data;
@@ -35,15 +34,15 @@
            //this.moniotrChartControl.Legend.Direction = LegendDirection.BottomToTop;//获取或设置在该图例中显示系列名称的方向。
            //this.moniotrChartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;//是否在图表上显示图例
            this.moniotrChartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;//是否在图表上显示图例
            this.moniotrChartControl.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.RightOutside;
            this.moniotrChartControl.Legend.AlignmentVertical = LegendAlignmentVertical.Top;
            this.moniotrChartControl.Legend.TextVisible = true;
            this.moniotrChartControl.Legend.MarkerMode= LegendMarkerMode.CheckBoxAndMarker;
            moniotrChartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;//是否在图表上显示图例
            moniotrChartControl.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.RightOutside;
            moniotrChartControl.Legend.AlignmentVertical = LegendAlignmentVertical.Top;
            moniotrChartControl.Legend.TextVisible = true;
            moniotrChartControl.Legend.MarkerMode = LegendMarkerMode.CheckBoxAndMarker;
            // Access the diagram's properties.把 Diagram 对象转换为所需的图象类型
            _diagram = (SwiftPlotDiagram)this.moniotrChartControl.Diagram;
            _diagram = (SwiftPlotDiagram)moniotrChartControl.Diagram;
            //_diagram.Rotated = false;//图像是否旋转
            _diagram.EnableAxisXScrolling = true;//X轴是否允许滚动
            _diagram.EnableAxisXZooming = true;//X轴是否允许缩放
@@ -153,7 +152,7 @@
        /// </summary>
        private void InitialBoxSelHelper()
        {
            _boxSelHelper = new ChartBoxSelHelper(this.moniotrChartControl);
            _boxSelHelper = new ChartBoxSelHelper(moniotrChartControl);
            _boxSelHelper.BoxSelCompletedEvent += _boxSelHelper_BoxSelCompletedEvent;
        }
@@ -182,7 +181,7 @@
        //结束框选
        public void CloseBoxSel()
        {
            this._boxSelHelper.CloseBoxSel();
            _boxSelHelper.CloseBoxSel();
        }
        //框选辅助类
@@ -199,10 +198,10 @@
                return;
            }
            if (this.BoxSelCompleteEvent != null)
            if (BoxSelCompleteEvent != null)
            {
                var list = boxSelSeriesPointList.Select(x => x.Tag as TimeValue).ToList();
                this.BoxSelCompleteEvent.Invoke(_boxSelTag, list);
                BoxSelCompleteEvent.Invoke(_boxSelTag, list);
            }
        }
@@ -224,7 +223,7 @@
        /// <param name="timeValues">系列的数据源</param>
        public void InitialDefaultSeries(string seriesName, IEnumerable<TimeValue> timeValues)
        {
            _defaultSeries = this.moniotrChartControl.Series[0];
            _defaultSeries = moniotrChartControl.Series[0];
            _defaultSeries.Tag = "default";
            _defaultSeries.Name = seriesName;
            if (timeValues == null || timeValues.Count() < 1)
@@ -262,7 +261,7 @@
        public void AddSwiftPlotSeries(string id, Color color, string caption, string axisYTitle, List<TimeValue> timeValues)
        {
            //IOverlaySplashScreenHandle lays = null;
            if (this.moniotrChartControl.Series.Count < 1)
            if (moniotrChartControl.Series.Count < 1)
            {
                _defaultAxisY.Title.Text = axisYTitle;
            }
@@ -297,27 +296,27 @@
                swiftPlotSeriesView.AxisY = _diagram.AxisY;
            }
            else
            {
            {
                var exist = _diagram.SecondaryAxesY.GetAxisByName(axisYTitle);
                if (exist == null)
                {
                    AddAxisY(series, axisYTitle);
                }
                else
                {
                {
                    swiftPlotSeriesView.AxisY = exist;
                }
            }
            if (timeValues != null && timeValues.Any())
            {
                series.BindToData(timeValues, "Time", "Value");
            }
            this.moniotrChartControl.Series.Add(series);
            moniotrChartControl.Series.Add(series);
        }
@@ -350,17 +349,17 @@
        /// </summary> 
        public void RemoveSeries(string id)
        {
            var lays = this.moniotrChartControl.ShowOverlay();
            var seriesCount = this.moniotrChartControl.Series.Count;
            var lays = moniotrChartControl.ShowOverlay();
            var seriesCount = moniotrChartControl.Series.Count;
            if (seriesCount > 0)
            {
                this.moniotrChartControl.BeginInit();
                moniotrChartControl.BeginInit();
                for (int i = 0; i < seriesCount; i++)
                {
                    var series = this.moniotrChartControl.Series[i];
                    var series = moniotrChartControl.Series[i];
                    if (series.Name == id)
                    {
                        this.moniotrChartControl.Series.RemoveAt(i);
                        moniotrChartControl.Series.RemoveAt(i);
                        break;
                    }
                }
@@ -374,7 +373,7 @@
                        break;
                    }
                }
                this.moniotrChartControl.EndInit();
                moniotrChartControl.EndInit();
            }
            lays.Close();
        }
@@ -384,9 +383,9 @@
        /// </summary> 
        public void ClearSeries()
        {
            this.moniotrChartControl.BeginInit();
            this.moniotrChartControl.Series.Clear();
            this.moniotrChartControl.EndInit();
            moniotrChartControl.BeginInit();
            moniotrChartControl.Series.Clear();
            moniotrChartControl.EndInit();
        }