Closed danwalmsley closed 1 year ago
updated to 11 rc1.1
Thanks for doing the RC1 refit; I couldn't manage to do that myself. Again, please could you drop https://github.com/oxyplot/oxyplot-avalonia/commit/65554e4f72a0e14cd392f4945367b919d1c326ae and rebase on master (https://github.com/oxyplot/oxyplot-avalonia/commit/c5ba4803473ce4fc24228b57cb65c64d1806a7e5) which contains fixes for invalidation problems.
@VisualMelon that should now be inline with your request.
@danwalmsley thanks, I'm away this weekend, but will retest next week.
Hello, have you gotten the chance to test yet @VisualMelon ? I personally have been using this branch in an Avalonia 11.0.0-rc1.1 project on Windows, and for my use case, it mostly works!
However, I have encountered one issue: the PngExporter
's Export
member (that takes in a Stream
and an IPlotModel
) fails to properly export the image to the file stream; the resulting file is completely empty. I can only export files if I first use the PngExporter
to export the plot to an Avalonia Bitmap
, and then save to the file via the bitmap.
@moonshxne thanks for the nudge: tested now, and seems to work fine with RC1 and the 11 release.
Fixes for a couple of issues with the AvaloniaExamples in https://github.com/VisualMelon/oxyplot-avalonia/tree/av11_release (and bumped to Avalonia 11 release)
Re. issue with PngExporter, I can't reproduce this, e.g. stuffing the below into the SimpleDemo view model constructor produces the expected result
using (var s = new FileStream("SimpleDemo.png", FileMode.Create))
{
OxyPlot.Avalonia.PngExporter.Export(tmp, s, 640, 480, OxyColors.WhiteSmoke);
// or
new OxyPlot.Avalonia.PngExporter() { Background = OxyColors.WhiteSmoke, Width = 640, Height = 480, Resolution = 96 }.Export(tmp, s);
}
Can you provide a minimal reproducing example? Note the implementation of this method is as you describe: it first exports to an Avalonia Bitmap, then saves that bitmap to the stream.
Does the PngExporter's Export
work in an asynchronous/task-based context, i.e., in conjunction with Avalonia's StorageProvider
API for saving user-selected files?
E.g., (within a ViewModel)
// filesService is an abstraction that wraps Avalonia's StorageProvider
var file = await filesService.SaveFilePickerAsync();
if (file is not null) {
await using s = await file.OpenWriteAsync();
new OxyPlot.Avalonia.PngExporter().Export(plot, s);
}
doesn't quite work. The PNG file is created as requested by the user, but no data is written to it.
Is it just the case that I can't use these methods in an async function? Then the workaround I did, first creating the Avalonia BitMap synchronously, and then asynchronously exporting the bitmap to disk, is probably just the way to go.
That's interesting; I don't know. I got a crash when trying to export from a non-UI thread: is it possible that the code is throwing, and as such leaving the file empty but the exception not being registered?
@Takoooooo see https://github.com/VisualMelon/oxyplot-avalonia/commits/av11_release for a couple of fixes to the examples
Sorry it's a bit inconvenient for me to actually test out exporting with async until maybe at night. I personally suspect that the exceptions, if any, are possibly being swallowed by some of my program logic.
That said, is this a blocker for upgrading this library to Avalonia 11? If not, I'll open a new issue after investigating a little bit.
I don't see it as a blocker; please do open an issue if you discover anything more.
Merging: will commit example fixes later. Will try to sort out a 2.1.2 targetting Av11 soon.
@danwalmsley this PR changed the PackageID to AvaloniaOU.Oxyplot
I presume you'd have no issue with this being changed back to OxyPlot.Avalonia
?
Can you scrub https://github.com/oxyplot/oxyplot-avalonia/pull/55/commits/65554e4f72a0e14cd392f4945367b919d1c326ae and rebase on master (https://github.com/oxyplot/oxyplot-avalonia/commit/c5ba4803473ce4fc24228b57cb65c64d1806a7e5) and then verify that the invalidation issue isn't present?