This project is read-only.

Infinite loop when doing Fit To View...

Jan 19, 2010 at 5:13 AM

Hello,

I have this scatter plot which I've created - it's pretty much based on the BigPointArrayPage example in the NewMarkersSample project.

The relevant plot xaml is below:

 

            <d3:DevMarkerChart Name="markerChart" IndependentValuePath="X" DependentValuePath="Y" BoundsUnionMode="Bounds" >
                <d3:DevMarkerChart.MarkerBuilder>
                    <d3:TemplateMarkerGenerator>
                        <DataTemplate DataType="{x:Type Point}">
                            <Ellipse Width="5" Height="5" SnapsToDevicePixels="True" Focusable="False"
                                     Fill="{Binding RelativeSource={RelativeSource Self}, Path=DataContext, Converter={StaticResource converter}}">
                            </Ellipse>
                        </DataTemplate>
                    </d3:TemplateMarkerGenerator>
                </d3:DevMarkerChart.MarkerBuilder>
            </d3:DevMarkerChart>

After the points chart is built, I set the visible bounds as follows:

 

MinXValue = (from p in pts select p.X).Min();
MinYValue = (from p in pts select p.Y).Min();
MaxXValue = (from p in pts select p.X).Max();
MaxYValue = (from p in pts select p.Y).Max();
double w = MaxXValue - MinXValue;
double h = MaxYValue - MinYValue;

plotter.Visible = new DataRect(MinXValue - w/30, MinYValue - h/30, w + w/15, h + h/15);

The initial bounds are set properly; however, after moving, zooming, etc, all with the built in DDD navigation functionality, when I right-click in the chart and perform a View to Fit, I end up going into an infinite loop where the axes/chart bounds go crazy, as if they could not determine the bounds of the chart.  If you would take a look at the wmv file at the location below (20 seconds, download size is 323kb), you'll see what I mean.  

http://cid-702233e61e834ac6.skydrive.live.com/self.aspx/.Public/ScatterPlotProblem.wmv?authkey=RrIauP9jpM8%24

Would any of you have any idea as to what could be causing this?

Thanks very much,

E.

 

Jan 20, 2010 at 4:10 AM

Just to provide a bit more detail, my plotter also has a RectangleSelector, e.g.:

 

<d3:ChartPlotter Name="plotter" >
	<d3:DevMarkerChart Name="markerChart" IndependentValuePath="X" DependentValuePath="Y" >
		<d3:DevMarkerChart.MarkerBuilder>
			<d3:TemplateMarkerGenerator>
				<DataTemplate DataType="{x:Type Point}">
					<Ellipse Width="5" Height="5" SnapsToDevicePixels="True" Focusable="False"/>
				</DataTemplate>
			</d3:TemplateMarkerGenerator>
		</d3:DevMarkerChart.MarkerBuilder>
	</d3:DevMarkerChart>

	<d3:RectangleSelector Name="selector" Mode="ClickAndDragSelect" RectangleTemplate="{StaticResource SelectorTemplate}" />
</d3:ChartPlotter>

By default, the selector object's SelectedRectangle.IsEmpty is true.   Upon clicking Fit to View, we wind up in Viewport2D.UpdateContentBoundsHosts(), which calls UpdateVisible which eventually winds up in Viewport2D.CoerceVisible.

In CoerceVisible, the bounds grow as a result of a call to CoordinateUtilities.RectZoom  with a clipToBoundsEnlargeFactor = 1.1.  Upon the bounds growing a, a newVisible Visible rect is returned, which eventually calls viewport.RaisePropertyChangedEvent with the new Visible rectangle, which calls UpdateContentBoundsHosts(), and so we begin again, going in an infinite loop, making the plotter grow and grow...

Perhaps this is a a bug somewhere stemming in the CoerceVisible logic?

Anyhow, for now, setting the selector object's SelectedRectangle property to "0,0,0,0" at the beginning is a workaround, but it's not pretty, because then it's visible, even when its size is zero...  So I needed to add logic to make the RectangleTemplate's Visibility set to Collapsed when the SelectedRectangle is 0.  Again, not pretty, but it works for now.

Just posting in case anyone encounters a similar issue.

E.