Example of OxyPlot.Wpf renders blank
Hi,
first of all thanks for the great work, LinqPad is just awesome!
I am trying to display the default example of a WPF OxyPlot line chart with the code below, but the output remains white.
I've also tried to put it into a Grid and set the width/height, but the result didn't change.
var model = new PlotModel { Title = "Example 1" }; model.Series.Add(new FunctionSeries(Math.Cos, 0, 10, 0.1, "cos(x)")); var plotView = new PlotView(); plotView.Model = model; PanelManager.DisplayWpfElement(plotView);
I am using LinqPad 5.44.02 (Premium Edition). Any Ideas?
Thanks
Jan
Comments
There's some dodgy code in OxyPlot.Wpf. In PlotViewBase:
If the parent is not a Window, OxyPlot assumes that the control is not in a visual tree. LINQPad doesn't use a Window to host WPF controls; it uses an ElementHost.
I suggest you run the OxyPlot.WindowsForms instead. It seems to perform quite well in LINQPad:
Edit: it looks like this problem has been fixed in the OxyPlot.Wpf source code, but the NuGet package hasn't yet been updated. They don't seem to release too often.
A similar issue seems to be fixed last month for rendering within SkiaSharp:
https://github.com/oxyplot/oxyplot/blame/196bb74bd8105bc1b5730389ec779996e57156a9/Source/OxyPlot.Wpf.Shared/PlotViewBase.cs#L448
I will try to extend OxyPlot to check for ElementHost as well.... otherwise using WinForms is also an acceptable solution. Thanks!
Checking for ElementHost in IsInVisualTree seems not to work either... doesen't matter, I'll continue with the WinForms solution. Thanks again .