Page 1 of 1

Setting Number of Horizontal Grid Lines While Zooming

Posted: Wed Aug 07, 2013 9:04 pm
by 9524540
Hello,

The graph is setup to follow the 1-2-5 rule across 20 horizontal lines for the Y-Axis of the grid during normal view.
My customer is requesting that the number of horizontal grid lines remain constant (20 Lines) while in Zoomimg or Panning.
How can I do this?

Thanks

Re: Setting Number of Horizontal Grid Lines While Zooming

Posted: Thu Aug 08, 2013 3:26 pm
by yeray
Hello,

What about setting a Left Axis Increment each time the chart is zoomed/unzoomed?
Ie:

Code: Select all

Dim nGridLines As Integer

Private Sub Form_Load()
  TChart1.Aspect.View3D = False
  
  TChart1.AddSeries scLine
  With TChart1.Series(0)
    .FillSampleValues
  End With
  
  nGridLines = 20
  TChart1.Environment.InternalRepaint
  recalcIncrement
End Sub

Private Sub TChart1_OnUndoZoom()
  recalcIncrement
End Sub

Private Sub TChart1_OnZoom()
  recalcIncrement
End Sub

Private Sub recalcIncrement()
  With TChart1.Axis.Left
    .Increment = (.Maximum - .Minimum) / nGridLines
  End With
End Sub

Re: Setting Number of Horizontal Grid Lines While Zooming

Posted: Fri Aug 09, 2013 8:34 pm
by 9524540
Yeray,

Thanks for the info.

That got me started in the right direction.
I also had to set the min.Separation % to 0 to keep the 20 lines from disappearing if the graph height is set to short.
I modified the code to cover both left and right axis.