Page 1 of 1

axis Maximum, Minimum and the Offset and related

Posted: Wed Nov 19, 2014 1:56 pm
by 16670455
Guys let me ask you about this behavior:

when I set the axis offset property and after this if I read the maximum/minimum property I got the maximum and minimum values of the axis before the offset, so the values are not the ones displayed at the chart

The question: is it normal ? Seems that I have to calculate by myself the real values of the maximum and minimum of the chart to calculate correctly the increments

It seems that MaximumRound/MinimumRound also does not take in account the offsets or I did not understand how the round works in teechart (see the pic)
janela3.png
janela3.png (23.59 KiB) Viewed 13158 times
Here is the code to show all above.

Code: Select all

Private Sub Command1_Click()
TChart1.Series(0).Clear
 TChart1.Series(0).FillSampleValues Rnd * 100
 Me.TChart1.Repaint
Me.TChart1.Axis.Bottom.Increment = (Me.TChart1.Axis.Bottom.Maximum - Me.TChart1.Axis.Bottom.Minimum) / 5
Me.TChart1.Axis.Left.Increment = (Me.TChart1.Axis.Left.Maximum - Me.TChart1.Axis.Left.Minimum) / 5
Me.Text1.Text = ""
Me.Text1.Text = ".bottom.minimum=" + Format(Me.TChart1.Axis.Bottom.Minimum, "#####0.000") + vbCrLf
Me.Text1.Text = Me.Text1.Text + ".bottom.maximum=" + Format(Me.TChart1.Axis.Bottom.Maximum, "#####0.000") + vbCrLf
Me.Text1.Text = Me.Text1.Text + ".left.minimum=" + Format(Me.TChart1.Axis.Left.Minimum, "#####0.000") + vbCrLf
Me.Text1.Text = Me.Text1.Text + ".left.maximum=" + Format(Me.TChart1.Axis.Left.Maximum, "#####0.000") + vbCrLf
End Sub

Private Sub Form_Load()
Randomize
Me.Show

 TChart1.Series(0).FillSampleValues Rnd * 100
With Me.TChart1
    .Panel.Gradient.Visible = False
    .Walls.Visible = True
    .Walls.Back.Color = vbWhite
    .Walls.Back.Gradient.Visible = False
    
    .Axis.Bottom.Ticks.Visible = False
    .Axis.Bottom.TickInnerLength = 6
    .Axis.Bottom.AxisPen.Color = vbBlack
    .Axis.Bottom.TicksInner.Color = vbBlack
    .Axis.Bottom.GridPen.Color = &HC0C0C0
    .Axis.Bottom.Labels.RoundFirstLabel = False
    .Axis.Bottom.MaximumRound = True
    .Axis.Bottom.MinimumRound = True
    .Axis.Bottom.MinimumOffset = 10
    .Axis.Bottom.MaximumOffset = 10
    
  
  
    .Axis.Left.Ticks.Visible = False
    .Axis.Left.TickInnerLength = 6
    .Axis.Left.AxisPen.Color = vbBlack
    .Axis.Left.TicksInner.Color = vbBlack
    .Axis.Left.GridPen.Color = &HC0C0C0
    .Axis.Left.Labels.RoundFirstLabel = False
    .Axis.Left.MaximumRound = True
    .Axis.Left.MinimumRound = True
    .Axis.Left.MinimumOffset = 10
    .Axis.Left.MaximumOffset = 10


End With
Me.TChart1.Repaint
Me.TChart1.Axis.Bottom.Increment = (Me.TChart1.Axis.Bottom.Maximum - Me.TChart1.Axis.Bottom.Minimum) / 5
Me.TChart1.Axis.Left.Increment = (Me.TChart1.Axis.Left.Maximum - Me.TChart1.Axis.Left.Minimum) / 5
Me.Text1.Text = ""
Me.Text1.Text = ".bottom.minimum=" + Format(Me.TChart1.Axis.Bottom.Minimum, "#####0.000") + vbCrLf
Me.Text1.Text = Me.Text1.Text + ".bottom.maximum=" + Format(Me.TChart1.Axis.Bottom.Maximum, "#####0.000") + vbCrLf
Me.Text1.Text = Me.Text1.Text + ".left.minimum=" + Format(Me.TChart1.Axis.Left.Minimum, "#####0.000") + vbCrLf
Me.Text1.Text = Me.Text1.Text + ".left.maximum=" + Format(Me.TChart1.Axis.Left.Maximum, "#####0.000") + vbCrLf



End Sub

Re: axis Maximum, Minimum and the Offset and related

Posted: Wed Nov 19, 2014 2:11 pm
by 16670455
Strange... if I comment the lines with MinimumOffset and MaximumOffset it seems to not change anything, i.e., the offsets still are applied....

Re: axis Maximum, Minimum and the Offset and related

Posted: Thu Nov 20, 2014 9:40 am
by yeray
Hello,

The Offsets set are applied internally without modifying the Minimum&Maximum properties.
If you want to calculate the resultant Minimum&Maximum, you could do this:

Code: Select all

    With .Axis
      Text1.Text = ""
      Text1.Text = ".bottom.minimum=" + Format(.Bottom.CalcPosPoint(.Bottom.IStartPos), "#####0.000") + vbCrLf
      Text1.Text = Text1.Text + ".bottom.maximum=" + Format(.Bottom.CalcPosPoint(.Bottom.IEndPos), "#####0.000") + vbCrLf
      Text1.Text = Text1.Text + ".left.minimum=" + Format(.Left.CalcPosPoint(.Left.IEndPos), "#####0.000") + vbCrLf
      Text1.Text = Text1.Text + ".left.maximum=" + Format(.Left.CalcPosPoint(.Left.IStartPos), "#####0.000") + vbCrLf
    End With