Placing marker at custom location

Jan 25, 2013 at 7:54 PM

Is there a way to place a marker at a custom location. If I had 5 points in my LineSeries, and I only want to put markers at the 2nd and 4th points, what's the best way to achieve that? 

Thanks in advance for your help. 

Coordinator
Feb 10, 2013 at 10:20 PM
I would add a ScatterSeries for the markers. The ScatterSeries class has more options for the markers. I don't think there should be more marker features in the LineSeries.
Feb 26, 2013 at 8:59 PM
Thanks for the tip. A ScatterSeries would work, except I need mouse events on the series to be enabled.

I ended up implementing a custom LineSeries. I re-defined the MarkerFill & MarkerStroke properties, so that setting them here doesn't enable markers in the base class.
    public class MarkerLineSeries : LineSeries
    {
        public IList<int> MarkerLocations { get; private set; }

        new public OxyColor MarkerFill { get; set; }

        new public OxyColor MarkerStroke { get; set; }

        public MarkerLineSeries()
            : this(string.Empty)
        {
        }

        public MarkerLineSeries(string title)
            : this(title, new Collection<int>())
        {
        }

        public MarkerLineSeries(string title, IList<int> markerLocations)
            : base(title)
        {
            MarkerLocations = markerLocations;
        }

        public override void Render(IRenderContext rc, PlotModel model)
        {
            base.Render(rc, model);
            foreach (var location in MarkerLocations)
            {
                if (location < 0 || location > Points.Count - 1) break;
                var pt = XAxis.Transform(Points[location].X, Points[location].Y, YAxis);
                rc.DrawMarker(
                    pt,
                    GetClippingRect(),
                    MarkerType,
                    MarkerOutline,
                    MarkerSize,
                    MarkerFill,
                    MarkerStroke,
                    MarkerStrokeThickness);
            }
        }
    }