Points not aligned with axes

Aug 27, 2010 at 2:19 AM

I've just come across this project, and it looks really cool.  However, I noticed in the Hello World Sample that the points don't always appear in the right places.  For example, Sin(.9) is about .78.  However, on the graph, upon zooming in, it shows as about .73.  I find that if I zoom in far enough (x range of .7 to 1.5, y range of -715 to .731), then resize the window vertically, the line moves about left-to-right.

I've built from the latest source code AND run the downloaded binaries - both show the problem.

Does anyone else see this?

Thanks,

Jeff

 

Aug 27, 2010 at 4:09 AM

Jeff,

I've tried this on my PC and the Hello World Sample displays the sine graph correctly.  If I zoom in on 0.9 I see the Y value of 0.7833 (as expected).

What O/S are you running on?  Not sure why that would matter but can't think of any other explanation.

Grant.

Aug 27, 2010 at 5:15 AM

I'm running Windows 7 x64.  I tried at home on another Windows 7 x64 machine - same issue.  Both are Core-2 Duo machines.  I tried setting the HelloWorldSample target Processor to x86, but it didn't change the behavior.

-Jeff

Aug 31, 2010 at 12:13 AM
Edited Aug 31, 2010 at 12:20 AM

Here's a screen shot of what I'm seeing:

Bad 1

Then, after resizing the window just a little smaller:

Bad 2

If those don't work, this slide show is easier to see

 

Dec 2, 2011 at 1:40 PM

We are seeing the behavior that Jeff mentions, and other undesirable behaviors in the Silverlight version 0.3. In our implementation, we have several key requirements that must be met:

  1. The user can define the minimum and maximum values for the Y-axis.
  2. The user can define whether or not the Y-axis range is automatically changed to fit the plotted data points, or stays fixed at the specified minimum and maximum values.
  3. The user can define the time span that is displayed on the X-axis.
  4. The X-axis should automatically update with time values as new data is added to the plot data source.
  5. The user can resize the chart in the horizontal and vertical directions.

A simplified description of our implementation goes something like this:

  • We have a custom (templated) control that contains a border. The border contains a nested ContentPresenter whose content is a D3 chart.
    • The height of the border is bound to a property on the parent control. So changing the border height affects the height of the D3 chart control that it contains
    • The initial height of the border is set to 250
  • When the control is rendered, and after each subsequent data value update, we recalculate the size of the plot viewport, which performs the following tasks:
    • If the Y-axis is set to auto-range, new minimum and maximum values are calculated based on the limits of the current data set.
    • The Y-axis's AxisControl.Range property is set to a new Range instance.
    • The ChartPlotter's Viewport.Visible property is set to a new rectangle that is calculated based on the user's selected data time span (X-axis) and the current Y-axis minimum and maximum values.

We have observed the following:

  • When the height of the control that contains the ChartPlotter is set to the default value of 250, with a Y-axis min/max of 0/100, plotting a constant value of 20.0 in a line graph, the line graph plots at a value of about 30. 
    • The error becomes greater as the constant value is decreased, and becomes smaller as it gets closer to 100.
  • If we resize the height of the control that contains the ChartPlotter, say from 250 to 300, while plotting a constant value of 20, the line graph plots at around 0.0. So there does not appear to be a causal relationship between the coordinate system of the plot area and the coordinate system of the axes.

My understanding is that, by default, the coordinate transformations for the plot viewport and the axis control are identical (identity). So if I change the available screen size by increasing or decreasing the height of the ChartPlotter, the axis would re-apply its transform the next time its Range property is set.

Can anyone shed some light on how this works and tell me if I am correct in my understanding?

 

 

 

Dec 2, 2011 at 3:21 PM

Okay, so I figured it out. I created a SizeChanged handler for the MainGrid element in the ChartPlotter, and re-create the VerticalAxis at that point. This forces the ticks and labels to get rebuilt and everything works properly.

Dec 5, 2011 at 1:51 PM

integragreg,

Would you mind providing a code example? I have a feeling I will need to do a similar thing.