/// <summary> /// 添加谱线,当传入值spec为空时,清空除了第一条线之外的其他谱线。 /// </summary> /// <param name="wave"></param> /// <param name="spec"></param> private void chart_fitting_addLine(object wave, double[] spec, bool newSeries, string name) { if (spec == null) { for (int i = Chart_fitting.SeriesCount - 1; i > 1; i--) { Chart_fitting.RemoveSeries(i); } } else { if (newSeries) { ESeriesClass series = new ESeriesClass(); int index = Chart_fitting.AddSeries(series); Chart_fitting.Series(index).Title = name; Chart_fitting.Series(index).AddArray(spec.Length, spec, wave); Chart_fitting.Series(index).Color = (uint)ColorTranslator.ToWin32(Color.Blue); } else { Chart_fitting.Series(0).AddArray(spec.Length, spec, wave); } } }
private void addSignFittingChart(int[] bufwave, double[] bufspec, double [] realSign, double[] unrealSign) { for (int i = Chart_fitting.SeriesCount - 1; i > 2; i--) { Chart_fitting.RemoveSeries(i); } Chart_fitting.Series(1).Clear(); if (realSign.Length == 0 && unrealSign.Length == 0) { return; } double[] markx = new double[realSign.Length + unrealSign.Length]; double[] marky = new double[realSign.Length + unrealSign.Length]; for (int i = 0; i < realSign.Length; i++) { int waveindex = ProcessArray.getCursorIndex(realSign[i], bufwave); double[] newserArrayY = new double[] { 0, bufspec [waveindex] }; double[] newserArrayX = new double[] { realSign[i], realSign[i] }; int index = Chart_fitting.AddSeries(ESeriesClass.scFastLine); Chart_fitting.Series(index).AddArray(2, newserArrayY, newserArrayX); Chart_fitting.Series(index).asFastLine.LinePen.Width = 2; Chart_fitting.Series(index).asFastLine.LinePen.Color = (uint)ColorTranslator.ToWin32(Color.Green); markx[i] = realSign[i]; marky[i] = bufspec[waveindex]; } for (int i = 0; i < unrealSign.Length; i++) { int waveindex = ProcessArray.getCursorIndex(unrealSign[i], bufwave); double[] newserArrayY = new double[] { 0, bufspec[waveindex] }; double[] newserArrayX = new double[] { unrealSign[i], unrealSign[i] }; int index = Chart_fitting.AddSeries(ESeriesClass.scFastLine); Chart_fitting.Series(index).AddArray(2, newserArrayY, newserArrayX); Chart_fitting.Series(index).asFastLine.LinePen.Width = 2; Chart_fitting.Series(index).asFastLine.LinePen.Color = (uint)ColorTranslator.ToWin32(Color.Red); markx[i + realSign.Length] = unrealSign[i]; marky[i + realSign.Length] = bufspec[waveindex]; } int serindex = 1; Chart_fitting.Series(serindex).AddArray(marky.Length, marky, markx); Chart_fitting.Series(serindex).asPoint.Pointer.Visible = false; Chart_fitting.Series(serindex).Marks.Style = EMarkStyle.smsXValue; Chart_fitting.Series(serindex).Marks.Symbol.Visible = false; Chart_fitting.Series(serindex).Marks.Show(); }