LineSeries in Cartesian plot does not redraw correctly.

Oystein Bjorke il y a 10 ans 0
This discussion was imported from CodePlex

endorphing wrote at 2013-08-16 23:57:

This is a strange drawing issue with Cartesian type plots that I don't see with regular XY types.
Steps to reproduce,

1) Set the PlotType to Cartesian,
2) Re-size the main Window of your application to a very small horizontal width.
3) Now click on the top-right corner of your window to make it full-screen.

Result: The line series does not redraw in the plot area, and retains the previous small size.

This issue can also be seen in your ExampleBrowser application in the Cartesian axes examples. Any idea what might be causing this?

Thanks in advance for your help.

everytimer wrote at 2013-08-17 20:45:

I think the root of the problem is the requirement of being at the same scale, the X and Y axes. When you reduce the width, the X remains the same but the Y axis range is going up. When the width of the plot is zero the Y range should be infinity and there I think is the problem. This happens not only when you Maximize the window but even if you just resize manually.

To solve this you could associate the Window State Changed to a method that resets the axes.
void ResetAxes()
{
foreach (var axis in plotter.Axes)
{
axis.Reset();
}
}
Good luck

endorphing wrote at 2013-10-08 21:24:

Thanks for the response. I ended up resetting the axes, as you described ( my code is below). I do wish there was a way to detect the size change at the Model level though (that feels like a more reusable and maintainable solution).
<oxy:Plot Name="MyPlot" Model="{Binding MyPlot.Model}" SizeChanged="MyPlot_SizeChanged" />

private void MyPlot_SizeChanged(object sender, SizeChangedEventArgs e)
{
    var plotter = sender as Plot;
    var model = plotter.Model;
    if (!ReferenceEquals(model, null) && model.PlotType == PlotType.Cartesian)
        plotter.ResetAllAxes();
}

thomasdr wrote at 2013-12-12 12:45:

If you don't mind modifying the OxyPlot source code, I have a fix for this problem. Go to the Issues section of this site and look for an issue entitled "Cartesian axes zoom in one direction only"

objo wrote at 2013-12-12 20:27:

thomasdr: thanks for the contribution! but I agree with you that it is a bit quick&dirty, so I am waiting for a simple&clean solution before merging this into the main branch!
The best solution would be to solve the 'cartesian axes' in a more general way, as described in https://oxyplot.codeplex.com/workitem/10095