简体   繁体   中英

Plot One point along with other lines in oxyplot C#

Trying to show a single point that actually lays on the line of other series. I could select the value in one series and highlight it but I think it would be harder. I choose to make a new lineseries called series2 and put my point in it. My other lineseries called series1 contain the actual points to be plotted.

    /// <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;
    }

The result I see from this plot is just the series1 and no series2 appears. Following is the result : The plot(chart)

However as you see the point is not shown. when debugging I see that that single point exist. There is always a value in serie1 that is equal to that single point. I have no idea what I'm doing wrong.

I changed the code to following. I believe the reason was the configuration of series2 :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM