Point selection on Line series?

Jul 3, 2014 at 1:31 PM
Hi,

First of all, thank you very much for this great chart library.
I'm having a problem while attempting to change the color of the selected marker in a line series. Is this possible at all, or it is a not-supported feature?

I've tried to modify the "LineSeries and PlotModel MouseDown event" example, simply adding the following lines
        model.SelectionColor = OxyColors.Red;
        s1.SelectionMode = SelectionMode.Single;
        s1.ItemsSource = s1.Points;
and inside the MouseDown event handler
                // Check if we are near a point
                if ((nearestPoint - e.Position).Length < 10)
                {
                    // Start editing this point
                    indexOfPointToMove = indexOfNearestPoint;
                    s1.SelectItem(indexOfPointToMove);
                }
This doesn't seem to work. Is there something that I'm missing?

Last thing, why do we have to change the color at model level? Isn't more flexible doing it a series level? That is we could also have more control on the stroke of the selected item.

Thanks,
Fabio
Jul 3, 2014 at 3:00 PM
After tracing it back through the source, it does seem to flag the item properly (all the way back in Selection.cs). Are you refreshing the plot after you select the item? (InvalidatePlot(false) on the view or model). The mouse event will change the flag but it won't actually display anything on it's own unless you tell the view to update manually.

Also imo at least selection colour should be global to the model itself, not series. I can't really think of a reason you'd want multiple different selection colours unless you're selecting different items for different actions.
Jul 3, 2014 at 5:11 PM
Yes, the model get invalidated (the lines of code I've added are from on of the examples).
If you see that the flag set properly. then, or it is ignored, or the color is overwritten when the line series get rendered, I imagine.

The reason was for aesthetics, as I might have 2 or more series on the same plot, and I might want to highlight each marker based on the original marker color, or with different colors for quick distinguish with a quick look. (I'm assuming here that you can have multiple items selected on the same plot from different series)

Anyway I solved it creating a scattered series that "clones" some information from the selected marker's series and paint a scattered item on top of it.

Thank you for the help.
Jul 3, 2014 at 8:32 PM
Well when it's the Selection object itself then it just has a boolean flag, but when it's a point in it, the Selection object has an array of bools that it flags with the index given to it. (Source Link).

That sounds more like a use for highlighting, not selection, although I do agree, I think highlighting should be drawn around (probably harder than it sounds or based on the original colour). It does look a bit weird in the Toolbar example I put together when you change the colour of an annotation and it just remains shiny yellow, would be nice to have it based on the colour it is, as you mention.