Nevron Forum

scroll bar with animated zoom

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

By Daniel Csimszi - Thursday, June 6, 2013

Hi,

I tried to include your data zoom tool (C# Examples/All Examples/Interactivity/Tools/Data Zoom Tool) in my project, how ever I noticed that the scroll bar does not work on it. Are there any extra code which is need to be added?

Regards
Daniel
By Nevron Support - Thursday, June 6, 2013

Hi Daniel,

Can you post the code you used to configure the control?
By Daniel Csimszi - Friday, June 7, 2013

Hi,

This is my constructor, where I set up the scroll and zoom as well:

NDataZoomTool m_DataZoomTool = new NDataZoomTool();

this.nChartControl1 = nChartControl1;

#region chart set up

// configure the chart
m_Chart = (NCartesianChart)nChartControl1.Charts[0];

// add interlaced stripe to the Y axis
NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1);
stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back };
((NStandardScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator).StripStyles.Add(stripStyle);
m_Chart.Location = new NPointL(new NLength(0, NRelativeUnit.ParentPercentage), new NLength(5, NRelativeUnit.ParentPercentage));
m_Chart.Size = new NSizeL(new NLength(100, NRelativeUnit.ParentPercentage), new NLength(95, NRelativeUnit.ParentPercentage));


NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
NRangeSelection rangeSelection = new NRangeSelection();
rangeSelection.ZoomOutResetsAxis = true;
chart.RangeSelections.Add(rangeSelection);
chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true;
chart.Axis(StandardAxis.PrimaryY).ScrollBar.Visible = true;

//set up axis X
NAxis axiss = m_Chart.Axis(StandardAxis.PrimaryX);
NDateTimeScaleConfigurator dateTimeScale = new NDateTimeScaleConfigurator();
dateTimeScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
dateTimeScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
dateTimeScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, false);
dateTimeScale.InnerMajorTickStyle.Length = new NLength(0);
dateTimeScale.MaxTickCount = 5;
dateTimeScale.MajorTickMode = MajorTickMode.AutoMaxCount;
dateTimeScale.AutoDateTimeUnits = new NDateTimeUnit[] { NDateTimeUnit.Second };
dateTimeScale.RoundToTickMin = false;
dateTimeScale.RoundToTickMax = false;
dateTimeScale.EnableUnitSensitiveFormatting = false;
dateTimeScale.LabelValueFormatter = new NDateTimeValueFormatter("dd-MMM-yy \r\n hh:mm:ss");
//DateTimeValueFormat.Year2Digit, DateTimeValueFormat.Year2Digit
dateTimeScale.LabelStyle.TextStyle = new NTextStyle(new Font("Verdana", 8), Color.Black);
axiss.ScaleConfigurator = dateTimeScale;

nChartControl1.Settings.AnimationInterval = 50;
m_DataZoomTool.AnimateZooming = true;
m_DataZoomTool.AnimationSteps = 10;

nChartControl1.Controller.Tools.Add(m_DataZoomTool);


nChartControl1.Controller.Selection.Add(chart);
nChartControl1.Controller.Tools.Add(new NAxisScrollTool());
nChartControl1.Controller.Tools.Add(new NDataZoomTool());

#endregion
By Nevron Support - Friday, June 7, 2013

Hi Daniel,

You add the data zoom tool before the axis scroll tool, which prevents this tool from being activated. The correct order is:

nChartControl1.Controller.Selection.Add(chart);
nChartControl1.Controller.Tools.Add(new NAxisScrollTool());
nChartControl1.Controller.Tools.Add(m_DataZoomTool);

Also there is no need to add the data zoom tool twice.
By Daniel Csimszi - Sunday, June 9, 2013

Thank you, works perfectly