Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlotView not exposing Invalidate #288

Closed
david-laundav opened this issue Dec 11, 2014 · 6 comments

Comments

Projects
None yet
2 participants
@david-laundav
Copy link
Contributor

commented Dec 11, 2014

As mentioned in this issue on Stackoverflow, when I create a ScatterSeries and listen to the TouchStarted event to highlight the selected item, it is not updated immediately in the PlotView. I have to drag the canvas before the SelectionColor is applied.

First, in my ViewModel, I do like so:

var model = new PlotModel()
{  
SelectionColor = OxyColors.Red,
// ...
};

var scatterSeries = new ScatterSeries()
{
    SelectionMode = SelectionMode.Single,
    // ...
};

var scatterPoints = new List<ScatterPoint>
{
    new ScatterPoint(0, 4),
    // ...
};

Thereafter, I listen to the TouchStarted event of the ScatterSeries:

scatterSeries.TouchStarted += (sender, e) =>
{
    var xCoordinate = e.Position.X;
    var yCoordinate = e.Position.Y;

    var screenPoint = new ScreenPoint(xCoordinate, yCoordinate);

    var point = lineSeries.GetNearestPoint(screenPoint, false);
    var index = (int)point.Index;
    scatterSeries.SelectItem(index);

    // I expect it to refresh and update the PlotModel here:
    model.InvalidatePlot(true); 

    e.Handled = true;
};

In my ViewModel I have also created a PlotModel Property which my PlotView (in my View) is bound to (i.e. PlotView.ModelProperty).

As mentioned, this seems to work fine, except for that the PlotModel is not updated immediately with the SelectionColor - I have to drag the canvas before it updates.

I think this may have something to do with the fact, that my PlotView is not invalidated after data has been updated.

As Cheesebaron mentions, I am unable to Invalidate the PlotView since it is not exposed in Xamarin.Forms.

Is this something you could possibly include, or do you have any other solution?

@objorke

This comment has been minimized.

Copy link
Member

commented Dec 16, 2014

This looks like a bug. What platform are you using - Xamarin.Forms? Then the error could be in the Xamarin.Forms implementation. The usage of InvalidatePlot looks correct - that is the current design to trig a refresh of the view.

@david-laundav

This comment has been minimized.

Copy link
Contributor Author

commented Dec 18, 2014

Yeah, I am using Xamarin.Forms. The implementation of the PlotView in the corresponding View is as follows:

var plotView = new PlotView
{
    WidthRequest = 200,
    HeightRequest = 200,
    VerticalOptions = LayoutOptions.Center
};

And then afterwards, I bind the ModelProperty of the PlotView to the PlotModel of the ViewModel:

plotView.SetBinding(PlotView.ModelProperty, LineChartViewModel.PlotModelProperty);

And lastly set the Content to the plotView instance:

Content = plotView;
@objorke

This comment has been minimized.

Copy link
Member

commented Jan 23, 2015

is this solved now?

@objorke objorke added this to the v2015.1 milestone Jan 26, 2015

@david-laundav

This comment has been minimized.

Copy link
Contributor Author

commented Jan 26, 2015

Tested on Android which works. Should be tested on iOS as well, as soon as #348 is fixed.

@objorke

This comment has been minimized.

Copy link
Member

commented Jan 30, 2015

I think this is a duplicate of #338

@david-laundav

This comment has been minimized.

Copy link
Contributor Author

commented Jan 30, 2015

It is a duplicate of #338 indeed. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.