This project is read-only.

Simulation Example AutoPan feature?

May 5, 2009 at 3:16 PM
HI, 
First of all: great job.

In the simulation example, the horizontal axis continues to autoscale data. until I pan or zoom the graph. 
Is there a way to autopan (without scaling) while I'm adding points to the ObservableDataSource?

Regards,
Marco Roello
May 6, 2009 at 12:51 PM
Hi Marco,

Do you want viewport to pan automatically when it is in a FitToView mode?

Mikhail.
May 6, 2009 at 4:32 PM
Edited May 6, 2009 at 4:35 PM
Mikhail, 
I'm sorry but I'm a newbye....

My need is to autoscroll x axis while I'm adding points to my graph.
I've seen that working with ViewPort.Visible I can adjust the visible area of the graph.

1) How to determine if the plotter is in FitToView mode. Can you help me?

2) One problem I still have is when using ViewPort.Visible I obviously loose the Y FitToView and I don't know how to determine the Min and Max Y values.

3) Is there a way to change the X,Y axis Scale using mouse? (I've played a lot with NPlot, a opensource GDI chart library, and that feature is very usefull)

These are few lines of code that demonstrate how I achieve an X AutoScroll....is this correct or there's a better way?

private delegate void ScrollViewPortDelegate(double x);
ScrollViewPortDelegate _scrollViewPortMethod;
.
.
.
// this is the code I use to add a Point 
//_sources[index] is an ObservableDataSource<Point> 
_sources[index].AppendAsync(Dispatcher, p1);
 Dispatcher.BeginInvoke(_scrollViewPortMethod, p1.X);
.
.
.
private void ScrollViewPort(double x)
        {
            double width = 10000;
            Rect r = plotter.Viewport.Visible;
            plotter.Viewport.Visible = new Rect(x - width, r.Y, width + 1000, r.Height);
            
        }

Thanks
May 14, 2009 at 8:10 AM
Hi Marco,

1) Plotter's viewport is considered as being in FitToView state when Viewport.Visible dependency property doesn't have locally set value. In this case, during the coercion phase of DP's value determining, size of children content is measured and used to produce new value of Visible. You can determine whether viewport is in this state by reading value from viewport's IsFittedToView property. Now there is no event that occurs when this state changes.
2) There are two collections in Viewport, that can be usefull to you - Restrictions and FitToViewRestrictions. Both these collections should contain descendants of ViewportRestrictionBase class - a simple class that has one method 
public abstract DataRect Apply(DataRect oldDataRect, DataRect newDataRect, Viewport2D viewport);

which is being called each time visible rectangle changes. As you can see, it takes three arguments - old and new (proposed) visible rectanges and the instance of Viewport to which this restriction is being applied, and returns new modified visible rectangle. The only difference between these two collections is that restrictions from FitToViewCollection are being applied before restrictions from Restrictions collection and only when Viewport is in FitToView state. You can add a new restriction to one of these collections and get a behavior you need. First of all, consider using built-in restrictions:
  • DataHeightRestriction, which is designed to work mainly in Restrictions collection and which is capable to restrict height of visible rectangle to a little bit enlarged united height of data in charts in specified x-borders.
  • FollowWidthRestriction, which is designed to work mainly in FitToViewRestriction collection and which limits x coordinates of visible rectangle so that actual visible rectangle has fixed width (you can change it - there is Width property in restriction) and is situated at the right side of visible rectangle, determined by uniting children content bounds.
Also you can easily create a new restriction which suites your need better.
Simply create an instance of restrcition (s) you need and add it or them to proper collection of Viewport.

3) Yes, it is possible to change scale of axes independently using mouse - simply place mouse over the axis you need to scale and rotate mouse wheel. If you need another way of doing it, please, write here your suggestion.

Best regards,
Mikhail Brinchuk,
DynamicDataDisplay developer.


2009/5/6 abunet <notifications@codeplex.com>

From: abunet

Mikhail, 
I'm sorry but I'm a newbye....

My need is to autoscroll x axis while I'm adding points to my graph.
I've seen that working with ViewPort.Visible I can adjust the visible area of the graph.

1) How to determine if the plotter is in FitToView mode. Can you help me?

2) One problem I still have is when using ViewPort.Visible I obviuosly lose the Y FitToView and I don't now how to determine the Min and Max Y values.

3) Is there a way to change the X,Y axis Scale using mouse? (I've played a lot with NPlot, a opensource GDI chart library, and that feature is very usefull)

These are few lines of code that demonstrate how I achieve an X AutoScroll....is this correct or there's a better way?

private delegate void ScrollViewPortDelegate(double x);
ScrollViewPortDelegate _scrollViewPortMethod;
.
.
.
// this is the code I use to add a Point 
//_sources[index] is an ObservableDataSource<Point> 
_sources[index].AppendAsync(Dispatcher, p1);
 Dispatcher.BeginInvoke(_scrollViewPortMethod, p1.X);
.
.
.
private void ScrollViewPort(double x)
        {
            double width = 10000;
            Rect r = plotter.Viewport.Visible;
            plotter.Viewport.Visible = new Rect(x - width, r.Y, width + 1000, r.Height);
            
        }

Thanks

Read the full discussion online.

To add a post to this discussion, reply to this email (dynamicdatadisplay@discussions.codeplex.com)

To start a new discussion for this project, email dynamicdatadisplay@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


May 14, 2009 at 8:15 AM

Hi Marco,

Sorry, I forgot to upload the latest development version of D3, which contains some things I've spoke about - it is here - http://cid-eaf0a921258b5980.skydrive.live.com/self.aspx/.Public/D3/DynamicDataDisplay%20For%20Marco.zip

 

Best regards,

Mikhail.