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 roundingNLinearScaleConfigurator 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 dataNPointSeries 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.