Nevron Forum

How to use NZoomTool and NAxisScrollTool together, as my way of doing this causes problem with hovering on axis scroll bars after zooming

https://www.nevron.com/Forum/Topic5911.aspx

By Atif Riaz - Friday, December 2, 2011

Below is the code used for creating chart with NZoomTool and NAxisScrollTool together. After zooming in or out, the scrollbars hovering functionality behave strangly (the scrollbar buttons highlight when mouse is slightly off the buttons). I am sure I am doing something silly or is there some other way to do this?



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Nevron.GraphicsCore;
using Nevron.Chart;
using Nevron.Chart.WinForm;

namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

nChartControl1.Legends.Clear();

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

NAxis axisX = chart.Axis(StandardAxis.PrimaryX);
NNumericAxisPagingView xPagingView = new NNumericAxisPagingView(new NRange1DD(0, 100));
xPagingView.MinPageLength = 1.0;
axisX.PagingView = xPagingView;
axisX.ScrollBar.Visible = true;

NAxis axisY = chart.Axis(StandardAxis.PrimaryY);
NNumericAxisPagingView yPagingView = new NNumericAxisPagingView(new NRange1DD(0, 100));
yPagingView.MinPageLength = 1.0;
axisY.PagingView = yPagingView;
axisY.ScrollBar.Visible = true;

Random rand = new Random();
NPointSeries lineSeries = (NPointSeries)chart.Series.Add(SeriesType.Point);
for (int i = 0; i < 100; i++)
{
lineSeries.UseXValues = true;
lineSeries.XValues.Add(rand.Next(100));
lineSeries.Values.Add(rand.Next(100));
}

nChartControl1.Controller.Tools.Add(new NSelectorTool());
nChartControl1.Controller.Tools.Add(new NZoomTool());
nChartControl1.Controller.Tools.Add(new NAxisScrollTool());
}
}
}
By Nevron Support - Monday, December 5, 2011

Hi Atif,

Generally we don't recommend using the Zoom tool with the axis scroll tool - the better combination is the data zoom zoom + scroll - for example:

   nChartControl1.Legends.Clear();

   NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
   chart.RangeSelections.Add(new NRangeSelection());

   NAxis axisX = chart.Axis(StandardAxis.PrimaryX);
   NNumericAxisPagingView xPagingView = new NNumericAxisPagingView(new NRange1DD(0, 100));
   xPagingView.MinPageLength = 1.0;
   axisX.PagingView = xPagingView;
   axisX.ScrollBar.Visible = true;

   NAxis axisY = chart.Axis(StandardAxis.PrimaryY);
   NNumericAxisPagingView yPagingView = new NNumericAxisPagingView(new NRange1DD(0, 100));
   yPagingView.MinPageLength = 1.0;
   axisY.PagingView = yPagingView;
   axisY.ScrollBar.Visible = true;

   Random rand = new Random();
   NPointSeries lineSeries = (NPointSeries)chart.Series.Add(SeriesType.Point);
   for (int i = 0; i < 100; i++)
   {
    lineSeries.UseXValues = true;
    lineSeries.XValues.Add(rand.Next(100));
    lineSeries.Values.Add(rand.Next(100));
   }

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

Note that you'll need a range selection in the chart. Hope this helps - let us know if you meet any problems.

 

By joern kunze - Monday, January 30, 2012

... just a further remark:

the sequenze of the commands _NevronChart.Controller.Tools.Add when initializing the chart is very important:

//works perfect:
_NevronChart.Controller.Tools.Add(new NSelectorTool());

_DataZoomTool = new NDataZoomTool();
_NevronChart.Controller.Tools.Add(_DataZoomTool);

_AxisScrollTool = new NAxisScrollTool();
_NevronChart.Controller.Tools.Add(_AxisScrollTool);

//behaves strangly with "normal" data / application crash with larger data when chart is initialized again:
_DataZoomTool = new NDataZoomTool();
_NevronChart.Controller.Tools.Add(_DataZoomTool);

_AxisScrollTool = new NAxisScrollTool();
_NevronChart.Controller.Tools.Add(_AxisScrollTool);

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

Best regards,
Joern