Jump to content
Software FX Community

DataView corrupt after input size changes


pepeiborra

Recommended Posts

Hi,

I am using a Surface type chart with View3D enabled, and the default DataView made visible. My app has functionality for allowing my users to zoom, which is currently implemented (there might be a better/more appropriate way to do it. If so please point it out) by slicing the elements in the collection used as input source.

Apparently the DataView table is not being regenerated after the input source changes its dimensions, and I either get graphical corruption or an incomplete table.

Link to comment
Share on other sites

I can't do that right now, deadline to current project is too close to spare a minute.

But it should be easy to reproduce the behaviour, as I am not doing anything too advanced. Simply binding to an array of 3D points using a CrossTabTransform to shape them into series. Here is the XAML code if that helps:

x:Name="chart1" ItemsSource="{Binding Data.Value}"

Gallery="Surface"

Palette="{x:Static cfx:Palettes.Litmus}"

>

ShowContourLines="False"

ShowPointsGridlines="False"

ShowSeriesGridlines="False"/>

The first type of DataView odd behaviour (display corruption) happens after performing the following steps:

1. Bind to some initial data and display the chart with the DataView hidden

2. Make the DataView visible

Fixed by forcing a redraw by e.g. resizing the window.

-----------

The second type of DataView odd behavior (no dataview displayed, just an empty box) happens after performing the following steps:

1. Bind to some initial data and display the chart with the DataView hidden

2. Update the data changing the number of datapoints (the chart refreshes accordingly)

3. Make the DataView visible

In order to fix it, I need to update the data to have the initial dimensions. Also, the problem doesn't happen if the DataView is visible.

Link to comment
Share on other sites

  • 2 weeks later...

Hi, I have some time now to further look at this problem. I apologize for the formatting of my previous post, I didn't notice that you need to use HTML tags explicitly. I am going to try again in a following post.



By the way, I noticed that the build of the trial version of ChartFX that I am using is pretty old. It is version 8.0.3581.26941dated from 2/22/2010. I don't see any options to download a more recent build. Any chances that I can get access to one so that I can verify whether the issue has been fixed already?



Thanks.

Link to comment
Share on other sites

I finally got access to a computer where I can allow ActiveX controls (sort of) and after installing the hotfix, the problem with the DataView is still there.

However I managed to better identify it. There were two separate issues:

  • The checkbox that toggled the dataview on and off was changing its visibility from Visible to Hidden. Using Collapsed instead of Hidden fixed the visual corruption which ocurred when hiding the chart and making it visible again. My bad
  • In order to provide zoom functionality, I allow the user to select the ranges of the axis, implemented by slicing the data array. This works fine with the Chart itself, but the dataview dissapears when shrinking the ranges and throws an OutOfBounds exception

    System.Windows.Data Error: 16 : Cannot get 'Data' value (type 'IEnumerable') from '' (type 'ItemsSourceHolder'). BindingExpression:Path=Data; DataItem='ItemsSourceHolder' (HashCode=49594800); target element is 'DataGridItems' (Name=''); target property is 'ItemsSource' (type 'IEnumerable') TargetInvocationException:'System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)   at System.ThrowHelper.ThrowArgumentOutOfRangeException()   at System.Collections.Generic.List`1.get_Item(Int32 index)   at ChartFX.WPF.Internal.AmbientCollection`1.get_Item(Int32 index)   at ChartFX.WPF.SeriesField.DefaultHeader(PaintInfo paintInfo, Object& content, DataTemplate& dataTemplate)   at ChartFX.WPF.DataGridItems.RenderHeaders(PaintInfo paintInfo)   at ChartFX.WPF.DataGridItems.BuildItemsSource(Object obj, IEnumerator enumerator, Int32 count, Int32& rows)   at ChartFX.WPF.DataView.ChartFX.WPF.Internal.ILogicalItemsBuilder.Build()   at ChartFX.WPF.Internal.ItemsSourceHolder.get_Data()   --- End of inner exception stack trace ---   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)   at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)   at MS.Internal.Data.PropertyPathWorker.GetValue(Object item, Int32 level)   at MS.Internal.Data.PropertyPathWorker.RawValue(Int32 k)'

The actual project is a bit more complex and uses in-house developed frameworks, so I am afraid it is not feasible to extract a self-contained example without investing a significant amount of time. Hopefully the stack trace above can be useful to identify the issue.

In case it helps, here is the XAML I use to declare the chart:

<cfx:Chart Grid.RowSpan="2"                   x:Name="chart1"                   Gallery="Surface"                   Palette="{x:Static cfx:Palettes.Litmus}"                   ItemsSource="{Binding Points.Value}">            <cfx:Chart.Resources>            </cfx:Chart.Resources>                <cfx:Chart.DataTransforms>                    <cfxData:CrosstabTransform RowPath="X" ColumnPath="Y" ValuePath="Z"/>                </cfx:Chart.DataTransforms>                <cfx:Chart.Titles>                    <cfx:Title>                    <TextBlock  FontSize="14" Foreground="#FFCCCCCC" Text="{Binding Path=Name}" Margin="0 20 0 0"/>                </cfx:Title>                 </cfx:Chart.Titles>                <cfx:Chart.View3D>                    <cfx:View3D IsEnabled="True"/>                </cfx:Chart.View3D>                <cfx:Chart.AllSeries>                    <cfx:AllSeriesAttributes>                        <cfx:AllSeriesAttributes.GalleryAttributes>                            <cfxGalleries:Surface ShowScaleInLegend="False"                                                   ShowContourLines="False"                                                   ShowPointsGridlines="False"                                                  ShowSeriesGridlines="False"/>                        </cfx:AllSeriesAttributes.GalleryAttributes>                    </cfx:AllSeriesAttributes>                </cfx:Chart.AllSeries>                <cfx:Chart.Series>                    <cfx:SeriesAttributes Fill="{StaticResource MyBlueGradient}"/>                </cfx:Chart.Series>                <cfx:Chart.DataView >                    <cfx:DataView Visibility="{Binding ElementName=Vol, Path=DataContext.DataVisibility.Value}"                                    MaxHeight="150"  />                </cfx:Chart.DataView>            <cfx:Chart.AxisX>                <cfx:Axis>                    <cfx:Axis.Title>                        <cfx:Title Content="X Axis"/>                    </cfx:Axis.Title>                </cfx:Axis>            </cfx:Chart.AxisX>            <cfx:Chart.AxisY>                <cfx:Axis>                    <cfx:Axis.Title>                        <cfx:Title Content="Y Axis" />                    </cfx:Axis.Title>                </cfx:Axis>            </cfx:Chart.AxisY>        </cfx:Chart>
Link to comment
Share on other sites

>> Installing the hotfix

Note that you can also visit our hotfix page even on a machine without Chart FX installed, instead of installing you can download the hotfix as a self-extracting executable that you can then run on the machine where ActiveX controls are disabled.

>> Setting the visibility to hidden instead of collapsed

We will research this as the visual corruption should not exist but we try as much as possible to honor the WPF behavior where a hidden element will not be visible but it "occupies" space. Maybe this is the reason the for the corruption

>> Zoom capabilities

Note that we provide some zoom capabilities for 2D charts which might be helpful on other charts. You can enable them by setting Chart.Zoom.Mode to Selection. This allows the end user to select a range and we will handle zooming. You can also change the zoom style by setting the Chart.Zoom.Style property to one of the following values: Scroll (after the user selects the range a set of scrollbars will appear on each axis), Map (useful for scatter charts) and Stripe (similar to map but scrolling is limited to X axis).

>> Zoom issue

What happens when the user selects a range, do you set the ItemsSource property again? Do you change any of the data transforms? Does the data source supports INotifyCollectionChanged?

JuanC

 

Link to comment
Share on other sites

>> Installing the hotfix

Note that you can also visit our hotfix page even on a machine without Chart FX installed, instead of installing you can download the hotfix as a self-extracting executable that you can then run on the machine where ActiveX controls are disabled.

I tried that too, but IE7 was crashing on me when trying to download the hotfix. I think I even installed IE8 and it still crashed.

>> Setting the visibility to hidden instead of collapsed

We will research this as the visual corruption should not exist but we try as much as possible to honor the WPF behavior where a hidden element will not be visible but it "occupies" space. Maybe this is the reason the for the corruption

>> Zoom capabilities

Note that we provide some zoom capabilities for 2D charts which might be helpful on other charts. You can enable them by setting Chart.Zoom.Mode to Selection. This allows the end user to select a range and we will handle zooming. You can also change the zoom style by setting the Chart.Zoom.Style property to one of the following values: Scroll (after the user selects the range a set of scrollbars will appear on each axis), Map (useful for scatter charts) and Stripe (similar to map but scrolling is limited to X axis).

Is this supposed to work with 3D surface charts too ? I couldnt get it to, for that reason I wrote some rudimentary code to provide zoom features.

>> Zoom issue

What happens when the user selects a range, do you set the ItemsSource property again? Do you change any of the data transforms? Does the data source supports INotifyCollectionChanged?

When the user selects a range, the property Points.Value of type array is updated with a new sliced array. I do not set ItemsSource again, since the Value property supports INotifyPropertyChanges. This suffices to trigger a redraw of the graph, even though the array type does not supprot INotifyCollectionChanged. I do not change any of the data transforms either.

Thanks

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...