0

Scatter plot point color

Martin Ingold 4 weeks ago 0

Hi all

I've have a WinForms application that I developed a while ago that uses Microsoft's Chart control.

Now I would like to move this application to WPF and found oxyplot, which seems to be all I need except for one thing.

I reallize that my usecase is a bit special, but here goes:

In my app, the user starts off with an empty chart (scatter plot). He adds points to an ObservableCollection by clicking anywhere on the chart. Clicking the point again, he can change some state of that point, right clicking removes it again.

Once he is complete, he can start a process that will do some stuff with each of the points, depending on where they are defined. So far so good.

Now to the problem:

In the old application, the state of the point (e.g. processed / unprocessed) is represented by a different image, so it's easily visible on the chart which point is in which state.

And here is my problem with oxyplot. I do not seem to be able to define a seperate point color based on a state. It seems to always take the color of the series.


What I have tried:

In my ViewModel, I've defined a couple CollectionViews, which filter points based on the state. This gives a proper result. But if I add a new Series in oxyplot using the CollectionView as an ItemSource, I only see the points of the last CollectionView that was added.

Code example:

public ICollectionView BasePoints { get; private set; }

public ICollectionView ModelPoints { get; private set; }

BasePoints = CollectionViewSource.GetDefaultView(ModelPointManager.GetInstance().PointList);

ModelPoints = CollectionViewSource.GetDefaultView(ModelPointManager.GetInstance().PointList);

PlotModel.Series.Add(new ScatterSeries(ModelPoints));
PlotModel.Series.Add(new ScatterSeries(BasePoints)); <---- only these points show up

However, if, instead of using collection views, I use "decoupled" collections (like sepereate ObservableCollections), they both show up.


I've also tried to create my own ScatterSeries based on the one from OxyPlot, and then to override the ActualMarkerFillColor property that I found in the source code:

public new OxyColor ActualMarkerFillColor {
get { return OxyColor.Parse("#00000000"); }
}


However, setting a breakpoint there is never getting hit, and of course the color is also not shown in the map.


So, at the moment, the only way to go about this is to create a bunch of collections, assign them to individual series, and when a point changes it's state in the original collection, manage all the others somehow.

This will be quite cumbersome, as there are a bunch of states a point can have, and the result would be that I would need to manage about 7 or 8 different collections, only to have them show up in the proper color.


Before I do this, does anyone have an other ideas / hints / tips on how I could achieve what I am trying to?

Thanks

Martin