How to fix axis limits of an axis (Time axis)

Apr 22, 2009 at 11:12 AM
Hi,

I want to fix axis limits( Range) of my date time axis, I found a method

dateAxis.SetConversion(

DateTime.Now.AddMinutes(-10).ToOADate(), DateTime.Now.AddMinutes(-10), DateTime.Now.AddMinutes(10).ToOADate(), DateTime.Now.AddMinutes(10));

But dateAxis is taking the default limits. How to set the custom limits.
Actually I want to fix the limits of axis for some time (up to 10 Minutes), After that I want to change limits again,
But this is not working, dateAxis is taking default or auto limits

Regards
Ravi

 

Editor
Apr 22, 2009 at 11:59 AM
Hi, Ravi!

As I have understood, you want to change area that is displayed by ChartPlotter.
It is impossible to do it from SetConversion method of axis, this can be done only in one way - creating new Rect with parameters you need and then by passing it to ChartPlotter.Viewport.Visible property.

Let's say you want Plotter to display area with following borders:
0 to 1 vertically (values are of double type), and from 12:00 1 Jan 2009 to 13:55 2 April 2010 horizontally (values are of DateTime type). Than you should do the following:

var axis = (DateTimeAxis)plotter.HorizontalAxis;
double xMin = axis.ConvertToDouble(new DateTime(2009, 1, 1, 12, 0, 0));
double xMax = axis.ConvertToDouble(new DateTime(2010, 4, 2, 13, 55, 0));

Rect visibleRect = new Rect(xMin, 0 /* this is yMin */, xMax - xMin /* this is width */, 1-0 /* this is YMax - YMin = height */);

// that's all
Plotter.Viewport.Visible = visibleRect;

Regards,
Mikhail Brinchuk,
DynamicDataDisplay Dev Team.

Apr 22, 2009 at 12:39 PM

Hi,

 

It’s working. It’s very nice, very smooth than what I expected.

 

Thank you very much

 

Regards,

Ravi.

Apr 22, 2009 at 3:32 PM
Hi Mikhail,

Let's say the x-axis is the DateTime and the y-axis some double values (price).
Through my day I want to see the last 10 minutes of market activity. To achieve this I follow your explication above with a 10 minutes width window.

Now, let's say that I make a compression on the x-axis and now I can see the last 25 minutes or the last 5 minutes. I want to keep this moving window with a width of 25 minutes or 5 minutes.
To achieve this I take the dateTime.Now and the first visible DateTime to construct this window.

Here is my question:
How can I retrieve the first visible DateTime on my plot?

Thanks,
Kamel
Editor
Apr 29, 2009 at 2:09 PM
Hi, Kamel,

What do you mean saying 'the first visible DateTime'? This value depends on Viewport.Visible rect, and if you want to convert one of the properties of Visible to DateTime, you can do the following:
AxisBase<DateTime> axis = (AxisBase<DateTime>)plotter.HorizontalAxis.
DateTime theFirstVisibleDateTime = axis.ConvertFromDouble(plotter.Viewport.Visible.Left);

I'm using plotter.Viewport.Visible.Left as this is left border of visible area, described by double values.

Have I answered on your question? If not, please explain it.

Best regards,
Mikhail.
Apr 30, 2009 at 3:29 AM
I think you did.

I'll give it a try and get back to you.

Thanks!!!