Profile Picture

NDataZoomTool Save / Restore Selected Range

Posted By James Richason 5 Years Ago
Author
Message
James Richason
Posted 5 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 5 Years Ago
Posts: 10, Visits: 63
Is there a way to save the current zoom and then restore it?

I have issues where the chart is cleared and restored during different events. It seems that it would be easiest to save the zoom and restore it on the new view.

Thanks 

Jim

Nevron Support
Posted 5 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,000
Hi James,

The zoom information is stored in the PagingView object attached to the axis. In order to save / restore the zoom level for a particular axis you can clone the view object and then assign it later to the axis when you want to restore the zoom to a previous state. The following code example shows how to do that:
private void Form1_Load(object sender, EventArgs e)
{
    NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
    chart.RangeSelections.Add(new NRangeSelection());

    NBarSeries bar = new NBarSeries();
    bar.Values.Add(10);
    bar.Values.Add(20);
    bar.Values.Add(30);
    chart.Series.Add(bar);

    nChartControl1.Controller.Tools.Add(new NPanelSelectorTool());
    nChartControl1.Controller.Tools.Add(new NDataZoomTool());
   }

   NAxisPagingView xView;
   NAxisPagingView yView;

   private void button1_Click(object sender, EventArgs e)
   {
    NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
    xView = (NAxisPagingView)chart.Axis(StandardAxis.PrimaryX).PagingView.Clone();
    yView = (NAxisPagingView)chart.Axis(StandardAxis.PrimaryY).PagingView.Clone();
   }

   private void button2_Click(object sender, EventArgs e)
   {
    NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
    chart.Axis(StandardAxis.PrimaryX).PagingView = (NAxisPagingView)xView.Clone();
    chart.Axis(StandardAxis.PrimaryY).PagingView = (NAxisPagingView)yView.Clone();

    nChartControl1.Refresh();
   }
Hope we helped - let us know if you meet any problems or have any questions.

Best Regards,
Nevron Support Team



Nevron Support
Posted 5 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,000
Hi James,
The scrollbar will fire the reset event when clicked:
   chart.Axis(StandardAxis.PrimaryX).ScrollBar.Reset += ScrollBar_Reset;
...
   private void ScrollBar_Reset(object sender, EventArgs e)
   {
    MessageBox.Show("Reset pressed");
   }

Let us know if you meet any problems...

Best Regards,
Nevron Support Team



James Richason
Posted 5 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 5 Years Ago
Posts: 10, Visits: 63
Is there a way to capture when the red circle close button click?

James Richason
Posted 5 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 5 Years Ago
Posts: 10, Visits: 63
The one issue I just noticed is that when I initially zoom to one month in a year of data the x scale is in days.  When I set it to the cloned data the x scale is in months?

Nevron Support
Posted 5 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,000
Hi James,
Can you send us a small code snippet that replicates that?

Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic