stride3d/stride · error · ArgumentNullException

Y axis should not be null when transforming.

Error message

Y axis should not be null when transforming.

What it means

This InverseTransform overload converts a point in screen/render coordinates back to data coordinates and requires a Y axis to invert the y component. A null yaxis would cause a NullReferenceException deeper in the call, so the method throws ArgumentNullException up front with the parameter name 'yaxis'.

Solutions

  1. Pass a non-null AxisBase instance as the yaxis argument
  2. Initialize/assign the YAxis of the chart or view model before transforming points
  3. Guard with a null check before calling and skip/schedule the transform
  4. Catch ArgumentNullException if null is an expected transient state

Example fix

// before
var point = xAxis.InverseTransform(x, y, yAxis); // yAxis may be null
// after
if (yAxis != null)
{
    var point = xAxis.InverseTransform(x, y, yAxis);
}
Defensive patterns

Strategy: validation

Validate before calling

if (yaxis == null) return; // or defer
dataPoint = axis.InverseTransform(x, y, yaxis);

Type guard

bool CanTransform(AxisBase yaxis) => yaxis != null;

Try / catch

try { p = axis.InverseTransform(x, y, yaxis); }
catch (ArgumentNullException ex) when (ex.ParamName == "yaxis") { /* defer until axes ready */ }

Prevention

When it happens

Trigger: Calling axis.InverseTransform(x, y, null) — passing a null yaxis argument, or passing a view model/axis object whose YAxis property has not been initialized yet.

Common situations: Curve editor panels constructed before axes are bound; code that only configures the X axis and forgets Y; transforms invoked during layout before the axis collection is populated.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/dee0f20c82a648a1. Report an issue: GitHub.

Appendix: source

Thrown at sources/editor/Stride.Assets.Presentation/CurveEditor/Axes/AxisBase.cs:498

        /// <param name="sx">The relative screen coordinate.</param>
        /// <param name="isVector">True if the transform is a vector transform (i.e. only applies scale, not translation). The default value is False.</param>
        /// <returns>The value.</returns>
        public virtual double InverseTransform(double sx, bool isVector = false)
        {
            return PostInverseTransform((sx / Scale) + (isVector ? 0 : Offset));
        }

        /// <summary>
        /// Inverse transform the specified screen point.
        /// </summary>
        /// <param name="x">The x coordinate.</param>
        /// <param name="y">The y coordinate.</param>
        /// <param name="yaxis">The y-axis.</param>
        /// <param name="isVector">True if the transform is a vector transform (i.e. only applies scale, not translation). The default value is False.</param>
        /// <returns>The data point.</returns>
        public virtual Point InverseTransform(double x, double y, AxisBase yaxis, bool isVector = false)
        {
            if (yaxis == null) throw new ArgumentNullException(nameof(yaxis), "Y axis should not be null when transforming.");
            return new Point(InverseTransform(x, isVector), yaxis.InverseTransform(y, isVector));
        }

        /// <summary>
        /// Determines whether the axis is horizontal.
        /// </summary>
        /// <returns><c>true</c> if the axis is horizontal; otherwise, <c>false</c> .</returns>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool IsHorizontal()
        {
            return Position == AxisPosition.Top || Position == AxisPosition.Bottom;
        }

        /// <summary>
        /// Determines whether the specified value is valid.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns><c>true</c> if the specified value is valid; otherwise, <c>false</c>.</returns>

View on GitHub (pinned to 96fad776d2)