Scrolling Stuck in Microsoft Chart Control

2011-06-07


We have a windows form project which used Microsoft Chart Control. The Axis X is DateTime type, Axis Y are double values.

We need zoom in/out feature and scroll feature, so we have already the following initial code:

chartAreaTrending.CursorX.Interval = 0;
chartAreaTrending.CursorY.Interval = 0;
chartAreaTrending.CursorX.IsUserSelectionEnabled = <span class="kwrd">true</span>;
chartAreaTrending.CursorY.IsUserSelectionEnabled = <span class="kwrd">true</span>;
chartAreaTrending.AxisX.ScaleView.Zoomable = <span class="kwrd">true</span>;
chartAreaTrending.AxisY.ScaleView.Zoomable = <span class="kwrd">true</span>;
chartAreaTrending.CursorX.SelectionColor = Color.DarkGray;
chartAreaTrending.CursorY.SelectionColor = Color.DarkGray;
chartAreaTrending.AxisY.ScrollBar.ButtonStyle = ScrollBarButtonStyles.SmallScroll;
<span class="kwrd">this</span>.chartAreaTrending.AxisX.IntervalType = DateTimeIntervalType.Minutes;
<span class="kwrd">this</span>.chartAreaTrending.AxisX.LabelStyle.Format = <span class="str">&quot;yyyy-MM-dd HH:mm&quot;</span>;</pre>

But later we found the scrolling function on Axis X stuck, we could not scroll but just sometimes jumped very long step.

mschartScroll00

The problem should be from the chart area zoom, firstly we tried to add the following code about ScaleView of AxisX:

<span class="kwrd">this</span>.chartAreaTrending.AxisX.ScaleView.MinSize = 0;
<span class="kwrd">this</span>.chartAreaTrending.AxisX.ScaleView.MinSizeType = DateTimeIntervalType.Minutes;
<span class="kwrd">this</span>.chartAreaTrending.AxisY.ScaleView.MinSize = 0;</pre>

But it still did not work.

Finally we featured out we should set value for SmallScrollSize and SmallScrollSizeType.

mschartScroll01

So we need to add the following code to implement:

<span class="kwrd">this</span>.chartAreaTrending.AxisX.ScaleView.SmallScrollMinSizeType = DateTimeIntervalType.Minutes;
<span class="kwrd">this</span>.chartAreaTrending.AxisX.ScaleView.SmallScrollSizeType = DateTimeIntervalType.Minutes;
<span class="kwrd">this</span>.chartAreaTrending.AxisY.ScaleView.SmallScrollMinSize = 0.01;
<span class="kwrd">this</span>.chartAreaTrending.AxisY.ScaleView.SmallScrollSize = 0.01;</pre>