Page 1 of 1

Annotations are broken. Can't draw on the canvas.

Posted: Tue Oct 29, 2024 5:36 pm
by 18286055
Steema.TeeChart.NET.MAUI v6.2024.8.29

Seems that the following is the culprit:

Code: Select all

Microsoft.Maui.Graphics.Platform.PlatformCanvas

Seems like the CurrentState is null. It should be an instance of PlatformCanvasState.

Code: Select all

	public override void FillRectangle(float x, float y, float width, float height)
	{
		var rectX = x;
		var rectY = y;
		var rectWidth = width;
		var rectHeight = height;

		_canvas.DrawRect(rectX, rectY, rectX + rectWidth, rectY + rectHeight, CurrentState.FillPaintWithAlpha);
	}
AnnotationTool is a sub-classed Steema.TeeChart.Tools.RectangleTool in the stack trace below.
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Maui.Graphics.Platform.PlatformCanvas.FillRectangle(Single x, Single y, Single width, Single height) in /_/src/Graphics/src/Graphics/Platforms/Android/PlatformCanvas.cs:line 473
at Microsoft.Maui.Graphics.ScalingCanvas.FillRectangle(Single x, Single y, Single width, Single height) in /_/src/Graphics/src/Graphics/ScalingCanvas.cs:line 167
at Microsoft.Maui.Graphics.CanvasExtensions.FillRectangle(ICanvas target, Rect rect) in /_/src/Graphics/src/Graphics/CanvasExtensions.cs:line 22
at Steema.TeeChart.Maui.Drawing.CanvasMaui.Rectangle(Rect r)
at <project>.AnnotationTool.DrawText(CanvasMaui& graphics, ReadOnlyRectangle& bounds) in <project>\Graphs\AnnotationTool.cs:line 241
at <project>.AnnotationTool.Draw(CanvasMaui& graphics, Line& line, DashboardResult& result, ReadOnlyPoint& target, ReadOnlyPoint& source, Int32& currentPointIndex, Boolean& floatingAnnotations, Double& annotationOffset, CultureInfo& culture) in <project>\Graphs\AnnotationTool.cs:line 189
Visual Studio 2022 versions.7z
(2.83 KiB) Downloaded 38 times

Re: Annotations are broken. Can't draw on the canvas.

Posted: Mon Nov 04, 2024 10:37 am
by edu
Hello,

I have tried to reproduce your issue but creating and setting up Annotations seems to work as expected on my end.
Could you please share additional details or code context so we can assist you further?

Best regards,
Edu