Nevron Forum

set begin and end value for DateTime scale

https://www.nevron.com/Forum/Topic12507.aspx

By Manal Goyal - Monday, June 18, 2018

Hi,

I have date time scale on x axis, and I want to give user a option to select a specific time span, for that I am thinking to restrict the x axis to a certain begin and end values, but I dont know hoe can I do that. is it possible? Please let me know the solution to my problem.

Thanks and regards
Manal
By Nevron Support - Monday, June 18, 2018

Hi Manal,
Yes it is possible to restrict the range of any axis in the control. Since date times in Nevron Chart are internally represented by double values (their OA equivalent) you need to convert the start / end date time to OA Date Time format. The following code shows how to do that:

DateTime dtEnd = DateTime.Now;
DateTime dtBegin = dtEnd - new TimeSpan(12, 0, 0);

chart.Axis(StandardAxis.PrimaryX).View = new NRangeAxisView(new NRange1DD(dtBegin.ToOADate(), dtEnd.ToOADate()), true, true);

Hope this helps - let us know if you meet any problems or have any questions.