Profile Picture

How to get View Range on Zoom Out button click of PrimaryXAxis Scrollbar with DateTimeScale??

Posted By Niranjan Singh 12 Years Ago

How to get View Range on Zoom Out button click of PrimaryXAxis...

Author
Message
Niranjan Singh
Posted 12 Years Ago
View Quick Profile
Forum Member

Forum Member (41 reputation)Forum Member (41 reputation)Forum Member (41 reputation)Forum Member (41 reputation)Forum Member (41 reputation)Forum Member (41 reputation)Forum Member (41 reputation)Forum Member (41 reputation)Forum Member (41 reputation)

Group: Forum Members
Last Active: 4 Years Ago
Posts: 49, Visits: 179
I am able to get the viewRange on ZoomIn and ZoomOut through the DataZoom Tool's EndDrag Event as:

void chartDataZoomTool_EndDrag(object sender, EventArgs e)
{
chartControl.Document.Calculate();
chartControl.Document.RecalcLayout(chartControl.View.Context);

NRange1DD xAxisRange = chart.Axis(StandardAxis.PrimaryX).Scale.RulerRange;
DateTime startdate = DateTime.FromOADate(xAxisRange.Begin);
DateTime enddate = DateTime.FromOADate(xAxisRange.End);

System.Diagnostics.Debug.WriteLine("Zoom Tool EndDrag: StartDate" + startdate + "- End Date:" + enddate);
}



I have subscribed to the PrimaryXAxis's Scrollbar events and other events giving correct values except the ZoomOut event.

Axis Initialization:

private void InitializePrimaryXAxis()
{
chartPrimaryXAxis = chart.Axis(StandardAxis.PrimaryX);
// X Axis Configuration

dateTimeScale = new NDateTimeScaleConfigurator();
dateTimeScale.Title.Text = string.Empty;
dateTimeScale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 90);
dateTimeScale.LabelStyle.ContentAlignment = ContentAlignment.MiddleCenter;
dateTimeScale.LabelStyle.TextStyle.FontStyle = new NFontStyle("Times New Roman", 10);
dateTimeScale.LabelFitModes = new LabelFitMode[] { LabelFitMode.AutoScale };
chartPrimaryXAxis.ScaleConfigurator = dateTimeScale;
chartPrimaryXAxis.ScrollBar.Visible = true;
chartPrimaryXAxis.ScrollBar.ResetButton.Visible = true;
chartPrimaryXAxis.ScrollBar.ShowSliders = true;
chartPrimaryXAxis.ScrollBar.Reset += new EventHandler(ScrollBar_Reset);
chartPrimaryXAxis.ScrollBar.BeginValueChanged += new EventHandler(ScrollBar_BeginValueChanged);
chartPrimaryXAxis.ScrollBar.EndValueChanged += new EventHandler(ScrollBar_EndValueChanged);
chartPrimaryXAxis.ScrollBar.ViewRangeChanged += new EventHandler(ScrollBar_ViewRangeChanged);
dateTimeScale.EnableUnitSensitiveFormatting = true;
dateTimeScale.RoundToTickMax = false;
dateTimeScale.RoundToTickMin = false;
}


// Reset Event

void ScrollBar_Reset(object sender, EventArgs e)
{
NRange1DD xAxisRange = new NRange1DD(chartPrimaryXAxis.ScrollBar.BeginValue, chartPrimaryXAxis.ScrollBar.EndValue);
//NRange1DD xAxisRange = chart.Axis(StandardAxis.PrimaryX).Scale.RulerRange;
DateTime startdate = DateTime.FromOADate(xAxisRange.Begin);
DateTime enddate = DateTime.FromOADate(xAxisRange.End);
NScrollBar scrollbar = (sender as NScrollBar);
System.Diagnostics.Debug.WriteLine("ScrollBar EndValueChanged: StartDate" +
DateTime.FromOADate(scrollbar.BeginValue) + "- End Date:" + DateTime.FromOADate(scrollbar.EndValue));

System.Diagnostics.Debug.WriteLine("Horizontal Axis Begin Value" + startdate.ToString());
System.Diagnostics.Debug.WriteLine("Horizontal Axis End Value" + enddate.ToString());
}


When i get value on Reset event it return the view range before the page view zoom out.

Question 1: How can i get updated Zoom PagingView Range on Reset event.
Question 2: How can i full Axis Range with paging?? example i have XValues 1 Jan to 31 Dec then which Axis property will let me know this at run time??
Question 3: What is the best way to get the Current Chart View Page begin and end values ( Range)?




Similar Topics


Reading This Topic