Jump to content
Software FX Community

Crash after removing axis


MattHolmes

Recommended Posts

In our software, we allow the user to choose from several curves our math package pushes out to our data model. Basically each curve is represented by a series, and we do some automatic axis management to make sure a properly labeled and unit converted / scale axis exists for that curve (this works).

 The issue is that when a user removes a curve, and we attempt to remove the associated axes, we get a crash inside of Chart FX. Our CleanAxes function looks like this:

private void CleanAxes () {   List<Axis> rem = new List<Axis> ();   foreach (Axis axis in _chart.AxesX) {   var query = from s in _chart.Series   where   s.AxisX == axis   select   s;   if (query.Count () <= 0) {   rem.Add (axis);   }   }   foreach (Axis axis in rem) {   _chart.AxesX.Remove (axis);   }   rem.Clear ();   foreach (Axis axis in _chart.AxesY) {   var query = from s in _chart.Series   where   s.AxisY == axis   select   s;   if (query.Count () <= 0) {   rem.Add (axis);   }   }   foreach (Axis axis in rem) {   _chart.AxesY.Remove (axis);   }   }

 Basically it goes through the X and Y Axes lists and removes any axis that no longer has any series using it.

When this code is finished running, and the chart tries to draw again, we get the following exception:

Message: Object reference not set to an instance of an object.Stack Trace: at ChartFX.WPF.Internal.PlotAreaCore.a(Axis A_0, IList`1& A_1, Axis A_2, IList`1& A_3) at ChartFX.WPF.Internal.PlotAreaCore.a(PaintMark A_0, AttributesResolver A_1, Boolean A_2, Boolean A_3, Double A_4, Double A_5, PaintSeriesInfo[] A_6) at ChartFX.WPF.Internal.PlotAreaCore.a(AttributesResolver A_0, Double A_1, Double A_2) at ChartFX.WPF.Internal.PlotAreaCore.a(Double A_0, Double A_1, Boolean A_2) at ChartFX.WPF.Internal.PlotAreaCore.b(Double A_0, Double A_1, Boolean A_2) at ChartFX.WPF.Internal.PlotAreaItems.OnRenderSizeChanged(SizeChangedInfo sizeInfo) at System.Windows.ContextLayoutManager.fireSizeChangedEvents() at System.Windows.ContextLayoutManager.UpdateLayout() at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg) at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork() at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget) at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)

 Is there some safe way to remover axes that I am not aware of?

 Another addition question that isn't really crucial right now, but has me curious: When I do Chart.Series.Clear(), why does ChartFX add two default series back to the chart? When I clear the series, I'd really like it to actually be clear.

Link to comment
Share on other sites

We have found and fixed the exception when removing an axis, any build marked 3701 or later will include the fix.

>> When I do Chart.Series.Clear(), why does ChartFX add two default series back to the chart? When I clear the series, I'd really like it to actually be clear.

This is because we want a default chart (no series) to show some random data as opposed to showing "No Data Available", you might want to try setting Chart.ItemsSource to null and see if that gives you an empty chart instead of the 2 random series.

If this doesn't work please try posting a simple app that shows this behavior.

Regards,

JuanC

Link to comment
Share on other sites

The hotfix site now lists build 3702 as being up, but when I attempt to install or download that build, it just gives me 3700 again. Is there an issue with the hotfixer? I've tried both doing the automated download, and doing the Download link that gives me an exe installer. In both cases, build 3700 is installed despite it saying 3702 is available.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...