Beispiel #1
0
        private void CreateChart()
        {
            gridChart.Children.Clear();
            if (m_chart != null)
            {
                m_chart.Dispose();
                m_chart = null;
            }

            m_chart = new LightningChartUltimate(LicenseKeyStrings.LightningChartUltimate);
            m_chart.BeginUpdate();
            m_chart.Title.Text = "";
            m_chart.ViewXY.AxisLayout.YAxesLayout        = YAxesLayout.Segmented;
            m_chart.ViewXY.AxisLayout.YAxisAutoPlacement = YAxisAutoPlacement.LeftThenRight;
            // m_chart.ViewXY.AxisLayout.AutoAdjustAxisGap = 0;

            m_chart.Background                          = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            m_chart.ChartBackground.Color               = Color.FromArgb(0, 0, 0, 0);
            m_chart.ChartBackground.GradientFill        = GradientFill.Solid;
            m_chart.ViewXY.GraphBackground.Color        = Color.FromArgb(0, 0, 0, 0);
            m_chart.ViewXY.GraphBackground.GradientFill = GradientFill.Solid;
            m_chart.ViewXY.GraphBorderColor             = Color.FromArgb(0, 0, 0, 0);

            m_chart.ViewXY.XAxes[0].ValueType         = AxisValueType.Number;
            m_chart.ViewXY.XAxes[0].Minimum           = 0;
            m_chart.ViewXY.XAxes[0].Maximum           = 1000;
            m_chart.ViewXY.XAxes[0].Title.Visible     = false;
            m_chart.ViewXY.XAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.XAxes[0].AxisThickness     = 2;
            m_chart.ViewXY.XAxes[0].AxisColor         = Color.FromArgb(100, 135, 205, 238);
            m_chart.ViewXY.XAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.XAxes[0].LabelsFont        = new WPFFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);

            m_chart.ViewXY.YAxes.Clear();
            m_chart.ViewXY.AxisLayout.Segments.Clear();

            m_chart.ViewXY.LegendBox.Visible        = true;
            m_chart.ViewXY.LegendBox.Layout         = LegendBoxLayout.VerticalColumnSpan;
            m_chart.ViewXY.LegendBox.Fill.Style     = RectFillStyle.None;
            m_chart.ViewXY.LegendBox.Shadow.Visible = false;
            m_chart.ViewXY.LegendBox.BorderWidth    = 0;
            m_chart.ViewXY.LegendBox.Position       = LegendBoxPosition.TopRight;
            m_chart.ViewXY.LegendBox.Offset.SetValues(-50, 10);
            m_chart.ViewXY.LegendBox.SeriesTitleFont = new WPFFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);
            //Add cursor
            LineSeriesCursor cursor = new LineSeriesCursor(m_chart.ViewXY, m_chart.ViewXY.XAxes[0]);

            m_chart.ViewXY.LineSeriesCursors.Add(cursor);
            cursor.PositionChanged  += new LineSeriesCursor.PositionChangedHandler(cursor_PositionChanged);
            cursor.LineStyle.Color   = System.Windows.Media.Color.FromArgb(150, 255, 0, 0);
            cursor.LineStyle.Width   = 2;
            cursor.SnapToPoints      = true;
            cursor.TrackPoint.Color1 = Colors.White;
            m_chart.ViewXY.FitView();
            m_chart.EndUpdate();

            gridChart.Children.Add(m_chart);
        }
        private void DrawTimeDomain(bool fitView)
        {
            try
            {
                if (viewModel == null || viewModel.CurrentSnapshotContract == null)
                {
                    return;
                }

                PointLineSeries  series           = m_chart.ViewXY.PointLineSeries[0];
                PointLineSeries  series1          = m_chart.ViewXY.PointLineSeries[1];
                LineSeriesCursor lineSeriesCursor = m_chart.ViewXY.LineSeriesCursors[0];
                int index = GetNearestPointIndex(series, lineSeriesCursor.ValueAtXAxis);
                if (index == -1)
                {
                    if (series1.PointCount > 0)
                    {
                        m_chart.BeginUpdate();
                        series1.Clear();
                        m_chart.EndUpdate();
                    }
                    return;
                }

                SeriesPoint           point         = series.Points[index];
                Guid                  id            = (Guid)point.Tag;
                SnapshotItemContract2 itemContract2 = viewModel.CurrentSnapshotContract.Item.Where(o => o.id == id).SingleOrDefault();
                if (itemContract2 == null)
                {
                    return;
                }
                ChannelDataContract channelData = itemContract2.Data;

                if (channelData != null)
                {
                    int           length = channelData.VData.Length / 4;
                    SeriesPoint[] points = new SeriesPoint[length];
                    for (int i = 0; i < length; i++)
                    {
                        points[i].X = i;
                        points[i].Y = BitConverter.ToSingle(channelData.VData, i * 4);
                    }

                    m_chart.BeginUpdate();
                    series1.Points = points;
                    if (fitView)
                    {
                        m_chart.ViewXY.FitView();
                    }
                    m_chart.EndUpdate();
                }
            }
            catch (Exception ex)
            {
                _eventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("数据回放-报警点趋势-时域", ex));
            }
        }
Beispiel #3
0
        private void UpdateCursorResult()
        {
            m_chart.BeginUpdate();

            LineSeriesCursor cursor             = m_chart.ViewXY.LineSeriesCursors[0];
            AnnotationXY     cursorValueDisplay = m_chart.ViewXY.Annotations[0];
            float            fTargetYCoord      = m_chart.ViewXY.GetMarginsRect().Bottom;
            double           dY;

            m_chart.ViewXY.YAxes[0].CoordToValue(fTargetYCoord, out dY);
            cursorValueDisplay.TargetAxisValues.X = cursor.ValueAtXAxis;
            cursorValueDisplay.TargetAxisValues.Y = dY;

            StringBuilder sb            = new StringBuilder();
            int           iSeriesNumber = 1;

            string strValue      = "";
            bool   bLabelVisible = false;

            int seriesCount = m_chart.ViewXY.PointLineSeries.Count;

            for (int i = 0; i < seriesCount; i++)
            {
                var series = m_chart.ViewXY.PointLineSeries[i];
                strValue = iSeriesNumber + ":";
                VibrationChannelToken token = series.Tag as VibrationChannelToken;
                if (token.VData != null)
                {
                    bool   bResolvedOK = false;
                    double yValue      = 0;
                    bResolvedOK = SolveValueAccurate(series, cursor.ValueAtXAxis, out yValue);
                    if (bResolvedOK)
                    {
                        bLabelVisible = true;
                        //strValue = string.Format(strChannelStringFormat, iSeriesNumber, Math.Round(yValue, 2), unit);
                        strValue += Math.Round(yValue, 2) + "(" + token.VData.Unit + ")";
                    }
                    else
                    {
                        //strValue = string.Format(strChannelStringFormat, iSeriesNumber, "---", "Unit");
                        strValue += "---" + "(Unit)";
                    }
                }

                sb.AppendLine(strValue);
                iSeriesNumber++;
            }

            sb.AppendLine("频率: " + cursor.ValueAtXAxis.ToString("0.00") + "Hz");
            //Set text
            cursorValueDisplay.Text    = sb.ToString().Trim();
            cursorValueDisplay.Visible = bLabelVisible;

            //Allow chart rendering
            m_chart.EndUpdate();
        }
 private void AlarmPointTrendDataView_PositionChanged(LineSeriesCursor sender, double newValue, ref bool cancelRendering)
 {
     if ((bool)timeRadioBtn.IsChecked)
     {
         DrawTimeDomain(false);
     }
     else if ((bool)frequencyRadioBtn.IsChecked)
     {
         DrawFrequencyDomain(false);
     }
 }
Beispiel #5
0
        public void AddVerticalConstantLine(double value, Color color)
        {
            var line = new LineSeriesCursor(ContainerChart.ViewXY, ContainerChart.ViewXY.XAxes[0])
            {
                ValueAtXAxis = 1,
                LineStyle    = { Width = 1 }
            };

            line.LineStyle.Color   = color; Color.FromArgb(200, color.R, color.G, color.B);
            line.FullHeight        = false;
            line.SnapToPoints      = false;
            line.MouseInteraction  = false;
            line.ValueAtXAxis      = value;
            line.Style             = CursorStyle.PointTracking;
            line.TrackPoint.Color1 = Colors.Transparent;
            line.TrackPoint.Color2 = Colors.Transparent;
            line.TrackPoint.Shape  = Shape.Circle;

            ContainerChart.ViewXY.LineSeriesCursors.Add(line);
        }
Beispiel #6
0
        private void DrawFrequencyDomain(bool fitView)
        {
            try
            {
                if (ViewModel == null || ViewModel.CurrentSnapshotContract == null)
                {
                    return;
                }

                PointLineSeries  series           = m_chart.ViewXY.PointLineSeries[0];
                PointLineSeries  series1          = m_chart.ViewXY.PointLineSeries[1];
                LineSeriesCursor lineSeriesCursor = m_chart.ViewXY.LineSeriesCursors[0];
                int index = GetNearestPointIndex(series, lineSeriesCursor.ValueAtXAxis);
                if (index == -1)
                {
                    if (series1.PointCount > 0)
                    {
                        m_chart.BeginUpdate();
                        series1.Clear();
                        m_chart.EndUpdate();
                    }
                    return;
                }
                else
                {
                    SeriesPoint point = series.Points[index];
                    Guid        id    = (Guid)point.Tag;

                    //htzk123,数据
                    //SnapshotItemContract2 itemContract2 = ViewModel.CurrentSnapshotContract.Item.Where(o => o.id == id).SingleOrDefault();
                    //if (itemContract2 == null) return;
                    //ChannelDataContract channelData = itemContract2.Data;

                    //if (channelData != null)
                    //{
                    //    int length = channelData.VData.Length / 4;
                    //    double[] vdata = new double[length];
                    //    for (int i = 0; i < length; i++)
                    //    {
                    //        vdata[i] = BitConverter.ToSingle(channelData.VData, i * 4);
                    //    }

                    //    double frequencyInterval = channelData.SampleFre / channelData.SamplePoint;
                    //    if (channelData.TriggerN == 2)
                    //    {
                    //        frequencyInterval = ((int)channelData.TeethNumber / 2) / length;
                    //    }
                    //    int frequencyLength = (int)(channelData.SamplePoint / 2.56);

                    //    var outputAmp = Algorithm.Instance.FFT2Action(vdata, channelData.SamplePoint);

                    //    m_chart.BeginUpdate();
                    //    if (series1.Points==null||series1.Points.Length != frequencyLength)
                    //    {
                    //        series1.Points = new SeriesPoint[frequencyLength];
                    //    }
                    //    for (int i = 0; i < frequencyLength; i++)
                    //    {
                    //        series1.Points[i].X = frequencyInterval * i;
                    //        series1.Points[i].Y = outputAmp[i];
                    //    }
                    //    if (fitView)
                    //    {
                    //        m_chart.ViewXY.ZoomToFit();
                    //    }
                    //    m_chart.EndUpdate();
                    //}
                }
            }
            catch (Exception ex)
            {
                _eventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("数据回放-报警点趋势-频域", ex));
            }
        }
Beispiel #7
0
        internal override Hashtable ToHashtable()
        {
            Hashtable hashtables                   = new Hashtable();
            bool?     allowPointSelect             = this.AllowPointSelect;
            bool?     allowPointSelectDefaultValue = this.AllowPointSelect_DefaultValue;

            if ((allowPointSelect.GetValueOrDefault() == allowPointSelectDefaultValue.GetValueOrDefault() ? allowPointSelect.HasValue != allowPointSelectDefaultValue.HasValue : true))
            {
                hashtables.Add("allowPointSelect", this.AllowPointSelect);
            }
            if (this.Animation.IsDirty())
            {
                hashtables.Add("animation", this.Animation.ToJSON());
            }
            double?animationLimit             = this.AnimationLimit;
            double?animationLimitDefaultValue = this.AnimationLimit_DefaultValue;

            if ((animationLimit.GetValueOrDefault() == animationLimitDefaultValue.GetValueOrDefault() ? animationLimit.HasValue != animationLimitDefaultValue.HasValue : true))
            {
                hashtables.Add("animationLimit", this.AnimationLimit);
            }
            if (this.ClassName != this.ClassName_DefaultValue)
            {
                hashtables.Add("className", this.ClassName);
            }
            if (this.Color != this.Color_DefaultValue)
            {
                hashtables.Add("color", this.Color);
            }
            animationLimitDefaultValue = this.ColorIndex;
            animationLimit             = this.ColorIndex_DefaultValue;
            if ((animationLimitDefaultValue.GetValueOrDefault() == animationLimit.GetValueOrDefault() ? animationLimitDefaultValue.HasValue != animationLimit.HasValue : true))
            {
                hashtables.Add("colorIndex", this.ColorIndex);
            }
            allowPointSelectDefaultValue = this.ConnectEnds;
            allowPointSelect             = this.ConnectEnds_DefaultValue;
            if ((allowPointSelectDefaultValue.GetValueOrDefault() == allowPointSelect.GetValueOrDefault() ? allowPointSelectDefaultValue.HasValue != allowPointSelect.HasValue : true))
            {
                hashtables.Add("connectEnds", this.ConnectEnds);
            }
            allowPointSelect             = this.ConnectNulls;
            allowPointSelectDefaultValue = this.ConnectNulls_DefaultValue;
            if ((allowPointSelect.GetValueOrDefault() == allowPointSelectDefaultValue.GetValueOrDefault() ? allowPointSelect.HasValue != allowPointSelectDefaultValue.HasValue : true))
            {
                hashtables.Add("connectNulls", this.ConnectNulls);
            }
            animationLimit             = this.CropThreshold;
            animationLimitDefaultValue = this.CropThreshold_DefaultValue;
            if ((animationLimit.GetValueOrDefault() == animationLimitDefaultValue.GetValueOrDefault() ? animationLimit.HasValue != animationLimitDefaultValue.HasValue : true))
            {
                hashtables.Add("cropThreshold", this.CropThreshold);
            }
            if (this.Cursor != this.Cursor_DefaultValue)
            {
                LineSeriesCursor cursor = this.Cursor;
                hashtables.Add("cursor", Highcharts.FirstCharacterToLower(cursor.ToString()));
            }
            if (this.DashStyle != this.DashStyle_DefaultValue)
            {
                LineSeriesDashStyle dashStyle = this.DashStyle;
                hashtables.Add("dashStyle", Highcharts.FirstCharacterToLower(dashStyle.ToString()));
            }
            if (this.Data.Any <LineSeriesData>())
            {
                hashtables.Add("data", base.HashifyList(this.Data));
            }
            if (this.DataLabels.IsDirty())
            {
                hashtables.Add("dataLabels", this.DataLabels.ToHashtable());
            }
            if (this.Description != this.Description_DefaultValue)
            {
                hashtables.Add("description", this.Description);
            }
            allowPointSelectDefaultValue = this.EnableMouseTracking;
            allowPointSelect             = this.EnableMouseTracking_DefaultValue;
            if ((allowPointSelectDefaultValue.GetValueOrDefault() == allowPointSelect.GetValueOrDefault() ? allowPointSelectDefaultValue.HasValue != allowPointSelect.HasValue : true))
            {
                hashtables.Add("enableMouseTracking", this.EnableMouseTracking);
            }
            if (this.Events.IsDirty())
            {
                hashtables.Add("events", this.Events.ToHashtable());
            }
            allowPointSelect             = this.GetExtremesFromAll;
            allowPointSelectDefaultValue = this.GetExtremesFromAll_DefaultValue;
            if ((allowPointSelect.GetValueOrDefault() == allowPointSelectDefaultValue.GetValueOrDefault() ? allowPointSelect.HasValue != allowPointSelectDefaultValue.HasValue : true))
            {
                hashtables.Add("getExtremesFromAll", this.GetExtremesFromAll);
            }
            if (this.Id != this.Id_DefaultValue)
            {
                hashtables.Add("id", this.Id);
            }
            animationLimitDefaultValue = this.Index;
            animationLimit             = this.Index_DefaultValue;
            if ((animationLimitDefaultValue.GetValueOrDefault() == animationLimit.GetValueOrDefault() ? animationLimitDefaultValue.HasValue != animationLimit.HasValue : true))
            {
                hashtables.Add("index", this.Index);
            }
            if (this.Keys != this.Keys_DefaultValue)
            {
                hashtables.Add("keys", this.Keys);
            }
            animationLimit             = this.LegendIndex;
            animationLimitDefaultValue = this.LegendIndex_DefaultValue;
            if ((animationLimit.GetValueOrDefault() == animationLimitDefaultValue.GetValueOrDefault() ? animationLimit.HasValue != animationLimitDefaultValue.HasValue : true))
            {
                hashtables.Add("legendIndex", this.LegendIndex);
            }
            animationLimitDefaultValue = this.LineWidth;
            animationLimit             = this.LineWidth_DefaultValue;
            if ((animationLimitDefaultValue.GetValueOrDefault() == animationLimit.GetValueOrDefault() ? animationLimitDefaultValue.HasValue != animationLimit.HasValue : true))
            {
                hashtables.Add("lineWidth", this.LineWidth);
            }
            if (this.Linecap != this.Linecap_DefaultValue)
            {
                LineSeriesLinecap linecap = this.Linecap;
                hashtables.Add("linecap", Highcharts.FirstCharacterToLower(linecap.ToString()));
            }
            if (this.LinkedTo != this.LinkedTo_DefaultValue)
            {
                hashtables.Add("linkedTo", this.LinkedTo);
            }
            if (this.Marker.IsDirty())
            {
                hashtables.Add("marker", this.Marker.ToHashtable());
            }
            if (this.Name != this.Name_DefaultValue)
            {
                hashtables.Add("name", this.Name);
            }
            if (this.NegativeColor != this.NegativeColor_DefaultValue)
            {
                hashtables.Add("negativeColor", this.NegativeColor);
            }
            if (this.Point.IsDirty())
            {
                hashtables.Add("point", this.Point.ToHashtable());
            }
            animationLimit             = this.PointInterval;
            animationLimitDefaultValue = this.PointInterval_DefaultValue;
            if ((animationLimit.GetValueOrDefault() == animationLimitDefaultValue.GetValueOrDefault() ? animationLimit.HasValue != animationLimitDefaultValue.HasValue : true))
            {
                hashtables.Add("pointInterval", this.PointInterval);
            }
            if (this.PointIntervalUnit != this.PointIntervalUnit_DefaultValue)
            {
                LineSeriesPointIntervalUnit pointIntervalUnit = this.PointIntervalUnit;
                hashtables.Add("pointIntervalUnit", Highcharts.FirstCharacterToLower(pointIntervalUnit.ToString()));
            }
            if (this.PointPlacement.IsDirty())
            {
                hashtables.Add("pointPlacement", this.PointPlacement.ToJSON());
            }
            animationLimitDefaultValue = this.PointStart;
            animationLimit             = this.PointStart_DefaultValue;
            if ((animationLimitDefaultValue.GetValueOrDefault() == animationLimit.GetValueOrDefault() ? animationLimitDefaultValue.HasValue != animationLimit.HasValue : true))
            {
                hashtables.Add("pointStart", this.PointStart);
            }
            allowPointSelectDefaultValue = this.Selected;
            allowPointSelect             = this.Selected_DefaultValue;
            if ((allowPointSelectDefaultValue.GetValueOrDefault() == allowPointSelect.GetValueOrDefault() ? allowPointSelectDefaultValue.HasValue != allowPointSelect.HasValue : true))
            {
                hashtables.Add("selected", this.Selected);
            }
            if (this.Shadow != this.Shadow_DefaultValue)
            {
                hashtables.Add("shadow", this.Shadow);
            }
            allowPointSelect             = this.ShowCheckbox;
            allowPointSelectDefaultValue = this.ShowCheckbox_DefaultValue;
            if ((allowPointSelect.GetValueOrDefault() == allowPointSelectDefaultValue.GetValueOrDefault() ? allowPointSelect.HasValue != allowPointSelectDefaultValue.HasValue : true))
            {
                hashtables.Add("showCheckbox", this.ShowCheckbox);
            }
            allowPointSelectDefaultValue = this.ShowInLegend;
            allowPointSelect             = this.ShowInLegend_DefaultValue;
            if ((allowPointSelectDefaultValue.GetValueOrDefault() == allowPointSelect.GetValueOrDefault() ? allowPointSelectDefaultValue.HasValue != allowPointSelect.HasValue : true))
            {
                hashtables.Add("showInLegend", this.ShowInLegend);
            }
            allowPointSelect             = this.SoftThreshold;
            allowPointSelectDefaultValue = this.SoftThreshold_DefaultValue;
            if ((allowPointSelect.GetValueOrDefault() == allowPointSelectDefaultValue.GetValueOrDefault() ? allowPointSelect.HasValue != allowPointSelectDefaultValue.HasValue : true))
            {
                hashtables.Add("softThreshold", this.SoftThreshold);
            }
            if (this.Stack != this.Stack_DefaultValue)
            {
                hashtables.Add("stack", this.Stack);
            }
            if (this.Stacking != this.Stacking_DefaultValue)
            {
                LineSeriesStacking stacking = this.Stacking;
                hashtables.Add("stacking", Highcharts.FirstCharacterToLower(stacking.ToString()));
            }
            if (this.States.IsDirty())
            {
                hashtables.Add("states", this.States.ToHashtable());
            }
            if (this.Step != this.Step_DefaultValue)
            {
                LineSeriesStep step = this.Step;
                hashtables.Add("step", Highcharts.FirstCharacterToLower(step.ToString()));
            }
            allowPointSelectDefaultValue = this.StickyTracking;
            allowPointSelect             = this.StickyTracking_DefaultValue;
            if ((allowPointSelectDefaultValue.GetValueOrDefault() == allowPointSelect.GetValueOrDefault() ? allowPointSelectDefaultValue.HasValue != allowPointSelect.HasValue : true))
            {
                hashtables.Add("stickyTracking", this.StickyTracking);
            }
            animationLimit             = this.Threshold;
            animationLimitDefaultValue = this.Threshold_DefaultValue;
            if ((animationLimit.GetValueOrDefault() == animationLimitDefaultValue.GetValueOrDefault() ? animationLimit.HasValue != animationLimitDefaultValue.HasValue : true))
            {
                hashtables.Add("threshold", this.Threshold);
            }
            if (this.Tooltip.IsDirty())
            {
                hashtables.Add("tooltip", this.Tooltip.ToHashtable());
            }
            animationLimitDefaultValue = this.TurboThreshold;
            animationLimit             = this.TurboThreshold_DefaultValue;
            if ((animationLimitDefaultValue.GetValueOrDefault() == animationLimit.GetValueOrDefault() ? animationLimitDefaultValue.HasValue != animationLimit.HasValue : true))
            {
                hashtables.Add("turboThreshold", this.TurboThreshold);
            }
            if (this.Type != this.Type_DefaultValue)
            {
                LineSeriesType type = this.Type;
                hashtables.Add("type", Highcharts.FirstCharacterToLower(type.ToString()));
            }
            allowPointSelect             = this.Visible;
            allowPointSelectDefaultValue = this.Visible_DefaultValue;
            if ((allowPointSelect.GetValueOrDefault() == allowPointSelectDefaultValue.GetValueOrDefault() ? allowPointSelect.HasValue != allowPointSelectDefaultValue.HasValue : true))
            {
                hashtables.Add("visible", this.Visible);
            }
            if (this.XAxis != this.XAxis_DefaultValue)
            {
                hashtables.Add("xAxis", this.XAxis);
            }
            if (this.YAxis != this.YAxis_DefaultValue)
            {
                hashtables.Add("yAxis", this.YAxis);
            }
            animationLimit             = this.ZIndex;
            animationLimitDefaultValue = this.ZIndex_DefaultValue;
            if ((animationLimit.GetValueOrDefault() == animationLimitDefaultValue.GetValueOrDefault() ? animationLimit.HasValue != animationLimitDefaultValue.HasValue : true))
            {
                hashtables.Add("zIndex", this.ZIndex);
            }
            if (this.ZoneAxis != this.ZoneAxis_DefaultValue)
            {
                hashtables.Add("zoneAxis", this.ZoneAxis);
            }
            if (this.Zones.IsDirty())
            {
                hashtables.Add("zones", this.Zones.ToHashtable());
            }
            return(hashtables);
        }
Beispiel #8
0
        public LineSeries()
        {
            bool?nullable = new bool?(false);

            this.AllowPointSelect_DefaultValue = nullable;
            this.AllowPointSelect = nullable;
            Highsoft.Web.Mvc.Charts.Animation animation = new Highsoft.Web.Mvc.Charts.Animation()
            {
                Enabled = true
            };
            Highsoft.Web.Mvc.Charts.Animation animation1 = animation;
            this.Animation_DefaultValue = animation;
            this.Animation = animation1;
            double?nullable1 = null;

            this.AnimationLimit_DefaultValue = nullable1;
            this.AnimationLimit = nullable1;
            string str  = "";
            string str1 = str;

            this.ClassName_DefaultValue = str;
            this.ClassName = str1;
            object obj = null;

            str1 = (string)obj;
            this.Color_DefaultValue = (string)obj;
            this.Color = str1;
            nullable1  = null;
            this.ColorIndex_DefaultValue = nullable1;
            this.ColorIndex = nullable1;
            nullable        = new bool?(true);
            this.ConnectEnds_DefaultValue = nullable;
            this.ConnectEnds = nullable;
            nullable         = new bool?(false);
            this.ConnectNulls_DefaultValue = nullable;
            this.ConnectNulls = nullable;
            nullable1         = new double?((double)300);
            this.CropThreshold_DefaultValue = nullable1;
            this.CropThreshold = nullable1;
            int num = 0;
            LineSeriesCursor lineSeriesCursor = (LineSeriesCursor)num;

            this.Cursor_DefaultValue = (LineSeriesCursor)num;
            this.Cursor = lineSeriesCursor;
            int num1 = 0;
            LineSeriesDashStyle lineSeriesDashStyle = (LineSeriesDashStyle)num1;

            this.DashStyle_DefaultValue = (LineSeriesDashStyle)num1;
            this.DashStyle = lineSeriesDashStyle;
            List <LineSeriesData> lineSeriesDatas  = new List <LineSeriesData>();
            List <LineSeriesData> lineSeriesDatas1 = lineSeriesDatas;

            this.Data_DefaultValue = lineSeriesDatas;
            this.Data = lineSeriesDatas1;
            LineSeriesDataLabels lineSeriesDataLabel  = new LineSeriesDataLabels();
            LineSeriesDataLabels lineSeriesDataLabel1 = lineSeriesDataLabel;

            this.DataLabels_DefaultValue = lineSeriesDataLabel;
            this.DataLabels = lineSeriesDataLabel1;
            string str2 = "undefined";

            str1 = str2;
            this.Description_DefaultValue = str2;
            this.Description = str1;
            nullable         = new bool?(true);
            this.EnableMouseTracking_DefaultValue = nullable;
            this.EnableMouseTracking = nullable;
            LineSeriesEvents lineSeriesEvent  = new LineSeriesEvents();
            LineSeriesEvents lineSeriesEvent1 = lineSeriesEvent;

            this.Events_DefaultValue = lineSeriesEvent;
            this.Events = lineSeriesEvent1;
            nullable    = new bool?(false);
            this.GetExtremesFromAll_DefaultValue = nullable;
            this.GetExtremesFromAll = nullable;
            string str3 = "";

            str1 = str3;
            this.Id_DefaultValue = str3;
            this.Id   = str1;
            nullable1 = null;
            this.Index_DefaultValue = nullable1;
            this.Index = nullable1;
            List <string> strs  = new List <string>();
            List <string> strs1 = strs;

            this.Keys_DefaultValue = strs;
            this.Keys = strs1;
            nullable1 = null;
            this.LegendIndex_DefaultValue = nullable1;
            this.LegendIndex            = nullable1;
            nullable1                   = new double?((double)2);
            this.LineWidth_DefaultValue = nullable1;
            this.LineWidth              = nullable1;
            int num2 = 0;
            LineSeriesLinecap lineSeriesLinecap = (LineSeriesLinecap)num2;

            this.Linecap_DefaultValue = (LineSeriesLinecap)num2;
            this.Linecap = lineSeriesLinecap;
            string str4 = "";

            str1 = str4;
            this.LinkedTo_DefaultValue = str4;
            this.LinkedTo = str1;
            LineSeriesMarker lineSeriesMarker  = new LineSeriesMarker();
            LineSeriesMarker lineSeriesMarker1 = lineSeriesMarker;

            this.Marker_DefaultValue = lineSeriesMarker;
            this.Marker = lineSeriesMarker1;
            object obj1 = null;

            str1 = (string)obj1;
            this.Name_DefaultValue = (string)obj1;
            this.Name = str1;
            string str5 = "null";

            str1 = str5;
            this.NegativeColor_DefaultValue = str5;
            this.NegativeColor = str1;
            LineSeriesPoint lineSeriesPoint  = new LineSeriesPoint();
            LineSeriesPoint lineSeriesPoint1 = lineSeriesPoint;

            this.Point_DefaultValue = lineSeriesPoint;
            this.Point = lineSeriesPoint1;
            nullable1  = new double?((double)1);
            this.PointInterval_DefaultValue = nullable1;
            this.PointInterval = nullable1;
            int num3 = 0;
            LineSeriesPointIntervalUnit lineSeriesPointIntervalUnit = (LineSeriesPointIntervalUnit)num3;

            this.PointIntervalUnit_DefaultValue = (LineSeriesPointIntervalUnit)num3;
            this.PointIntervalUnit = lineSeriesPointIntervalUnit;
            Highsoft.Web.Mvc.Charts.PointPlacement pointPlacement  = new Highsoft.Web.Mvc.Charts.PointPlacement();
            Highsoft.Web.Mvc.Charts.PointPlacement pointPlacement1 = pointPlacement;
            this.PointPlacement_DefaultValue = pointPlacement;
            this.PointPlacement          = pointPlacement1;
            nullable1                    = new double?(0);
            this.PointStart_DefaultValue = nullable1;
            this.PointStart              = nullable1;
            nullable = new bool?(false);
            this.Selected_DefaultValue = nullable;
            this.Selected = nullable;
            Highsoft.Web.Mvc.Charts.Shadow shadow = new Highsoft.Web.Mvc.Charts.Shadow()
            {
                Enabled = false
            };
            Highsoft.Web.Mvc.Charts.Shadow shadow1 = shadow;
            this.Shadow_DefaultValue = shadow;
            this.Shadow = shadow1;
            nullable    = new bool?(false);
            this.ShowCheckbox_DefaultValue = nullable;
            this.ShowCheckbox = nullable;
            nullable          = new bool?(true);
            this.ShowInLegend_DefaultValue = nullable;
            this.ShowInLegend = nullable;
            nullable          = new bool?(true);
            this.SoftThreshold_DefaultValue = nullable;
            this.SoftThreshold = nullable;
            object obj2 = null;

            str1 = (string)obj2;
            this.Stack_DefaultValue = (string)obj2;
            this.Stack = str1;
            int num4 = 0;
            LineSeriesStacking lineSeriesStacking = (LineSeriesStacking)num4;

            this.Stacking_DefaultValue = (LineSeriesStacking)num4;
            this.Stacking = lineSeriesStacking;
            LineSeriesStates lineSeriesState  = new LineSeriesStates();
            LineSeriesStates lineSeriesState1 = lineSeriesState;

            this.States_DefaultValue = lineSeriesState;
            this.States = lineSeriesState1;
            int            num5           = 0;
            LineSeriesStep lineSeriesStep = (LineSeriesStep)num5;

            this.Step_DefaultValue = (LineSeriesStep)num5;
            this.Step = lineSeriesStep;
            nullable  = new bool?(true);
            this.StickyTracking_DefaultValue = nullable;
            this.StickyTracking         = nullable;
            nullable1                   = new double?(0);
            this.Threshold_DefaultValue = nullable1;
            this.Threshold              = nullable1;
            LineSeriesTooltip lineSeriesTooltip  = new LineSeriesTooltip();
            LineSeriesTooltip lineSeriesTooltip1 = lineSeriesTooltip;

            this.Tooltip_DefaultValue = lineSeriesTooltip;
            this.Tooltip = lineSeriesTooltip1;
            nullable1    = new double?((double)1000);
            this.TurboThreshold_DefaultValue = nullable1;
            this.TurboThreshold = nullable1;
            int            num6           = 0;
            LineSeriesType lineSeriesType = (LineSeriesType)num6;

            this.Type_DefaultValue = (LineSeriesType)num6;
            this.Type = lineSeriesType;
            nullable  = new bool?(true);
            this.Visible_DefaultValue = nullable;
            this.Visible = nullable;
            string str6 = "0";

            str1 = str6;
            this.XAxis_DefaultValue = str6;
            this.XAxis = str1;
            string str7 = "0";

            str1 = str7;
            this.YAxis_DefaultValue = str7;
            this.YAxis = str1;
            nullable1  = null;
            this.ZIndex_DefaultValue = nullable1;
            this.ZIndex = nullable1;
            string str8 = "y";

            str1 = str8;
            this.ZoneAxis_DefaultValue = str8;
            this.ZoneAxis = str1;
            LineSeriesZones lineSeriesZone  = new LineSeriesZones();
            LineSeriesZones lineSeriesZone1 = lineSeriesZone;

            this.Zones_DefaultValue = lineSeriesZone;
            this.Zones = lineSeriesZone1;
        }
Beispiel #9
0
 private void cursor_PositionChanged(LineSeriesCursor sender, double newValue, ref bool cancelRendering)
 {
     cancelRendering = true;
     UpdateCursorResult();
 }
Beispiel #10
0
        private void CreateChart()
        {
            gridChart.Children.Clear();
            if (m_chart != null)
            {
                m_chart.Dispose();
                m_chart = null;
            }

            m_chart = new LightningChartUltimate();
            m_chart.BeginUpdate();
            m_chart.Title.Text = "";;
            m_chart.ViewXY.AxisLayout.YAxesLayout        = YAxesLayout.Segmented;
            m_chart.ViewXY.AxisLayout.YAxisAutoPlacement = YAxisAutoPlacement.LeftThenRight;
            // m_chart.ViewXY.BeforeZooming += ViewXY_BeforeZooming;
            //m_chart.ViewXY.ZoomPanOptions.MouseWheelZooming = MouseWheelZooming.Vertical;


            // m_chart.ViewXY.AxisLayout.AutoAdjustAxisGap = 0;
            m_chart.Background                          = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            m_chart.ChartBackground.Color               = Color.FromArgb(0, 0, 0, 0);
            m_chart.ChartBackground.GradientFill        = GradientFill.Solid;
            m_chart.ViewXY.GraphBackground.Color        = Color.FromArgb(0, 0, 0, 0);
            m_chart.ViewXY.GraphBackground.GradientFill = GradientFill.Solid;
            m_chart.ViewXY.GraphBorderColor             = Color.FromArgb(0, 0, 0, 0);

            m_chart.ViewXY.XAxes[0].ValueType     = AxisValueType.DateTime;
            m_chart.ViewXY.XAxes[0].Title.Visible = false;
            //m_chart.ViewXY.XAxes[0].MinimumDateTime = DateTime.Now.Subtract(TimeSpan.FromMinutes(5));
            //m_chart.ViewXY.XAxes[0].MaximumDateTime = DateTime.Now;
            m_chart.ViewXY.XAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.XAxes[0].AxisThickness     = 2;
            m_chart.ViewXY.XAxes[0].AxisColor         = Color.FromArgb(0xff, 0xff, 0xff, 0xff);//Color.FromArgb(100, 135, 205, 238);
            m_chart.ViewXY.XAxes[0].LabelsFont        = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);

            //Create new Y axis for each series
            //AxisY yAxis = new AxisY(m_chart.ViewXY);
            //yAxis.SetRange(-10, 10);
            //m_chart.ViewXY.YAxes.Add(yAxis);
            //Almost zero margins, bottom is 3u
            //   m_chart.ViewXY.Margins = new Thickness(3);

            m_chart.ViewXY.YAxes.Clear();
            AxisY axisYnone = new AxisY(m_chart.ViewXY);

            axisYnone.Title.Font    = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 10, System.Drawing.FontStyle.Regular);
            axisYnone.AxisThickness = 2;
            axisYnone.AxisColor     = Color.FromArgb(0xff, 0xff, 0xff, 0xff);//Color.FromArgb(100, 135, 205, 238);
            axisYnone.Units.Text    = "none";
            m_chart.ViewXY.YAxes.Add(axisYnone);

            m_chart.ViewXY.AxisLayout.Segments.Clear();
            m_chart.ViewXY.AxisLayout.Segments.Add(new YAxisSegment(m_chart.ViewXY.AxisLayout)
            {
                Height = 0
            });
            m_chart.ViewXY.AxisLayout.Segments.Add(new YAxisSegment(m_chart.ViewXY.AxisLayout)
            {
                Height = 0
            });

            m_chart.ViewXY.LegendBoxes[0].Visible        = true;
            m_chart.ViewXY.LegendBoxes[0].Layout         = LegendBoxLayout.VerticalColumnSpan;
            m_chart.ViewXY.LegendBoxes[0].Fill.Style     = RectFillStyle.None;
            m_chart.ViewXY.LegendBoxes[0].Shadow.Visible = false;
            m_chart.ViewXY.LegendBoxes[0].BorderWidth    = 0;
            m_chart.ViewXY.LegendBoxes[0].Position       = LegendBoxPositionXY.TopRight;
            m_chart.ViewXY.LegendBoxes[0].Offset.SetValues(-80, 5);
            m_chart.ViewXY.LegendBoxes[0].SeriesTitleFont             = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);
            m_chart.ViewXY.LegendBoxes[0].SeriesTitleMouseMoveOverOn += LegendBox_SeriesTitleMouseMoveOverOn;

            //Add cursor
            LineSeriesCursor cursor = new LineSeriesCursor(m_chart.ViewXY, m_chart.ViewXY.XAxes[0]);

            m_chart.ViewXY.LineSeriesCursors.Add(cursor);
            cursor.PositionChanged  += cursor_PositionChanged;
            cursor.LineStyle.Color   = System.Windows.Media.Color.FromArgb(150, 255, 0, 0);
            cursor.LineStyle.Width   = 2;
            cursor.SnapToPoints      = true;
            cursor.TrackPoint.Color1 = Colors.White;

            m_chart.ViewXY.ZoomToFit();
            m_chart.EndUpdate();

            gridChart.Children.Add(m_chart);
        }
Beispiel #11
0
        public void SetGraphs(LightningChartUltimate throughputGraph, LightningChartUltimate tfGraph,
                              LightningChartUltimate timeGraph, LightningChartUltimate freqGraph)
        {
            int    i, j;
            double fstart = _dataFileNode.fstart;
            double df     = _dataFileNode.fs / _dataFileNode.Nfft / 2;

            float[] maxfreq = _dbClientService.getMaxFrf(_dataFileNode.Id);
            flen = maxfreq.Length;

            _throughputGraph = throughputGraph;
            _tfGraph         = tfGraph;
            _timeGraph       = timeGraph;
            _freqGraph       = freqGraph;

            {
                _throughputGraph.BeginUpdate();
                _throughputGraph.Title.Visible = false;
                _throughputGraph.ViewXY.LegendBoxes[0].Position = LegendBoxPositionXY.TopRight;
                _throughputGraph.ViewXY.LegendBoxes[0].Layout   = LegendBoxLayout.Vertical;
                AxisX axisX = _throughputGraph.ViewXY.XAxes[0];
                axisX.Title.Text = "时间(s)";
                AxisY axisY0 = _throughputGraph.ViewXY.YAxes[0];
                axisY0.Title.Text = "声压(Pa)";
                AxisY axisY1 = new AxisY(_throughputGraph.ViewXY);
                axisY1.Title.Text = "总声压级(dBA)";
                _throughputGraph.ViewXY.YAxes.Add(axisY1);

                _maxrmsSeries                      = new SampleDataSeries(_throughputGraph.ViewXY, axisX, axisY1);
                _maxrmsSeries.Title.Text           = "最大总声压级";
                _maxrmsSeries.LineStyle.Color      = Colors.Red;
                _maxrmsSeries.SampleFormat         = SampleFormat.SingleFloat;
                _maxrmsSeries.FirstSampleTimeStamp = _dataFileNode.Nfft / _dataFileNode.fs / 2;
                _maxrmsSeries.SamplingFrequency    = _dataFileNode.fs / _dataFileNode.FrameDN;
                _throughputGraph.ViewXY.SampleDataSeries.Add(_maxrmsSeries);

                _rmsSeries                      = new SampleDataSeries(_throughputGraph.ViewXY, axisX, axisY1);
                _rmsSeries.Title.Text           = "总声压级";
                _rmsSeries.LineStyle.Color      = Colors.Blue;
                _rmsSeries.SampleFormat         = SampleFormat.SingleFloat;
                _rmsSeries.FirstSampleTimeStamp = _maxrmsSeries.FirstSampleTimeStamp;
                _rmsSeries.SamplingFrequency    = _maxrmsSeries.SamplingFrequency;
                _throughputGraph.ViewXY.SampleDataSeries.Add(_rmsSeries);

                _throughputgraph_verticalCursor                   = new LineSeriesCursor(_throughputGraph.ViewXY, axisX);
                _throughputgraph_verticalCursor.Style             = CursorStyle.VerticalNoTracking;
                _throughputgraph_verticalCursor.LineStyle.Color   = Colors.White;
                _throughputgraph_verticalCursor.LineStyle.Pattern = LinePattern.Dot;
                _throughputgraph_verticalCursor.LineStyle.Width   = 3;
                _throughputgraph_verticalCursor.ValueAtXAxis      = 10;
                _throughputgraph_verticalCursor.MouseHighlight    = MouseOverHighlight.None;
                _throughputGraph.ViewXY.LineSeriesCursors.Add(_throughputgraph_verticalCursor);

                _throughputSeries                      = new SampleDataSeries(_throughputGraph.ViewXY, axisX, axisY0);
                _throughputSeries.Title.Text           = "时域";
                _throughputSeries.LineStyle.Color      = Colors.Orange;
                _throughputSeries.SampleFormat         = SampleFormat.SingleFloat;
                _throughputSeries.FirstSampleTimeStamp = 0;
                _throughputSeries.SamplingFrequency    = _dataFileNode.fs;
                _throughputGraph.ViewXY.SampleDataSeries.Add(_throughputSeries);

                float[] _maxrmsData = new float[_dataFileNode.NFrame];
                _rmsData[0].CopyTo(_maxrmsData, 0);
                for (i = 1; i < _dataFileNode.NFrame; i++)
                {
                    for (j = 0; j < _dataFileNode.ChannelNum; j++)
                    {
                        if (_rmsData[j][i] > _maxrmsData[i])
                        {
                            _maxrmsData[i] = _rmsData[j][i];
                        }
                    }
                }
                _maxrmsSeries.SamplesSingle = _maxrmsData;

                _throughputGraph.EndUpdate();
            }

            {
                _tfGraph.BeginUpdate();
                _tfGraph.Title.Visible = false;
                //_tfGraph.ViewXY.LegendBoxes[0].Visible = false;
                _tfGraph.ViewXY.LegendBoxes[0].Position       = LegendBoxPositionXY.TopRight;
                _tfGraph.ViewXY.LegendBoxes[0].ShowCheckboxes = false;
                AxisX axisX = _tfGraph.ViewXY.XAxes[0];
                axisX.Title.Text = "时间(s)";
                AxisY axisY = _tfGraph.ViewXY.YAxes[0];
                axisY.Title.Text = "频率(Hz)";

                _tfSeries = new IntensityGridSeries(_throughputGraph.ViewXY, axisX, axisY);
                _tfSeries.PixelRendering    = true;
                _tfSeries.ContourLineType   = ContourLineTypeXY.None;
                _tfSeries.ValueRangePalette = CreatePalette(_tfSeries, 20, 100);
                _tfSeries.SetRangesXY(_dataFileNode.Nfft / _dataFileNode.fs / 2,
                                      _dataFileNode.Nfft / _dataFileNode.fs / 2 + (_dataFileNode.NFrame - 1) * _dataFileNode.FrameDN / _dataFileNode.fs,
                                      fstart, fstart + (flen - 1) * df);
                _tfSeries.MouseInteraction      = false;
                _tfSeries.LegendBoxUnits        = null;
                _tfSeries.LegendBoxValuesFormat = "0";
                //_tfSeries.Title.Visible = false;
                _tfSeries.Title.Text = "声压级(dBA)";
                _tfGraph.ViewXY.IntensityGridSeries.Add(_tfSeries);

                _tfgraph_verticalCursor                   = new LineSeriesCursor(_tfGraph.ViewXY, axisX);
                _tfgraph_verticalCursor.Style             = CursorStyle.VerticalNoTracking;
                _tfgraph_verticalCursor.LineStyle.Color   = Colors.White;
                _tfgraph_verticalCursor.LineStyle.Pattern = LinePattern.Dot;
                _tfgraph_verticalCursor.LineStyle.Width   = 3;
                _tfgraph_verticalCursor.ValueAtXAxis      = _throughputgraph_verticalCursor.ValueAtXAxis;
                _tfgraph_verticalCursor.MouseHighlight    = MouseOverHighlight.None;
                _tfGraph.ViewXY.LineSeriesCursors.Add(_tfgraph_verticalCursor);

                _tfgraph_horizontalCursor = new ConstantLine(_tfGraph.ViewXY, axisX, axisY);
                _tfgraph_horizontalCursor.LineStyle.Color   = Colors.White;
                _tfgraph_horizontalCursor.LineStyle.Width   = 3;
                _tfgraph_horizontalCursor.LineStyle.Pattern = LinePattern.Dot;
                _tfgraph_horizontalCursor.Value             = 2000;
                _tfgraph_horizontalCursor.ShowInLegendBox   = false;
                _tfgraph_horizontalCursor.MouseHighlight    = MouseOverHighlight.None;
                _tfGraph.ViewXY.ConstantLines.Add(_tfgraph_horizontalCursor);

                spectrumCalculator = new SpectrumCalculator();
                double[] _aweight = Weight.GetWeightData(FreqWeightType.AWeight, fstart, df, flen);
                _aweightdb = new double[_aweight.Length];

                for (i = 0; i < flen; i++)
                {
                    _aweightdb[i] = 20 * Math.Log10(_aweight[i] * Math.Sqrt(2) / _dataFileNode.Nfft) + 93.9794;//93.9794为2e-5Pa参考
                }
                fstarti = (int)(fstart / df);

                ////Configure legend
                _tfGraph.ViewXY.LegendBoxes[0].IntensityScales.ScaleSizeDim1 = 400;
                _tfGraph.ViewXY.LegendBoxes[0].Layout = LegendBoxLayout.Horizontal;
                //_tfGraph.ViewXY.LegendBoxes[0].Offset = new PointIntXY(-15, -70);
                _tfGraph.ViewXY.LegendBoxes[0].ResetLocation();

                _tfGraph.EndUpdate();
            }

            {
                _timeGraph.BeginUpdate();
                _timeGraph.Title.Visible = false;
                _timeGraph.ViewXY.LegendBoxes[0].Position = LegendBoxPositionXY.TopRight;
                _timeGraph.ViewXY.LegendBoxes[0].Visible  = false;
                AxisX axisX = _timeGraph.ViewXY.XAxes[0];
                axisX.Title.Text = "时间(s)";
                AxisY axisY = _timeGraph.ViewXY.YAxes[0];
                axisY.Title.Text = "声压(Pa)";

                _timegraph_verticalCursor                   = new LineSeriesCursor(_timeGraph.ViewXY, axisX);
                _timegraph_verticalCursor.Style             = CursorStyle.VerticalNoTracking;
                _timegraph_verticalCursor.LineStyle.Color   = Colors.White;
                _timegraph_verticalCursor.LineStyle.Pattern = LinePattern.Dot;
                _timegraph_verticalCursor.LineStyle.Width   = 3;
                _timegraph_verticalCursor.ValueAtXAxis      = _dataFileNode.Nfft / _dataFileNode.fs / 2;
                _timegraph_verticalCursor.MouseHighlight    = MouseOverHighlight.None;
                _timeGraph.ViewXY.LineSeriesCursors.Add(_timegraph_verticalCursor);

                _timeSeries                      = new SampleDataSeries(_timeGraph.ViewXY, axisX, axisY);
                _timeSeries.Title.Text           = "时域";
                _timeSeries.LineStyle.Color      = Colors.Orange;
                _timeSeries.SampleFormat         = SampleFormat.SingleFloat;
                _timeSeries.FirstSampleTimeStamp = 0;
                _timeSeries.SamplingFrequency    = _dataFileNode.fs;
                _timeGraph.ViewXY.SampleDataSeries.Add(_timeSeries);

                _timeGraph.ViewXY.ZoomToFit();

                _timeGraph.EndUpdate();
            }

            {
                _freqGraph.BeginUpdate();
                _freqGraph.Title.Visible = false;
                _freqGraph.ViewXY.LegendBoxes[0].Position = LegendBoxPositionXY.TopRight;
                _freqGraph.ViewXY.LegendBoxes[0].Layout   = LegendBoxLayout.Vertical;
                AxisX axisX = _freqGraph.ViewXY.XAxes[0];
                axisX.Title.Text = "频率(Hz)";
                AxisY axisY = _freqGraph.ViewXY.YAxes[0];
                axisY.Title.Text = "声压级(dBA)";

                _freqgraph_verticalCursor                   = new LineSeriesCursor(_freqGraph.ViewXY, axisX);
                _freqgraph_verticalCursor.Style             = CursorStyle.VerticalNoTracking;
                _freqgraph_verticalCursor.LineStyle.Color   = Colors.White;
                _freqgraph_verticalCursor.LineStyle.Pattern = LinePattern.Dot;
                _freqgraph_verticalCursor.LineStyle.Width   = 3;
                _freqgraph_verticalCursor.ValueAtXAxis      = _tfgraph_horizontalCursor.Value;
                _freqgraph_verticalCursor.MouseHighlight    = MouseOverHighlight.None;
                _freqGraph.ViewXY.LineSeriesCursors.Add(_freqgraph_verticalCursor);

                _maxfreqSeries                      = new SampleDataSeries(_freqGraph.ViewXY, axisX, axisY);
                _maxfreqSeries.Title.Text           = "最大值";
                _maxfreqSeries.LineStyle.Color      = Colors.Red;
                _maxfreqSeries.SampleFormat         = SampleFormat.SingleFloat;
                _maxfreqSeries.FirstSampleTimeStamp = fstart;
                _maxfreqSeries.SamplingFrequency    = 1 / df;
                _freqGraph.ViewXY.SampleDataSeries.Add(_maxfreqSeries);
                _maxfreqSeries.SamplesSingle = maxfreq;

                _freqSeries                      = new SampleDataSeries(_freqGraph.ViewXY, axisX, axisY);
                _freqSeries.Title.Text           = "频谱";
                _freqSeries.LineStyle.Color      = Colors.Orange;
                _freqSeries.SampleFormat         = SampleFormat.DoubleFloat;
                _freqSeries.FirstSampleTimeStamp = fstart;
                _freqSeries.SamplingFrequency    = 1 / df;
                _freqGraph.ViewXY.SampleDataSeries.Add(_freqSeries);

                _freqGraph.ViewXY.ZoomToFit();

                _freqGraph.EndUpdate();
            }

            _ShowTimer.Interval = _dataFileNode.FrameDN / _dataFileNode.fs * 1000 / 2;
            _ShowTimer.Elapsed += _ShowTimer_Elapsed;

            _tfgraph_verticalCursor.PositionChanged += verticalCursor_PositionChanged;
            _tfgraph_horizontalCursor.ValueChanged  += horizontalCursor_ValueChanged;

            UpdateChannel();
        }
Beispiel #12
0
        private void CreateChart(Color lineColor, double yMinimum, double yMaximum)
        {
            if (ContainerChart != null)
            {
                ContainerChart.Dispose();
                ContainerChart = null;
            }

            ContainerChart = new LightningChartUltimate
            {
                Name                = "Chart2",
                ChartName           = "Chart2",
                Title               = { Text = string.Empty },
                VerticalAlignment   = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Left,
            };

            ContainerChart.MouseMove += (sender, args) =>
            {
                var    position = args.GetPosition(ContainerChart);
                double doubleIndex;
                ContainerChart.ViewXY.XAxes[0].CoordToValue((int)position.X, out doubleIndex, true);

                var list = new List <KeyValuePair <SampleDataSeries, double> >();

                foreach (var series in ContainerChart.ViewXY.SampleDataSeries)
                {
                    var intIndex = doubleIndex * series.SamplingFrequency;
                    if (intIndex > _points || intIndex < 0 || series.SamplesDouble.Length - 1 < intIndex)
                    {
                        return;
                    }

                    var value = series.SamplesDouble[(int)intIndex];

                    list.Add(new KeyValuePair <SampleDataSeries, double>(series, value));
                }

                OnSelectedValueChanged(doubleIndex, list);
            };

            var chartView = ContainerChart.ViewXY;

            chartView.AxisLayout.AutoAdjustMargins = false;
            chartView.AxisLayout.AutoAdjustAxisGap = 0;

            var xAxis = chartView.XAxes[0];

            chartView.AxisLayout.YAxesLayout     = YAxesLayout.Layered;
            chartView.AxisLayout.StackedYAxesGap = 1;

            xAxis.ScrollPosition = 0;
            xAxis.ScrollMode     = XAxisScrollMode.None;
            xAxis.SweepingGap    = 1;
            xAxis.Title.Visible  = true;
            xAxis.Title.Text     = string.Empty;

            chartView.LegendBox.Visible = false;
            chartView.DropOldSeriesData = false;
            chartView.ZoomPanOptions.RectangleZoomDirectionLayered = RectangleZoomDirectionLayered.Horizontal;
            chartView.ZoomPanOptions.MouseWheelZooming             = MouseWheelZooming.Off;
            chartView.ZoomPanOptions.RightMouseButtonAction        = MouseButtonAction.None;
            chartView.ZoomPanOptions.ShiftEnabled          = false;
            chartView.ZoomPanOptions.CtrlEnabled           = false;
            chartView.ZoomPanOptions.RightToLeftZoomAction = RightToLeftZoomAction.Off;
            chartView.ZoomPanOptions.LeftMouseButtonAction = MouseButtonAction.None;
            chartView.ZoomPanOptions.PanDirection          = PanDirection.Horizontal;

            // Initialize left cursor
            _cursor = new LineSeriesCursor(ContainerChart.ViewXY, ContainerChart.ViewXY.XAxes[0])
            {
                ValueAtXAxis = 1, LineStyle = { Width = 3 }
            };
            _cursor.LineStyle.Color        = Color.FromArgb(70, lineColor.R, lineColor.G, lineColor.B);
            _cursor.SnapToPoints           = true;
            _cursor.Style                  = CursorStyle.VerticalNoTracking;
            _cursor.TrackPoint.Color1      = Colors.Yellow;
            _cursor.TrackPoint.Color2      = Colors.Transparent;
            _cursor.TrackPoint.Shape       = Shape.Circle;
            _cursor.MoveByMouse            = false;
            _cursor.IndicateTrackingYRange = true;
            ContainerChart.ViewXY.LineSeriesCursors.Add(_cursor);

            // After test layerd and stacked
            ContainerChart.ViewXY.YAxes[0].SetRange(yMinimum, yMaximum);
            ContainerChart.ViewXY.YAxes[0].Title.Text = string.Empty;

            _scrollBar = new ScrollBar {
                Offset = new PointIntXY(0, 30)
            };
            xAxis.LabelsPosition = Alignment.Near;

            _scrollBar.Scroll += (sender, type, value, newValue) =>
            {
                if (value == newValue)
                {
                    return;
                }

                var initialLength = _end - _start;
                var currentLength = xAxis.Maximum - xAxis.Minimum;
                if (Math.Abs(initialLength - currentLength) < TOLERANCE)
                {
                    return;
                }

                ContainerChart.BeginUpdate();

                var ratio  = 1 - (currentLength / initialLength);
                var step   = ((double)newValue - value) / SCROLL_BAR_AVAILABLE_MAX;
                var offset = ratio * step;

                xAxis.SetRange(xAxis.Minimum + offset, xAxis.Maximum + offset);
                ContainerChart.EndUpdate();
            };

            ContainerChart.ScrollBars.Add(_scrollBar);
        }
Beispiel #13
0
        private void CreateChart()
        {
            gridChart.Children.Clear();
            if (_chart != null)
            {
                _chart.Dispose();
                _chart = null;
            }

            _chart = new LightningChartUltimate();
            _chart.BeginUpdate();
            _chart.Title.Text = "";;
            _chart.ViewXY.AxisLayout.YAxesLayout        = YAxesLayout.Layered;
            _chart.ViewXY.AxisLayout.YAxisAutoPlacement = YAxisAutoPlacement.LeftThenRight;

            // _chart.ViewXY.AxisLayout.AutoAdjustAxisGap = 0;
            _chart.Background                          = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            _chart.ChartBackground.Color               = Color.FromArgb(0, 0, 0, 0);
            _chart.ChartBackground.GradientFill        = GradientFill.Solid;
            _chart.ViewXY.GraphBackground.Color        = Color.FromArgb(0, 0, 0, 0);
            _chart.ViewXY.GraphBackground.GradientFill = GradientFill.Solid;
            _chart.ViewXY.GraphBorderColor             = Color.FromArgb(0, 0, 0, 0);

            _chart.ViewXY.XAxes[0].ValueType        = AxisValueType.DateTime;
            _chart.ViewXY.XAxes[0].AutoFormatLabels = false;
            _chart.ViewXY.XAxes[0].LabelsTimeFormat = "MM-dd HH:mm";
            _chart.ViewXY.XAxes[0].Title.Visible    = false;
            //_chart.ViewXY.XAxes[0].MinimumDateTime = DateTime.Now.Subtract(TimeSpan.FromMinutes(5));
            //_chart.ViewXY.XAxes[0].MaximumDateTime = DateTime.Now;
            _chart.ViewXY.XAxes[0].MinorGrid.Visible = false;
            _chart.ViewXY.XAxes[0].AxisThickness     = 2;
            _chart.ViewXY.XAxes[0].AxisColor         = Color.FromArgb(0xff, 0xff, 0xff, 0xff);//Color.FromArgb(100, 135, 205, 238);
            _chart.ViewXY.XAxes[0].LabelsFont        = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);

            _chart.ViewXY.YAxes.Clear();
            AxisY axisYnone = new AxisY(_chart.ViewXY);

            axisYnone.Title.Font    = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 10, System.Drawing.FontStyle.Regular);
            axisYnone.AxisThickness = 2;
            axisYnone.AxisColor     = Color.FromArgb(0xff, 0xff, 0xff, 0xff);//Color.FromArgb(100, 135, 205, 238);
            axisYnone.Units.Text    = "none";
            _chart.ViewXY.YAxes.Add(axisYnone);

            _chart.ViewXY.LegendBoxes[0].Visible        = false;
            _chart.ViewXY.LegendBoxes[0].Layout         = LegendBoxLayout.VerticalColumnSpan;
            _chart.ViewXY.LegendBoxes[0].Fill.Style     = RectFillStyle.None;
            _chart.ViewXY.LegendBoxes[0].Shadow.Visible = false;
            _chart.ViewXY.LegendBoxes[0].BorderWidth    = 0;
            _chart.ViewXY.LegendBoxes[0].Position       = LegendBoxPositionXY.TopRight;
            _chart.ViewXY.LegendBoxes[0].Offset.SetValues(-80, 5);
            _chart.ViewXY.LegendBoxes[0].SeriesTitleFont             = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);
            _chart.ViewXY.LegendBoxes[0].SeriesTitleMouseMoveOverOn += LegendBox_SeriesTitleMouseMoveOverOn;

            //Add cursor
            LineSeriesCursor cursor = new LineSeriesCursor(_chart.ViewXY, _chart.ViewXY.XAxes[0]);

            _chart.ViewXY.LineSeriesCursors.Add(cursor);
            cursor.PositionChanged  += cursor_PositionChanged;
            cursor.LineStyle.Color   = System.Windows.Media.Color.FromArgb(150, 255, 0, 0);
            cursor.LineStyle.Width   = 2;
            cursor.SnapToPoints      = true;
            cursor.TrackPoint.Color1 = Colors.White;

            _chart.ViewXY.ZoomToFit();

            _chart.EndUpdate();

            gridChart.Children.Add(_chart);

            chkZoom.Checked   += chkZoom_Checked;
            chkZoom.Unchecked += chkZoom_Unchecked;
            chkZoom_Checked(null, null);
        }
Beispiel #14
0
        private void CreateChart()
        {
            gridChart.Children.Clear();
            if (m_chart != null)
            {
                m_chart.Dispose();
                m_chart = null;
            }

            m_chart = new LightningChartUltimate();
            m_chart.BeginUpdate();
            m_chart.Title.Text = "";
            m_chart.ViewXY.AxisLayout.XAxisAutoPlacement      = XAxisAutoPlacement.BottomThenTop;
            m_chart.ViewXY.AxisLayout.YAxisAutoPlacement      = YAxisAutoPlacement.LeftThenRight;
            m_chart.ViewXY.AxisLayout.YAxisTitleAutoPlacement = false;
            m_chart.ViewXY.AxisLayout.YAxesLayout             = YAxesLayout.Layered;

            m_chart.Background                          = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            m_chart.ChartBackground.Color               = Color.FromArgb(0, 0, 0, 0);
            m_chart.ChartBackground.GradientFill        = GradientFill.Solid;
            m_chart.ViewXY.GraphBackground.Color        = Color.FromArgb(0, 0, 0, 0);
            m_chart.ViewXY.GraphBackground.GradientFill = GradientFill.Solid;
            m_chart.ViewXY.GraphBorderColor             = Color.FromArgb(0, 0, 0, 0);

            m_chart.ViewXY.LegendBoxes[0].Visible = false;

            m_chart.ViewXY.XAxes[0].ValueType         = AxisValueType.DateTime;
            m_chart.ViewXY.XAxes[0].Title.Visible     = false;
            m_chart.ViewXY.XAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.XAxes[0].AxisThickness     = 2;
            m_chart.ViewXY.XAxes[0].AxisColor         = Color.FromArgb(0xff, 0xff, 0xff, 0xff);//Color.FromArgb(100, 135, 205, 238);
            m_chart.ViewXY.XAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.XAxes[0].LabelsFont        = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);


            m_chart.ViewXY.YAxes[0].Title.Visible     = false;
            m_chart.ViewXY.YAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.YAxes[0].AxisThickness     = 2;
            m_chart.ViewXY.YAxes[0].AxisColor         = Color.FromArgb(0xff, 0xff, 0xff, 0xff);//Color.FromArgb(100, 135, 205, 238);
            m_chart.ViewXY.YAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.YAxes[0].LabelsFont        = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);
            m_chart.ViewXY.YAxes[0].Title.Text        = "";

            AxisX xAxis2 = new AxisX(m_chart.ViewXY);

            xAxis2.LabelsFont        = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);
            xAxis2.Title.Text        = "";
            xAxis2.AxisColor         = DefaultColors.SeriesForBlackBackgroundWpf[1];
            xAxis2.MajorGrid.Visible = false;
            xAxis2.ValueType         = AxisValueType.Number;
            m_chart.ViewXY.XAxes.Add(xAxis2);

            AxisY yAxis2 = new AxisY(m_chart.ViewXY);

            yAxis2.LabelsFont        = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);
            yAxis2.Title.Text        = "";
            yAxis2.AxisColor         = DefaultColors.SeriesForBlackBackgroundWpf[1];
            yAxis2.MajorGrid.Visible = false;
            m_chart.ViewXY.YAxes.Add(yAxis2);

            PointLineSeries series = new PointLineSeries(m_chart.ViewXY, m_chart.ViewXY.XAxes[0], m_chart.ViewXY.YAxes[0]);

            series.MouseInteraction       = false;
            series.LineStyle.AntiAliasing = LineAntialias.None;
            series.LineStyle.Width        = 1;
            m_chart.ViewXY.PointLineSeries.Add(series);

            PointLineSeries series2 = new PointLineSeries(m_chart.ViewXY, m_chart.ViewXY.XAxes[1], m_chart.ViewXY.YAxes[1]);

            series2.MouseInteraction       = false;
            series2.LineStyle.Color        = DefaultColors.SeriesForBlackBackgroundWpf[1];
            series2.LineStyle.AntiAliasing = LineAntialias.None;
            series2.LineStyle.Width        = 1;
            series2.CursorTrackEnabled     = false;
            m_chart.ViewXY.PointLineSeries.Add(series2);

            //Add cursor
            LineSeriesCursor cursor = new LineSeriesCursor(m_chart.ViewXY, m_chart.ViewXY.XAxes[0]);

            cursor.PositionChanged += AlarmPointTrendDataView_PositionChanged;
            //cursor.AssignXAxisIndex = 0;
            m_chart.ViewXY.LineSeriesCursors.Add(cursor);
            cursor.LineStyle.Color   = System.Windows.Media.Color.FromArgb(150, 255, 0, 0);
            cursor.SnapToPoints      = true;
            cursor.LineStyle.Width   = 2;
            cursor.TrackPoint.Color1 = Colors.White;

            m_chart.ViewXY.ZoomToFit();
            m_chart.EndUpdate();
            gridChart.Children.Add(m_chart);
        }
Beispiel #15
0
        private void HandleVibrationMessage(VibrationMessage message)
        {
            try
            {
                m_chart.BeginUpdate();

                var fftLength   = message.Frequency.Length;
                var series      = m_chart.ViewXY.PointLineSeries[0];
                var phaseSeries = m_chart.ViewXY.PointLineSeries[1];

                if (series.Points == null || series.Points.Length != fftLength)
                {
                    series.Points = new SeriesPoint[fftLength];
                }
                if (phaseSeries.Points == null || phaseSeries.Points.Length != fftLength)
                {
                    phaseSeries.Points = new SeriesPoint[fftLength];
                }
                for (int i = 0; i < fftLength; i++)
                {
                    series.Points[i].X = message.Frequency[i];
                    series.Points[i].Y = message.Amplitude[i];

                    phaseSeries.Points[i].X = message.Frequency[i];
                    phaseSeries.Points[i].Y = message.Phase[i];
                }

                if (m_chart.ViewXY.Annotations[1].Visible)
                {
                    LineSeriesCursor lineSeriesCursor = m_chart.ViewXY.LineSeriesCursors[0];
                    int index = GetNearestPointIndex(series, lineSeriesCursor.ValueAtXAxis);
                    if (index == -1)
                    {
                        m_chart.ViewXY.Annotations[1].Text = string.Empty;
                    }
                    else
                    {
                        SeriesPoint point = series.Points[index];
                        m_chart.ViewXY.Annotations[1].Text = string.Format("幅值:{0}", Math.Round(point.Y, 3)) + "\r\n" + string.Format("频率:{0}", Math.Round(point.X, 3));
                    }
                }

                m_chart.ViewXY.PointLineSeries[0].InvalidateData();
                m_chart.ViewXY.PointLineSeries[1].InvalidateData();
                AnnotationXY  spectrumAnnotation = m_chart.ViewXY.Annotations[0];
                StringBuilder spectrumSB         = new StringBuilder();
                spectrumSB.AppendLine("频率" + "  " + "幅值");

                var fftValuesDict = message.Amplitude.Select((s, i) => new { Key = i, Value = s }).OrderByDescending(o => o.Value).Take(6);
                foreach (var item in fftValuesDict)
                {
                    spectrumSB.AppendLine(message.Frequency[item.Key].ToString("0.00") + "; " + item.Value.ToString("0.00"));
                }

                spectrumAnnotation.Text = spectrumSB.ToString().Trim();

                //if (fitViewCheckBox.IsChecked == true)
                //{
                m_chart.ViewXY.ZoomToFit();
                // }
                m_chart.EndUpdate();
            }
            catch (Exception ex)
            {
                m_chart.EndUpdate();
            }
        }
Beispiel #16
0
        public void AddToChart(LightningChartUltimate chart)
        {
            Chart = chart;

            var xAxis = chart.ViewXY.XAxes[0];
            var yAxis = chart.ViewXY.YAxes[0];
            var color = Config.Color;

            // Initialize left cursor
            Left = new LineSeriesCursor(Chart.ViewXY, xAxis)
            {
                ValueAtXAxis = 1, LineStyle = { Width = Config.LineWidth }
            };
            Left.LineStyle.Color   = Color.FromArgb(180, color.R, color.G, color.B);
            Left.FullHeight        = false;
            Left.SnapToPoints      = false;
            Left.Style             = CursorStyle.PointTracking;
            Left.TrackPoint.Color1 = Colors.Transparent;
            Left.TrackPoint.Color2 = Colors.Transparent;
            Left.TrackPoint.Shape  = Shape.Circle;
            Chart.ViewXY.LineSeriesCursors.Add(Left);

            // Initialize right cursor
            Right = new LineSeriesCursor(Chart.ViewXY, xAxis)
            {
                ValueAtXAxis = 1, LineStyle = { Width = Config.LineWidth }
            };
            Right.LineStyle.Color   = Color.FromArgb(180, color.R, color.G, color.B);
            Right.FullHeight        = false;
            Right.SnapToPoints      = false;
            Right.Style             = CursorStyle.PointTracking;
            Right.TrackPoint.Color1 = Colors.Transparent;
            Right.TrackPoint.Color2 = Colors.Transparent;
            Right.TrackPoint.Shape  = Shape.Circle;
            Chart.ViewXY.LineSeriesCursors.Add(Right);

            // Initialize middle cursor
            Middle = new LineSeriesCursor(Chart.ViewXY, xAxis)
            {
                ValueAtXAxis = 1, LineStyle = { Width = Config.LineWidth }
            };
            Middle.LineStyle.Color   = Color.FromArgb(180, color.R, color.G, color.B);
            Middle.FullHeight        = false;
            Middle.SnapToPoints      = false;
            Middle.Style             = CursorStyle.PointTracking;
            Middle.TrackPoint.Color1 = Colors.Transparent;
            Middle.TrackPoint.Color2 = Colors.Transparent;
            Middle.TrackPoint.Shape  = Shape.Circle;
            Chart.ViewXY.LineSeriesCursors.Add(Middle);

            //Edit bands
            BandBar = new Band(Chart.ViewXY, xAxis, yAxis)
            {
                Title   = { Text = string.Empty },
                Behind  = true,
                Binding = AxisBinding.XAxis
            };
            var bandColor = Config.BandColor;

            BandBar.Fill.Color             = Color.FromArgb(bandColor.A, bandColor.R, bandColor.G, bandColor.B);
            BandBar.Fill.GradientColor     = ChartTools.CalcGradient(BandBar.Fill.Color, Color.FromArgb(150, 0, 0, 0), 50);
            BandBar.Fill.GradientDirection = 0;

            BandBar.Title.Visible = true;
            BandBar.Title.Color   = Colors.White;
            BandBar.MouseResize   = false;
            Chart.ViewXY.Bands.Add(BandBar);

            BandBar.MovedByMouse += (sender, args) =>
            {
                if (_isChanging)
                {
                    return;
                }
                _isChanging = true;

                var middle = (BandBar.ValueBegin + BandBar.ValueEnd) / 2;
                var diff   = middle - Value;

                var left  = Left.ValueAtXAxis + diff;
                var right = Right.ValueAtXAxis + diff;

                SetByValue(right, left, middle);

                // resize bandwidth
                //var middleDiff = Middle.ValueAtXAxis - BandBar.ValueBegin;
                //if (middleDiff >= 0)
                //{
                //    Range.Start = -middleDiff;
                //    Range.End = middleDiff;
                //}
                //else
                //{
                //    Range.Start = 0;
                //    Range.End = 0;
                //}

                //if (middleDiff > Config.BandwidthMaximum)
                //{
                //    Range.Start = -Config.BandwidthMaximum;
                //    Range.End = Config.BandwidthMaximum;
                //}

                //var right = Middle.ValueAtXAxis + Range.End;
                //var left = Middle.ValueAtXAxis + Range.Start;
                //var middle = Middle.ValueAtXAxis;

                //SetByValue(right, left, middle);

                _isChanging = false;
            };

            Right.PositionChanged += (LineSeriesCursor sender, double value, ref bool rendering) =>
            {
                if (_isChanging)
                {
                    return;
                }
                _isChanging = true;

                var middleDiff = Right.ValueAtXAxis - Middle.ValueAtXAxis;
                if (middleDiff >= 0)
                {
                    Range.Start = -middleDiff;
                    Range.End   = middleDiff;
                }
                else
                {
                    Range.Start = 0;
                    Range.End   = 0;
                }

                if (middleDiff > Config.BandwidthMaximum)
                {
                    Range.Start = -Config.BandwidthMaximum;
                    Range.End   = Config.BandwidthMaximum;
                }

                var right  = Middle.ValueAtXAxis + Range.End;
                var left   = Middle.ValueAtXAxis + Range.Start;
                var middle = Middle.ValueAtXAxis;

                SetByValue(right, left, middle);

                _isChanging = false;
            };

            Left.PositionChanged += (LineSeriesCursor sender, double value, ref bool rendering) =>
            {
                if (_isChanging)
                {
                    return;
                }
                _isChanging = true;

                var middleDiff = Middle.ValueAtXAxis - Left.ValueAtXAxis;
                if (middleDiff >= 0)
                {
                    Range.Start = -middleDiff;
                    Range.End   = middleDiff;
                }
                else
                {
                    Range.Start = 0;
                    Range.End   = 0;
                }

                if (middleDiff > Config.BandwidthMaximum)
                {
                    Range.Start = -Config.BandwidthMaximum;
                    Range.End   = Config.BandwidthMaximum;
                }

                var right  = Middle.ValueAtXAxis + Range.End;
                var left   = Middle.ValueAtXAxis + Range.Start;
                var middle = Middle.ValueAtXAxis;

                SetByValue(right, left, middle);

                _isChanging = false;
            };

            Middle.PositionChanged += (LineSeriesCursor sender, double value, ref bool rendering) =>
            {
                if (_isChanging)
                {
                    return;
                }
                _isChanging = true;

                var diff = value - Value;

                var left  = Left.ValueAtXAxis + diff;
                var right = Right.ValueAtXAxis + diff;

                SetByValue(right, left, value);

                _isChanging = false;
            };
        }
Beispiel #17
0
        private void CreateChart()
        {
            gridChart.Children.Clear();
            if (m_chart != null)
            {
                m_chart.Dispose();
                m_chart = null;
            }

            m_chart = new LightningChartUltimate();
            m_chart.BeginUpdate();
            m_chart.Title.Visible = false;
            m_chart.ViewXY.AxisLayout.YAxesLayout = YAxesLayout.Stacked;

            m_chart.Background                          = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            m_chart.ChartBackground.Color               = Color.FromArgb(0, 0, 0, 0);
            m_chart.ChartBackground.GradientFill        = GradientFill.Solid;
            m_chart.ViewXY.GraphBackground.Color        = Color.FromArgb(0, 0, 0, 0);
            m_chart.ViewXY.GraphBackground.GradientFill = GradientFill.Solid;
            m_chart.ViewXY.GraphBorderColor             = Color.FromArgb(0, 0, 0, 0);

            m_chart.ViewXY.XAxes[0].ValueType         = AxisValueType.Number;
            m_chart.ViewXY.XAxes[0].Title.Visible     = false;
            m_chart.ViewXY.XAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.XAxes[0].AxisThickness     = 2;
            m_chart.ViewXY.XAxes[0].AxisColor         = Color.FromArgb(0xff, 0xff, 0xff, 0xff);//Color.FromArgb(100, 135, 205, 238);
            m_chart.ViewXY.XAxes[0].MinorGrid.Visible = false;
            m_chart.ViewXY.XAxes[0].LabelsFont        = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);

            m_chart.ViewXY.YAxes.Clear();
            AxisY axisYnone = new AxisY(m_chart.ViewXY);

            axisYnone.Title.Font    = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 10, System.Drawing.FontStyle.Regular);
            axisYnone.AxisThickness = 2;
            axisYnone.AxisColor     = Color.FromArgb(0xff, 0xff, 0xff, 0xff);//Color.FromArgb(100, 135, 205, 238);
            axisYnone.Units.Text    = "none";
            m_chart.ViewXY.YAxes.Add(axisYnone);

            m_chart.ViewXY.LegendBoxes[0].Visible        = true;
            m_chart.ViewXY.LegendBoxes[0].Layout         = LegendBoxLayout.VerticalColumnSpan;
            m_chart.ViewXY.LegendBoxes[0].Fill.Style     = RectFillStyle.None;
            m_chart.ViewXY.LegendBoxes[0].Shadow.Visible = false;
            m_chart.ViewXY.LegendBoxes[0].BorderWidth    = 0;
            m_chart.ViewXY.LegendBoxes[0].Position       = LegendBoxPositionXY.TopRight;
            m_chart.ViewXY.LegendBoxes[0].Offset.SetValues(-80, 10);
            m_chart.ViewXY.LegendBoxes[0].SeriesTitleFont = new WpfFont(System.Drawing.FontFamily.GenericSansSerif, 9, System.Drawing.FontStyle.Regular);

            //Add cursor
            LineSeriesCursor cursor = new LineSeriesCursor(m_chart.ViewXY, m_chart.ViewXY.XAxes[0]);

            m_chart.ViewXY.LineSeriesCursors.Add(cursor);
            cursor.PositionChanged  += cursor_PositionChanged;
            cursor.LineStyle.Color   = System.Windows.Media.Color.FromArgb(150, 255, 0, 0);
            cursor.LineStyle.Width   = 2;
            cursor.SnapToPoints      = true;
            cursor.TrackPoint.Color1 = Colors.White;

            m_chart.ViewXY.ZoomToFit();
            m_chart.EndUpdate();

            gridChart.Children.Add(m_chart);

            showCheckBox.Checked   += showCheckBox_Checked;
            showCheckBox.Unchecked += showCheckBox_Checked;
        }