/// <summary> /// 更新示波器数据 /// </summary> /// <param name="samples">数据</param> public void FeedData(double[][] samples) { //Only accept resolution count of data points if (samples == null) { return; } _chart.BeginUpdate(); for (int index = 0; index < samples.Count(); index++) { if (samples[index] != null) { //SampleDataSeries series = _chart.ViewXY.SampleDataSeries[index]; //series.AddSamples(samples[index], false); SampleDataSeries series = _chart.ViewXY.SampleDataSeries[index]; var data = samples[index]; series.AddSamples(data, true); //每次更新数据x轴只滚动一次 if (index == 0) { _chart.ViewXY.XAxes[0].ScrollPosition = series.FirstSampleTimeStamp + (double)(series.PointCount - 1) / _samplingFrequency; } } } _chart.EndUpdate(); }
public FixedChannelChart() { InitializeComponent(); _player = new WaveformPlayer(-120, 0); ContentControlChart.Content = _player.ContainerChart; var color0 = Colors.Brown; var config0 = new WaveformPlayerConfig { Color = Color.FromArgb(100, color0.R, color0.G, color0.B), Maximum = 0, Minimum = -120, }; _max = _player.AddNewWaveformPlayer(config0); var color1 = Colors.DarkOrange; var config1 = new WaveformPlayerConfig { Color = Color.FromArgb(100, color1.R, color1.G, color1.B), Maximum = 0, Minimum = -120, }; _current = _player.AddNewWaveformPlayer(config1); var color2 = Colors.OrangeRed; var config2 = new WaveformPlayerConfig { Color = Color.FromArgb(100, color2.R, color2.G, color2.B), Maximum = 0, Minimum = -120, }; _min = _player.AddNewWaveformPlayer(config2); _player.Initialize(0.0d, 1.0d, 500); _player.SelectedValueChanged += OnSelectedValueChanged; SizeChanged += (sender, args) => _player.SetBounds((int)RootLayout.ActualWidth, (int)RootLayout.ActualHeight - 10); }
public SampleDataSeries AddNewWaveformPlayer(WaveformPlayerConfig config) { var chartView = ContainerChart.ViewXY; var yAxis = chartView.YAxes.AddNew(); // ReSharper disable once PossibleNullReferenceException yAxis.MouseInteraction = false; yAxis.Title.Visible = false; yAxis.Visible = false; yAxis.SetRange(config.Minimum, config.Maximum); chartView.DropOldSeriesData = false; var series = new SampleDataSeries(chartView, chartView.XAxes[0], yAxis); chartView.SampleDataSeries.Add(series); series.LineStyle.Width = 1; series.LineStyle.Color = Color.FromArgb(100, config.Color.R, config.Color.G, config.Color.B); series.MouseInteraction = false; return(series); }
public WaveformMonitor(Color lineColor, string title = "") { SampleFrequency = 0.0; ContainerChart = new LightningChartUltimate { Name = "Chart1", ChartName = "Chart1", Title = { Text = title }, VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch }; ContainerChart.BeginUpdate(); ContainerChart.ViewXY.AxisLayout.AutoAdjustMargins = false; ContainerChart.ViewXY.DropOldSeriesData = false; _xAxis = ContainerChart.ViewXY.XAxes[0]; _xAxis.ValueType = AxisValueType.Number; _xAxis.SweepingGap = 2; _xAxis.ScrollMode = XAxisScrollMode.None; _xAxis.Title.Text = "Range"; _xAxis.Title.VerticalAlign = XAxisTitleAlignmentVertical.Top; _xAxis.Title.HorizontalAlign = XAxisTitleAlignmentHorizontal.Right; _xAxis.LabelsPosition = Alignment.Near; _xAxis.LabelsFont = new WPFFont("Tahoma", 9.0, "9", true, false); _xAxis.MajorDivTickStyle.Visible = false; _xAxis.MinorDivTickStyle.Visible = false; _xAxis.MajorGrid.Visible = false; _xAxis.MinorGrid.Visible = false; _xAxis.LabelsVisible = true; _xAxis.SteppingInterval = 1; _xAxis.MouseScaling = false; _xAxis.MouseScrolling = false; _xAxis.MouseInteraction = false; _xAxis.AxisThickness = 1; var axisY = ContainerChart.ViewXY.YAxes[0]; axisY.SetRange(0, 30000); axisY.Title.Visible = false; axisY.LabelsFont = new WPFFont("Tahoma", 9.0, "9", true, false); ContainerChart.ViewXY.GraphBackground.GradientDirection = 270; ContainerChart.ViewXY.GraphBackground.GradientFill = GradientFill.Cylindrical; var color = ContainerChart.ViewXY.GraphBackground.Color; ContainerChart.ViewXY.GraphBackground.Color = Color.FromArgb(150, color.R, color.G, color.B); ContainerChart.Title.Font = new WPFFont("Tahoma", 11.0, "11", true, false); ContainerChart.Title.Align = ChartTitleAlignment.TopCenter; ContainerChart.Title.Offset.SetValues(0, 25); ContainerChart.Title.Color = lineColor; ContainerChart.ViewXY.Margins = new Thickness(70, 10, 15, 10); ContainerChart.ViewXY.ZoomPanOptions.ZoomRectLine.Color = Colors.Lime; ContainerChart.ChartBackground.Color = ChartTools.CalcGradient(lineColor, Colors.Black, 65); ContainerChart.ChartBackground.GradientDirection = 0; ContainerChart.ChartBackground.GradientFill = GradientFill.Cylindrical; ContainerChart.ViewXY.LegendBox.Visible = false; var series = new SampleDataSeries(ContainerChart.ViewXY, _xAxis, axisY) { LineStyle = { Width = 1f, Color = lineColor, AntiAliasing = LineAntialias.None }, MouseInteraction = false }; ContainerChart.ViewXY.SampleDataSeries.Add(series); ContainerChart.EndUpdate(); }
/// <summary> /// 构造函数 /// </summary> /// <param name="parentControl">父容器</param> /// <param name="seriesNames">示波器各序列名</param> /// <param name="sampleFrequency">绘制曲线颜色</param> /// <param name="titleColor">绘制曲线颜色</param> /// <param name="chartManager"> 内置图表的的chartManager(可空)</param> public WaveformMonitor( Panel parentControl, string[] seriesNames, double sampleFrequency, Color titleColor, ChartManager chartManager ) { _samplingFrequency = sampleFrequency; _parentControl = parentControl; _chart = new LightningChartUltimate(); _chart.ChartName = "Waveform chart"; _chart.ViewXY.XAxes = ViewXY.CreateDefaultXAxes(); _chart.ViewXY.YAxes = ViewXY.CreateDefaultYAxes(); _chart.VerticalAlignment = VerticalAlignment.Top; _chart.HorizontalAlignment = HorizontalAlignment.Left; _chart.ViewXY.AxisLayout.YAxesLayout = YAxesLayout.Stacked; _chart.ViewXY.AxisLayout.SegmentsGap = 10; parentControl.Children.Add(_chart); _chart.BeginUpdate(); _chart.ChartManager = chartManager; _chart.ViewXY.AxisLayout.AutoAdjustMargins = false; _chart.ViewXY.DropOldSeriesData = true; _chart.ChartRenderOptions.AntiAliasLevel = 0; // Disable hw anti-aliasing. AxisX axisX = _chart.ViewXY.XAxes[0]; axisX.Maximum = 10; axisX.SweepingGap = 2; axisX.ScrollMode = XAxisScrollMode.Scrolling; axisX.Title.Text = "Range"; axisX.Title.VerticalAlign = XAxisTitleAlignmentVertical.Top; axisX.Title.HorizontalAlign = XAxisTitleAlignmentHorizontal.Right; axisX.LabelsPosition = Alignment.Near; axisX.LabelsFont = new WpfFont("Segoe UI", 11, true, false); axisX.MajorDivTickStyle.Visible = false; axisX.MinorDivTickStyle.Visible = false; axisX.MajorGrid.Visible = false; axisX.MinorGrid.Visible = false; axisX.LabelsVisible = false; axisX.SteppingInterval = 1; axisX.MouseScaling = false; axisX.MouseScrolling = false; axisX.AxisThickness = 1; //AxisY axisY = _chart.ViewXY.YAxes[0]; //axisY.SetRange(-30000, 30000); //axisY.Title.Visible = false; //axisY.LabelsFont = new WpfFont("Segoe UI", 11, true, false); _chart.ViewXY.GraphBackground.GradientDirection = 270; _chart.ViewXY.GraphBackground.GradientFill = GradientFill.Cylindrical; Color color = _chart.ViewXY.GraphBackground.Color; _chart.ViewXY.GraphBackground.Color = Color.FromArgb(150, color.R, color.G, color.B); _chart.Title.Font = new WpfFont("Segoe UI", 14, true, false); _chart.Title.Align = ChartTitleAlignment.TopCenter; _chart.Title.Offset.SetValues(0, 25); _chart.Title.Color = titleColor; _chart.ViewXY.Margins = new Thickness(70, 10, 15, 10); _chart.ViewXY.ZoomPanOptions.ZoomRectLine.Color = Colors.Lime; _chart.ChartBackground.Color = ChartTools.CalcGradient(titleColor, Colors.Black, 65); _chart.ChartBackground.GradientDirection = 0; _chart.ChartBackground.GradientFill = GradientFill.Cylindrical; //清除之前的y轴与数据序列 DisposeAllAndClear(_chart.ViewXY.YAxes); DisposeAllAndClear(_chart.ViewXY.SampleDataSeries); //添加多序列的y轴属性 for (int index = 0; index < seriesNames.Count(); index++) { AxisY axisY = new AxisY(_chart.ViewXY); axisY.SetRange(-30000, 30000); axisY.Title.Font = new WpfFont("Segoe UI", 10, false, false); axisY.Title.Text = string.Format(seriesNames[index]); axisY.Title.Angle = 0; axisY.Units.Visible = false; //axisY.Title.Visible = false; axisY.LabelsFont = new WpfFont("Segoe UI", 11, true, false); _chart.ViewXY.YAxes.Add(axisY); //Add SampleDataSeries SampleDataSeries sds = new SampleDataSeries(_chart.ViewXY, axisX, axisY); _chart.ViewXY.SampleDataSeries.Add(sds); sds.SampleFormat = SampleFormat.DoubleFloat; sds.LineStyle.Color = DefaultColors.SeriesForBlackBackgroundWpf[index % DefaultColors.SeriesForBlackBackgroundWpf.Length]; sds.SamplingFrequency = _samplingFrequency; sds.FirstSampleTimeStamp = 1.0 / _samplingFrequency; sds.LineStyle.Width = 1f; sds.LineStyle.AntiAliasing = LineAntialias.None; sds.ScrollModePointsKeepLevel = 1; sds.ScrollingStabilizing = true; sds.MouseInteraction = false; //Add the line as a zero level ConstantLine cls = new ConstantLine(_chart.ViewXY, axisX, axisY); cls.Title.Text = "Constant line"; cls.Title.Visible = false; cls.LineStyle.Color = Colors.BlueViolet; cls.Behind = true; cls.LineStyle.Width = 2; cls.MouseInteraction = false; cls.Value = 0; _chart.ViewXY.ConstantLines.Add(cls); } //LineSeriesCursor cursor1 = new LineSeriesCursor(_chart.ViewXY, axisX); //cursor1.ValueAtXAxis = 1; //cursor1.LineStyle.Width = 6; //color = Colors.OrangeRed; //cursor1.LineStyle.Color = Color.FromArgb(180, color.R, color.G, color.B); //cursor1.FullHeight = true; //cursor1.SnapToPoints = true; //cursor1.Style = CursorStyle.PointTracking; //cursor1.TrackPoint.Color1 = Colors.Yellow; //cursor1.TrackPoint.Color2 = Colors.Transparent; //cursor1.TrackPoint.Shape = Shape.Circle; //_chart.ViewXY.LineSeriesCursors.Add(cursor1); _chart.EndUpdate(); }
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(); }
private void OnChannelAdded(ChannelToken token) { try { if (viewModel == null || !(token is VibrationChannelToken)) { return; } m_chart.BeginUpdate(); VibrationChannelToken vToken = token as VibrationChannelToken; AxisY axisY = new AxisY(m_chart.ViewXY); axisY.Tag = vToken; axisY.Title.Visible = false; axisY.AxisThickness = 2; axisY.AxisColor = Color.FromArgb(100, 135, 205, 238); m_chart.ViewXY.YAxes.Add(axisY); if (m_chart.ViewXY.Annotations.Count == 0) { CreateAnnotation(); } AnnotationXY annotation = m_chart.ViewXY.Annotations[0]; int count = m_chart.ViewXY.SampleDataSeries.Count; while (count > 15) { count -= 15; } Color color = DefaultColors.SeriesForBlackBackgroundWPF[count]; SampleDataSeries series = new SampleDataSeries(m_chart.ViewXY, m_chart.ViewXY.XAxes[0], axisY); series.SampleFormat = SampleFormat.DoubleFloat; series.MouseInteraction = false; series.LineStyle.Color = color; series.LineStyle.AntiAliasing = LineAntialias.None; series.LineStyle.Width = 1; series.Tag = vToken; series.Title.Text = vToken.Channel.Name + vToken.Channel.MSSN; series.Title.Font = new WPFFont(System.Drawing.FontFamily.GenericSansSerif, 10f, System.Drawing.FontStyle.Bold); series.Title.Color = ChartTools.CalcGradient(Colors.White, Colors.White, 50); series.Title.HorizontalAlign = AlignmentHorizontal.Left; series.Title.VerticalAlign = AlignmentVertical.Top; series.Title.MoveByMouse = false; series.Title.MouseInteraction = false; series.Title.Offset = new PointIntXY(5, 5); series.Title.Visible = true; //Update Annotation StringBuilder sb = new StringBuilder(); string[] branches = annotation.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < branches.Length; i++) { sb.AppendLine(branches[i]); } string text = string.Format("{0}:", m_chart.ViewXY.YAxes.Count); if (vToken.VData != null) { series.SamplesDouble = vToken.VData.Waveform; axisY.Title.Text += "\r\n" + " (" + vToken.VData.Unit + ")"; text = string.Format("{0,6}|{1,6}|{2,6}|{3,7}|{4,6}|{5,9}|{6,9}|{7,9}|{8,9}|{9,9}|{10,9}", vToken.VData.AMS.ToString("0.00"), vToken.VData.PeakValue.ToString("0.00"), vToken.VData.PeakPeakValue.ToString("0.00"), vToken.VData.Slope.ToString("0.00"), vToken.VData.Kurtosis.ToString("0.00"), vToken.VData.KurtosisValue.ToString("0.00"), vToken.VData.WaveIndex.ToString("0.00"), vToken.VData.PeakIndex.ToString("0.00"), vToken.VData.ImpulsionIndex.ToString("0.00"), vToken.VData.RootAmplitude.ToString("0.00"), vToken.VData.ToleranceIndex.ToString("0.00")); } sb.Append(text); annotation.Text = sb.ToString().Trim(); m_chart.ViewXY.SampleDataSeries.Add(series); m_chart.ViewXY.FitView(); m_chart.EndUpdate(); } catch (Exception ex) { m_chart.EndUpdate(); EventAggregatorService.Instance.EventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("数据回放-时域-添加通道", ex)); } }