Data zoom (use NDataZoomTool + NOffsetTool), show selected area in another window


Data zoom (use NDataZoomTool + NOffsetTool), show selected area in...
Author
Message
Alex Art
Alex Art
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)
Group: Forum Members
Posts: 3, Visits: 1
I'm happy with NDataZoomTool , but I want also to be able to do the following

1. Is it possible to combine NDataZoomTool + NOffsetTool(or in another way), so I want to be able to zoom in data and at the same time move screen to select data which are close to current selected subset

2. When I have NDataZoomTool , I want to be able dig in data using mouse wheel (when I move wheel down, it will behave as if I selected smaller area with NDataZoomTool and moving wheel up will move me step back showing previous subset of data)

3. I want to show current selected subset of data (like small chart in additional window where I show data "" + selected area)

Thanks in advance!

Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Alex,

1. Is it possible to combine NDataZoomTool + NOffsetTool(or in another way), so I want to be able to zoom in data and at the same time move screen to select data which are close to current selected subset

Most likely you have to combine the NDataZoomTool + NDataPanTool - check out the "Data Pan Tool" example. This will allow you to to move the selected area when you right click on the chart.

2. When I have NDataZoomTool , I want to be able dig in data using mouse wheel (when I move wheel down, it will behave as if I selected smaller area with NDataZoomTool and moving wheel up will move me step back showing previous subset of data)

You can use a secondary data zoom tool that reacts on mouse wheel. Note that it will zoom relative to the current position of the mouse - for example:

NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
chart.RangeSelections.Add(
new NRangeSelection());
NPointSeries point = new NPointSeries();
point.DataLabelStyle.Visible =
false;
point.UseXValues =
true;
for (int i = 0; i < 10; i++)
{
point.Values.Add(i);
point.XValues.Add(i);
}

chart.Series.Add(point);

nChartControl1.Controller.Tools.Add(new NSelectorTool());
nChartControl1.Controller.Tools.Add(
new NDataZoomTool());
NDataZoomTool wheelZoom = new NDataZoomTool();
wheelZoom.BeginDragMouseCommand =
new NMouseCommand(MouseAction.Wheel, MouseButtons.Left, 0);
nChartControl1.Controller.Tools.Add(wheelZoom);
nChartControl1.Controller.Tools.Add(
new NDataPanTool());


3. I want to show current selected subset of data (like small chart in additional window where I show data "" + selected area)

The following code shows how to create two charts that show the same data, where the first chart displays a zoomed portion of it and the second one displays a range selection for the zoomed area:

public class NCustomPaintCallback : NPaintCallback

{

public NCustomPaintCallback(Form1 form)

{

m_Form = form;

}

public override void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs)

{

m_Form.OnAxisRangeChanged(null, null);

}

Form1 m_Form;

}

private void Form1_Load(object sender, EventArgs e)

{

NCartesianChart chart1 = (NCartesianChart)nChartControl1.Charts[0];

NRangeSelection rs1 = new NRangeSelection();

chart1.RangeSelections.Add(rs1);

chart1.PaintCallback = new NCustomPaintCallback(this);

NCartesianChart chart2 = (NCartesianChart)nChartControl2.Charts[0];

chart2.RangeSelections.Add(new NRangeSelection());

ConfigureChart(chart1);

ConfigureChart(chart2);

nChartControl1.Controller.Tools.Add(new NSelectorTool());

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

NDataZoomTool wheelZoom = new NDataZoomTool();

wheelZoom.BeginDragMouseCommand = new NMouseCommand(MouseAction.Wheel, MouseButtons.Left, 0);

nChartControl1.Controller.Tools.Add(wheelZoom);

nChartControl1.Controller.Tools.Add(new NDataPanTool());

}

private void ConfigureChart(NChart chart)

{

chart.BoundsMode = BoundsMode.Stretch;

// turn off tick rounding

NLinearScaleConfigurator xScale = new NLinearScaleConfigurator();

xScale.RoundToTickMax = false;

xScale.RoundToTickMin = false;

chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = xScale;

NLinearScaleConfigurator yScale = new NLinearScaleConfigurator();

yScale.RoundToTickMax = false;

yScale.RoundToTickMin = false;

chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = yScale;

// add some dummy data

NPointSeries point = new NPointSeries();

point.DataLabelStyle.Visible = false;

point.UseXValues = true;

for (int i = 0; i < 10; i++)

{

point.Values.Add(i);

point.XValues.Add(i);

}

chart.Series.Add(point);

}

void OnAxisRangeChanged(object sender, EventArgs e)

{

NCartesianChart chart2 = (NCartesianChart)nChartControl2.Charts[0];

NRangeSelection rs = (NRangeSelection)chart2.RangeSelections[0];

NCartesianChart chart1 = (NCartesianChart)nChartControl1.Charts[0];

NAxis xAxis = chart1.Axis(StandardAxis.PrimaryX);

NAxis yAxis = chart1.Axis(StandardAxis.PrimaryY);

rs.Visible = xAxis.PagingView.Enabled || yAxis.PagingView.Enabled;

rs.HorizontalAxisRange = xAxis.Scale.RulerRange;

rs.VerticalAxisRange = yAxis.Scale.RulerRange;

nChartControl2.Refresh();

}

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



Best Regards,
Nevron Support Team


Alina Voskova
Alina Voskova
Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)
Group: Forum Members
Posts: 43, Visits: 1
Hello.
I'm also interesting in Alex's question number 1. But I want to know how to do the same thing in code. In more detail: I have on my chart NSelectorTool, NAxisScrollTool, NDataPanTool, NDataZoomTool. So the user have the ability to change the scale. I know the line series and the point index on this line series. I want to put this point in the center of the chart without changing the scale.
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi Ereona,

The following code shows how to center the axis when its scrolling to some value (in this case 30):

   double xValue = 30;
   NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

   NNumericAxisPagingView view = chart.Axis(StandardAxis.PrimaryX).PagingView as NNumericAxisPagingView;

   if (view.Enabled)
   {
    double length = view.Length;
    double begin = xValue - length / 2.0;
    double end = xValue + length / 2.0;
    
    view.ZoomIn(new NRange1DD(begin, end), 0.001);
    nChartControl1.Refresh();
   }

Note that you have to check whether the current paging view is enabled and ZoomIn afterwards.



Best Regards,
Nevron Support Team


Alina Voskova
Alina Voskova
Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)Forum Member (43 reputation)
Group: Forum Members
Posts: 43, Visits: 1
Thank you very much!
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search