Group: Forum Members
Last Active: 4 Years Ago
Posts: 49,
Visits: 179
|
I am trying to load the last saved chart position, so i am trying through following code:
chartPrimaryXAxis.ScrollBar.Visible = true; chartPrimaryYAxis.ScrollBar.Visible = true;
chartPrimaryXAxis.ScrollBar.BeginValueChanged += new EventHandler(ScrollBar_BeginValueChanged); chartPrimaryXAxis.PagingView = new NDateTimeAxisPagingView(); chartPrimaryYAxis.PagingView = new NNumericAxisPagingView(); UpdateDateTimeScale(); dateTimeScale.EnableUnitSensitiveFormatting = true; // configure interactivity chartControl.Controller.Selection.Add(chartControl.Charts[0]); NRangeSelection rangeSelection = (chart.RangeSelections[0] as NRangeSelection); rangeSelection.HorizontalAxisRange = new NRange1DD(new DateTime(2011, 06, 1, 10, 00, 00).ToOADate(), new DateTime(2011, 06, 1, 23, 00, 00).ToOADate());
chartControl.Controller.Tools.Add(new NSelectorTool()); chartControl.Controller.Tools.Add(new NAxisScrollTool()); chartControl.Controller.Tools.Add(new NDataZoomTool()); rangeSelection.ZoomIn();
How can i achieve this??
I have gotten the axis range 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("Horizontal Axis Begin Value" + startdate.ToString()); System.Diagnostics.Debug.WriteLine("Horizontal Axis End Value" + enddate.ToString()); }
That does not work so i have tried to zoomIn using the PagingView and it works, but there a problem that when i am trying to set the zoom begin and end range value on the constructor then it does not work but work fine if it executed on some button's event.
//PagingView 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; dateTimeScale.EnableUnitSensitiveFormatting = true; dateTimeScale.RoundToTickMax = false; dateTimeScale.RoundToTickMin = false;
NDateTimeAxisPagingView dateTimePagingView = new NDateTimeAxisPagingView(); chartPrimaryXAxis.PagingView = dateTimePagingView; //chart.Axis(StandardAxis.PrimaryY).PagingView = new NNumericAxisPagingView(); }
/// Reload button working that called on the constructor, but page view set to month 6 to 12 if year data available.
private void ReloadInSaveState() { chart.RangeSelections.Clear(); NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.MinHorizontalPageSize = 0; rangeSelection.MinVerticalPageSize = 0; rangeSelection.ZoomOutResetsAxis = false; rangeSelection.HorizontalAxisId = (int)StandardAxis.PrimaryX; rangeSelection.VerticalAxisId = (int)StandardAxis.PrimaryY;
rangeSelection.PreserveAspectRatio = false; rangeSelection.HorizontalValueSnapper = null; rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); chart.RangeSelections.Add(rangeSelection);
NDateTimeAxisPagingView XPagingView = chartPrimaryXAxis.PagingView as NDateTimeAxisPagingView; XPagingView.ResetMode = PagingViewResetMode.LastZoom; UpdateDateTimeScale();
// configure interactivity
NRange1DD viewRange = new NRange1DD(new DateTime(2011, 1, 21, 4, 0, 0).ToOADate(), new DateTime(2011, 1, 21, 10, 0, 0).ToOADate()); // rangeSelection.HorizontalAxisRange = viewRange; XPagingView.Enabled = true; chartControl.Controller.Tools.Add(new NSelectorTool()); chartControl.Controller.Tools.Add(chartDataZoomTool); chartControl.Controller.Tools.Add(new NAxisScrollTool());
//rangeSelection.VerticalAxisRange = new NRange1DD(2, 4); //rangeSelection.SetAxisRanges(viewRange, viewRange);
XPagingView.ZoomIn(viewRange, 2); chartControl.Refresh();
//rangeSelection.ZoomIn(); }
/// When i call this method on button event, it reset to some range. private void btnRestore_Click(object sender, EventArgs e) { ReloadInSaveState(); }
and i have saved that range to global scope.
Now i am trying to put the chart in same state when my dataZoomTool left.
|