AnthonyJones Posted October 8, 2009 Report Share Posted October 8, 2009 Our application allows the user to change the chart type and appearance from a context menu. If the legend box is visible and the user has unticked one or more series, and the chart type is then changed to a 3D pie (or dougnut or pyramid), then ChartFX.WPF throws the following exception: System.NullReferenceException was unhandled Message="Object reference not set to an instance of an object." Source="ChartFX.WPF" StackTrace: at ChartFX.WPF.PlotArea3D.a(PaintMark A_0, LogicalItemCollection A_1) at ChartFX.WPF.Internal.PlotAreaCore.a(PaintMark A_0, AttributesResolver A_1, Double A_2, Double A_3, LogicalItemCollection A_4, LogicalItemCollection A_5, Int32 A_6, Boolean A_7) 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.PlotArea3D.c(Object A_0, EventArgs A_1) at ChartFX.WPF.PlotArea3D.Viewport3DRepaint.OnRender(DrawingContext drawingContext) at System.Windows.UIElement.Arrange(Rect finalRect) at System.Windows.Controls.Border.ArrangeOverride(Size finalSize) at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect) at System.Windows.UIElement.Arrange(Rect finalRect) at System.Windows.Controls.DockPanel.ArrangeOverride(Size arrangeSize) at ChartFX.WPF.TitlePanel.ArrangeOverride(Size arrangeSize) at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect) at System.Windows.UIElement.Arrange(Rect finalRect) at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize) at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize) at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect) at System.Windows.UIElement.Arrange(Rect finalRect) at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds) at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect) at System.Windows.UIElement.Arrange(Rect finalRect) at ChartFX.WPF.Controls.GridFocus.a(UIElement A_0, Rect A_1, LayoutType A_2) at ChartFX.WPF.Controls.GridFocus.a(Size A_0, LayoutType A_1) at ChartFX.WPF.Controls.GridFocus.ArrangeOverride(Size arrangeSize) at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect) at System.Windows.UIElement.Arrange(Rect finalRect) at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize) at System.Windows.Controls.ItemsPresenter.ArrangeOverride(Size arrangeSize) at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect) at System.Windows.UIElement.Arrange(Rect finalRect) at System.Windows.Controls.Border.ArrangeOverride(Size finalSize) at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect) at System.Windows.UIElement.Arrange(Rect finalRect) at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds) at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect) at System.Windows.UIElement.Arrange(Rect finalRect) at ChartFX.WPF.Controls.SpacingDockPanel.ArrangeOverride(Size finalSize) at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect) at System.Windows.UIElement.Arrange(Rect finalRect) 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.AnimatedRenderMessageHandler(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) at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state) at System.Threading.ExecutionContext.runTryCode(Object userData) at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) 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) at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter) at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.Run() at System.Windows.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at System.Windows.Application.Run(Window window) at System.Windows.Application.Run() at OBM_EXE.App.Main() in C:\Users\user\Documents\Projects\Neutrino\Code\OBM\OBM_EXE\obj\Debug\App.g.cs:line 0 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() We are currently using version 8.0.3488.31327. Has this been fixed in a later version? The online updater doesn't offer me anything newer than 8.0.3422.28509. Thanks, Anthony. Quote Link to comment Share on other sites More sharing options...
JuanC Posted October 8, 2009 Report Share Posted October 8, 2009 I tested a small app that starts with 3 series and when a button is pressed we execute this code chart1.Series[0].Visibility = Visibility.Collapsed; Then when the button is pressed again we run this code chart1.View3D.IsEnabled = true; chart1.Gallery = Gallery.Pie; I also tried to start with a 3D chart, in both cases, our most recent build works as expected. You can download our most recent hotfix here (note that if UAC is enabled you have to make sure IE is run as an Administrator) If the problem persists please try to duplicate the issue in a small dummy app. JuanC Quote Link to comment Share on other sites More sharing options...
AnthonyJones Posted November 3, 2009 Author Report Share Posted November 3, 2009 Apologies for the long delay in replying, I've been away. I have managed to reproduce the problem in this small app. If you click the button to hide the series, then the button to change the chart to a 3D pie, the exception is thrown: Window1.xaml: <Window x:Class="Chart3DTest.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:cfxControls="clr-namespace:ChartFX.WPF;assembly=ChartFX.WPF" Title="Window1" Height="500" Width="500"> <Grid> <StackPanel Orientation="Vertical"> <cfxControls:Chart Name="chartTest" VerticalAlignment="Top" HorizontalAlignment="Center"/> <Button Name="btnHide" Content="Hide series 1" VerticalAlignment="Bottom" HorizontalAlignment="Center"/> <Button Name="btnChange" Content="Change to 3D pie" VerticalAlignment="Bottom" HorizontalAlignment="Center"/> </StackPanel> </Grid> </Window> Window1.xaml.cs: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using ChartFX.WPF; namespace Chart3DTest { /// <summary> /// Interaction logic for Window1.xaml /// </summary> public partial class Window1 : Window { public Window1() { InitializeComponent(); btnChange.Click += new RoutedEventHandler(btnChange_Click); btnHide.Click += new RoutedEventHandler(btnHide_Click); } void btnHide_Click(object sender, RoutedEventArgs e) { chartTest.Series[0].Visibility = Visibility.Hidden; } void btnChange_Click(object sender, RoutedEventArgs e) { chartTest.View3D.IsEnabled = true; chartTest.Gallery = Gallery.Pie; } } } I'm now using 8.0.3565.24914 and the problem still occurs. I noticed that you used Visibility.Collapsed rather than Visibility.Hidden in your example. If I do the same in this app it works fine. What's the difference between Hidden and Collapsed? Thanks, Anthony. Quote Link to comment Share on other sites More sharing options...
JuanC Posted November 4, 2009 Report Share Posted November 4, 2009 This issue has been fixed on build 3594 (available as a hotfix). In Axis charts (Bar, Line, etc.) a hidden series will still "contribute" to the axis scale while a collapsed series will not. In Pie chart there should be no difference between the 2. JuanC Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.