在氧气图C#中绘制一个点以及其他线

时间:2018-02-13 14:11:57

标签: c# winforms oxyplot

试图显示实际位于其他系列线上的单个点。我可以在一个系列中选择值并突出显示它,但我认为它会更难。我选择制作一种名为series2的新lineseries并将其重点放在其中。我称为series1的其他lineseries包含要绘制的实际点。

    /// <summary>
    /// Streaming plot
    /// </summary>
    private void InitiateStreamPlot(List<double> time, List<double> sample, params object[] restOfPointsToPlote)
    {
        myModel = new PlotModel { Title = "Voltage level" };
        ss = "New streaming plot is starting" + Environment.NewLine;

        series1 = new LineSeries
        {
            MarkerType = MarkerType.Circle,
            StrokeThickness = 1,
            MarkerSize = 1,
            Smooth = true,
            Title = "Voltage level",
            CanTrackerInterpolatePoints = false,

        };

        series2 = new LineSeries
        {
            Color = OxyColors.LightBlue,
            MarkerFill = OxyColors.Blue,
            MarkerType = MarkerType.Plus,
            MarkerSize = 15,
        };

        linearAxis1 = new LinearAxis { Position = AxisPosition.Bottom, Title = "Time in nanosec" };
        linearAxis2 = new LinearAxis { Position = AxisPosition.Left, Title = "Voltage" };

        myModel.Axes.Add(linearAxis1);
        myModel.Axes.Add(linearAxis2);

        // Show the triggered value on the plot

        //series2.Points.Add(new ScatterPoint(timeAtIndex, sampleAtIndex));
        //myModel.Series.Add(series2);
        if (restOfPointsToPlote.Length > 0)
        {
            double timeAtIndex = (double)restOfPointsToPlote[0];
            double sampleAtIndex = (double)restOfPointsToPlote[1];
            series2.Points.Add(new OxyPlot.DataPoint(timeAtIndex, sampleAtIndex));
            myModel.Series.Add(series2);
        }

        for (int i = 0; i < time.Count - 1; i++)
        {
            series1.Points.Add(new OxyPlot.DataPoint(time[i], sample[i]));
        }

        myModel.Series.Add(series1);
        plotView1.Model = myModel;
        sendit = true;
    }

我从这个图中看到的结果只是series1而没有出现series2。以下是结果: The plot(chart)

然而,正如您所看到的那样,没有显示出来。在调试时我发现那个单点存在。 serie1中始终存在等于该单点的值。我不知道我做错了什么。

1 个答案:

答案 0 :(得分:0)

我将代码更改为以下内容。我相信原因是series2

的配置
        series2 = new LineSeries
        {
            Color = OxyColors.Red,
            MarkerFill = OxyColors.Blue,
            MarkerStroke = OxyColors.Red,
            MarkerType = MarkerType.Circle,
            StrokeThickness = 0,
            MarkerSize = 4,
        };